audio/internal/readerdriver: Bug fix: An error was overwritten

This commit is contained in:
Hajime Hoshi 2021-05-18 21:08:26 +09:00
parent ae14caee93
commit e43dcc2265

View File

@ -537,13 +537,13 @@ func (p *playerImpl) closeImpl() error {
osstatus := C.AudioQueueStop(q, C.true) osstatus := C.AudioQueueStop(q, C.true)
p.cond.L.Lock() p.cond.L.Lock()
if osstatus != C.noErr && p.err != nil { if osstatus != C.noErr && p.err == nil {
// setErrorImpl calls closeImpl. Do not call this. // setErrorImpl calls closeImpl. Do not call this.
p.err = fmt.Errorf("readerdriver: AudioQueueStop failed: %d", osstatus) p.err = fmt.Errorf("readerdriver: AudioQueueStop failed: %d", osstatus)
} }
// All the AudioQueueBuffers are already dequeued. It is safe to dispose the AudioQueue and its buffers. // All the AudioQueueBuffers are already dequeued. It is safe to dispose the AudioQueue and its buffers.
if err := p.context.audioQueuePool.Put(p.audioQueue); err != nil && p.err != nil { if err := p.context.audioQueuePool.Put(p.audioQueue); err != nil && p.err == nil {
p.err = err p.err = err
} }
thePlayers.remove(p.audioQueue) thePlayers.remove(p.audioQueue)