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