audio: Bug fix: The dummy player should have long enough buffer

In the current implementation, the audio context will be ready
when a player's Write is finished. If the buffer is too short,
Write finishes immediately without accessing the low audio layer
and the audio context would be ready without playing anything.

This change changes the dummy buffer to have a long enough buffer
so that Write will be wait for acutual audio playing.

Fixes #970
This commit is contained in:
Hajime Hoshi 2019-10-23 02:41:09 +09:00
parent b78f678700
commit 124389561c

View File

@ -200,7 +200,8 @@ func (c *Context) IsReady() bool {
// The audio context is never ready unless there is a player. This is // The audio context is never ready unless there is a player. This is
// problematic when a user tries to play audio after the context is ready. // problematic when a user tries to play audio after the context is ready.
// Play a dummy player to avoid the blocking (#969). // Play a dummy player to avoid the blocking (#969).
p, _ := NewPlayerFromBytes(c, make([]byte, bytesPerSample)) // Use a long enough buffer so that writing doesn't finish immediately (#970).
p, _ := NewPlayerFromBytes(c, make([]byte, bufferSize()*2))
p.Play() p.Play()
}() }()