From d5d5ebb0b31998045426f544104c7e20c08b7135 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 7 Jan 2018 18:32:12 +0900 Subject: [PATCH] clock: Make ProceedAudioTimer take a number of frames --- audio/audio.go | 5 +---- internal/clock/clock.go | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) 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() }