audio/internal/readerdriver: Bug fix: Need to lock the callback logic

This commit is contained in:
Hajime Hoshi 2021-05-17 04:03:04 +09:00
parent 089883aba0
commit 66999989e1

View File

@ -523,9 +523,7 @@ func (p *playerImpl) Close() error {
return p.closeImpl(false)
}
func (p *playerImpl) closeForReuse() error {
p.cond.L.Lock()
defer p.cond.L.Unlock()
func (p *playerImpl) closeForReuseImpl() error {
return p.closeImpl(true)
}
@ -574,11 +572,15 @@ func ebiten_readerdriver_render(inUserData unsafe.Pointer, inAQ C.AudioQueueRef,
p.setError(err)
return
}
if !queued {
if queued {
return
}
p.cond.L.Lock()
defer p.cond.L.Unlock()
p.unqueuedBufs = append(p.unqueuedBufs, inBuffer)
if len(p.unqueuedBufs) == 2 && p.eof {
p.closeForReuse()
}
p.closeForReuseImpl()
}
}