Fix unified player frame reader contention
This commit is contained in:
parent
a4ad5ff8ff
commit
b7f1cd0737
|
|
@ -582,7 +582,8 @@ func (p *UnifiedPlayer) startVideoProcess() error {
|
|||
p.cmd = cmd
|
||||
|
||||
// Start video frame reading goroutine
|
||||
go func() {
|
||||
if !p.previewMode {
|
||||
go func() {
|
||||
rate := p.frameRate
|
||||
if rate <= 0 {
|
||||
rate = 24
|
||||
|
|
@ -626,7 +627,8 @@ func (p *UnifiedPlayer) startVideoProcess() error {
|
|||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ func NewUnifiedPlayerAdapter(path string, width, height int, fps, duration float
|
|||
Muted: false,
|
||||
AutoPlay: false,
|
||||
HardwareAccel: false,
|
||||
PreviewMode: false,
|
||||
PreviewMode: true,
|
||||
AudioOutput: "auto",
|
||||
VideoOutput: "rgb24",
|
||||
CacheEnabled: true,
|
||||
|
|
@ -287,9 +287,15 @@ func (p *UnifiedPlayerAdapter) startUpdateLoop() {
|
|||
case <-p.updateTicker.C:
|
||||
p.mu.Lock()
|
||||
if !p.paused && p.player != nil {
|
||||
// Get current time from UnifiedPlayer
|
||||
currentTime := p.player.GetCurrentTime()
|
||||
p.current = currentTime.Seconds()
|
||||
// Drive timeline locally to avoid fighting the frame reader.
|
||||
elapsed := time.Since(p.startTime).Seconds()
|
||||
if elapsed < 0 {
|
||||
elapsed = 0
|
||||
}
|
||||
if p.duration > 0 && elapsed > p.duration {
|
||||
elapsed = p.duration
|
||||
}
|
||||
p.current = elapsed
|
||||
p.frameN = int(p.current * p.fps)
|
||||
|
||||
// Update UI callbacks
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user