Major improvements to UnifiedPlayer: 1. GetFrameImage() now works when paused for responsive UI updates 2. Play() method properly starts FFmpeg process 3. Frame display loop runs continuously for smooth video display 4. Disabled audio temporarily to fix video playback fundamentals 5. Simplified FFmpeg command to focus on video stream only Player now: - Generates video frames correctly - Shows video when paused - Has responsive progress tracking - Starts playback properly Next steps: Re-enable audio playback once video is stable
31 lines
631 B
Go
31 lines
631 B
Go
package async
|
|
|
|
import "sync"
|
|
|
|
// Implementation inspired by https://github.com/tailscale/tailscale/blob/main/syncs/pool.go.
|
|
|
|
// Pool is the generic version of sync.Pool.
|
|
type Pool[T any] struct {
|
|
pool sync.Pool
|
|
|
|
// New specifies a function to generate
|
|
// a value when Get would otherwise return the zero value of T.
|
|
New func() T
|
|
}
|
|
|
|
// Get selects an arbitrary item from the Pool, removes it from the Pool,
|
|
// and returns it to the caller.
|
|
func (p *Pool[T]) Get() T {
|
|
x, ok := p.pool.Get().(T)
|
|
if !ok && p.New != nil {
|
|
return p.New()
|
|
}
|
|
|
|
return x
|
|
}
|
|
|
|
// Put adds x to the pool.
|
|
func (p *Pool[T]) Put(x T) {
|
|
p.pool.Put(x)
|
|
}
|