audio: Bug fix: alGenBuffer accepts only positive number

This commit is contained in:
Hajime Hoshi 2016-02-12 21:43:00 +09:00
parent b2724e8694
commit 68b84a90b6

View File

@ -132,13 +132,15 @@ 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))
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()
go func() {