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,12 +132,14 @@ func (p *player) play() error {
// TODO: What if play is already called? // TODO: What if play is already called?
emptyBytes := make([]byte, bufferSize) emptyBytes := make([]byte, bufferSize)
m.Lock() m.Lock()
queued := p.alSource.BuffersQueued() n := 8 - int(p.alSource.BuffersQueued())
bufs := al.GenBuffers(8 - int(queued)) if 0 < n {
for _, buf := range bufs { bufs := al.GenBuffers(n)
// Note that the third argument of only the first buffer is used. for _, buf := range bufs {
buf.BufferData(al.FormatStereo16, emptyBytes, int32(p.sampleRate)) // Note that the third argument of only the first buffer is used.
p.alSource.QueueBuffers(buf) buf.BufferData(al.FormatStereo16, emptyBytes, int32(p.sampleRate))
p.alSource.QueueBuffers(buf)
}
} }
al.PlaySources(p.alSource) al.PlaySources(p.alSource)
m.Unlock() m.Unlock()