mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
audio: Adjust buffer size for browsers (#434)
This commit is contained in:
parent
32b33dd86d
commit
8e75964cb1
@ -21,11 +21,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *Context) bufferSize() int {
|
func (c *Context) bufferSize() int {
|
||||||
// TODO: On Chrome and Firefox, 1/30[s] doesn't work with 24000 or 48000 [Hz]
|
n := 10
|
||||||
// at least on macOS.
|
if !web.IsMobileBrowser() {
|
||||||
n := 20
|
// TODO: On Chrome and Firefox, 1/30[s] doesn't work with 24000 or 48000 [Hz]
|
||||||
if web.IsMobileBrowser() {
|
// at least on macOS.
|
||||||
n = 10
|
switch c.sampleRate {
|
||||||
|
case 44100, 88200:
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user