From 68b84a90b6b8e176a17fdf279bf4f0df8e13d4ca Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 12 Feb 2016 21:43:00 +0900 Subject: [PATCH] audio: Bug fix: alGenBuffer accepts only positive number --- exp/audio/audio_openal.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/exp/audio/audio_openal.go b/exp/audio/audio_openal.go index 3bc4443cd..47106c45a 100644 --- a/exp/audio/audio_openal.go +++ b/exp/audio/audio_openal.go @@ -132,12 +132,14 @@ func (p *player) play() error { // TODO: What if play is already called? emptyBytes := make([]byte, bufferSize) m.Lock() - queued := p.alSource.BuffersQueued() - bufs := al.GenBuffers(8 - int(queued)) - for _, buf := range bufs { - // Note that the third argument of only the first buffer is used. - buf.BufferData(al.FormatStereo16, emptyBytes, int32(p.sampleRate)) - p.alSource.QueueBuffers(buf) + n := 8 - int(p.alSource.BuffersQueued()) + if 0 < n { + bufs := al.GenBuffers(n) + for _, buf := range bufs { + // Note that the third argument of only the first buffer is used. + buf.BufferData(al.FormatStereo16, emptyBytes, int32(p.sampleRate)) + p.alSource.QueueBuffers(buf) + } } al.PlaySources(p.alSource) m.Unlock()