audio: Adjust buffer size for browsers (#434)

This commit is contained in:
Hajime Hoshi 2017-09-24 20:16:07 +09:00
parent 32b33dd86d
commit 8e75964cb1

View File

@ -21,11 +21,21 @@ import (
) )
func (c *Context) bufferSize() int { func (c *Context) bufferSize() int {
n := 10
if !web.IsMobileBrowser() {
// TODO: On Chrome and Firefox, 1/30[s] doesn't work with 24000 or 48000 [Hz] // TODO: On Chrome and Firefox, 1/30[s] doesn't work with 24000 or 48000 [Hz]
// at least on macOS. // at least on macOS.
n := 20 switch c.sampleRate {
if web.IsMobileBrowser() { case 44100, 88200:
n = 10 n = 30
case 22050:
// #434
n = 15
case 24000, 48000:
n = 20
default:
n = 15
}
} }
return c.sampleRate * channelNum * bytesPerSample / n return c.sampleRate * channelNum * bytesPerSample / n
} }