From f2173f8f751ea32f141d6f1bac86b194261a154a Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 11 Mar 2016 12:01:48 +0900 Subject: [PATCH] audio: Bug fix: Adjust stream position (#180) --- exp/audio/audio_js.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exp/audio/audio_js.go b/exp/audio/audio_js.go index a3ba95228..56a04ddd9 100644 --- a/exp/audio/audio_js.go +++ b/exp/audio/audio_js.go @@ -77,6 +77,11 @@ func max64(a, b int64) int64 { func (p *player) proceed() error { const bufferSize = 2048 c := int64(p.context.Get("currentTime").Float() * float64(p.sampleRate)) + // Buffer size is relatively big and it is needed to check that c.positionInSample doesn't + // proceed too far away (#180). + if c+bufferSize < p.positionInSamples { + return nil + } if p.positionInSamples < c { p.positionInSamples = c }