clock: Make ProceedAudioTimer take a number of frames

This commit is contained in:
Hajime Hoshi 2018-01-07 18:32:12 +09:00
parent d12a3d4073
commit d5d5ebb0b3
2 changed files with 4 additions and 7 deletions

View File

@ -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
}
}

View File

@ -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()
}