diff --git a/audio/audio.go b/audio/audio.go index 8c818b0b7..0471ae3c7 100644 --- a/audio/audio.go +++ b/audio/audio.go @@ -260,10 +260,7 @@ func (c *Context) loop() { written += int64(n) fs := written/int64(bytesPerFrame) - prevWritten/int64(bytesPerFrame) - for fs > 0 { - clock.ProceedAudioTimer() - fs-- - } + clock.ProceedAudioTimer(fs) prevWritten = written } } diff --git a/internal/clock/clock.go b/internal/clock/clock.go index df129507b..1b97f61f1 100644 --- a/internal/clock/clock.go +++ b/internal/clock/clock.go @@ -66,10 +66,10 @@ func RegisterPing(pingFunc func()) { m.Unlock() } -// ProceedAudioTimer increments the audio time by a frame. -func ProceedAudioTimer() { +// ProceedAudioTimer increments the audio time by the given number of frames. +func ProceedAudioTimer(num int64) { m.Lock() - audioTimeInFrames++ + audioTimeInFrames += num m.Unlock() }