From 124389561c16b1cdf2f9f9aa5715faddcc6ec02c Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 23 Oct 2019 02:41:09 +0900 Subject: [PATCH] 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 --- audio/audio.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audio/audio.go b/audio/audio.go index 1c76e2fb3..f5b32060e 100644 --- a/audio/audio.go +++ b/audio/audio.go @@ -200,7 +200,8 @@ func (c *Context) IsReady() bool { // 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. // 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() }()