mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
audio: Bug fix: alGenBuffer accepts only positive number
This commit is contained in:
parent
b2724e8694
commit
68b84a90b6
@ -132,13 +132,15 @@ 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 {
|
||||||
|
bufs := al.GenBuffers(n)
|
||||||
for _, buf := range bufs {
|
for _, buf := range bufs {
|
||||||
// Note that the third argument of only the first buffer is used.
|
// Note that the third argument of only the first buffer is used.
|
||||||
buf.BufferData(al.FormatStereo16, emptyBytes, int32(p.sampleRate))
|
buf.BufferData(al.FormatStereo16, emptyBytes, int32(p.sampleRate))
|
||||||
p.alSource.QueueBuffers(buf)
|
p.alSource.QueueBuffers(buf)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
al.PlaySources(p.alSource)
|
al.PlaySources(p.alSource)
|
||||||
m.Unlock()
|
m.Unlock()
|
||||||
go func() {
|
go func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user