From 623caad3ec089b0632199f0a9e5a04b6a3f11b96 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 25 Dec 2017 01:54:55 +0900 Subject: [PATCH] audio: Bug fix: appropriate buffer size on browsers --- audio/audio.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/audio/audio.go b/audio/audio.go index 305d87894..9a90402d6 100644 --- a/audio/audio.go +++ b/audio/audio.go @@ -232,10 +232,11 @@ func (c *Context) loop() { // This is a heuristic decision of audio buffer size. // On most desktops and mobiles, 4096 [bytes] is enough but there are some known environment that is too short (e.g. Windows on Parallels). - // On browsers, 8192 [bytes] should work with any sample rate except for Android Chrome. + // On browsers, samples for 12800 [bytes] should work with any sample rate. + // This is misterious but e.g. 8192 [bytes], 12000 [bytes] or 16384 [bytes] doesn't work on Chrome well... bufferSize := 8192 - if web.IsAndroidChrome() { - bufferSize = 12000 + if web.IsBrowser() { + bufferSize = 12800 } p, err := oto.NewPlayer(c.sampleRate, channelNum, bytesPerSample, bufferSize) if err != nil {