audio/internal/readerdriver: Bug fix: AudioQueuePause/Reset might take long time

This issue has existed since ae14caee93.
This change fixes the issue by skipping the C function calls when
possible.

Updates #1650
This commit is contained in:
Hajime Hoshi 2021-05-28 02:45:31 +09:00
parent a4d28198f4
commit 72d8d77173

View File

@ -449,6 +449,7 @@ func (p *playerImpl) resetImpl() {
return
}
if len(p.unqueuedBufs) < 2 {
if osstatus := C.AudioQueuePause(p.audioQueue); osstatus != C.noErr && p.err == nil {
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueuePause failed: %d", osstatus))
return
@ -462,6 +463,7 @@ func (p *playerImpl) resetImpl() {
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueReset failed: %d", osstatus))
return
}
}
p.state = playerPaused
p.buf = p.buf[:0]