mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
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:
parent
a4d28198f4
commit
72d8d77173
@ -449,18 +449,20 @@ func (p *playerImpl) resetImpl() {
|
||||
return
|
||||
}
|
||||
|
||||
if osstatus := C.AudioQueuePause(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueuePause failed: %d", osstatus))
|
||||
return
|
||||
}
|
||||
// AudioQueueReset invokes the callback directry.
|
||||
q := p.audioQueue
|
||||
p.cond.L.Unlock()
|
||||
osstatus := C.AudioQueueReset(q)
|
||||
p.cond.L.Lock()
|
||||
if osstatus != C.noErr && p.err == nil {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueReset failed: %d", osstatus))
|
||||
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
|
||||
}
|
||||
// AudioQueueReset invokes the callback directry.
|
||||
q := p.audioQueue
|
||||
p.cond.L.Unlock()
|
||||
osstatus := C.AudioQueueReset(q)
|
||||
p.cond.L.Lock()
|
||||
if osstatus != C.noErr && p.err == nil {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueReset failed: %d", osstatus))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
p.state = playerPaused
|
||||
|
Loading…
Reference in New Issue
Block a user