mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-03 22:44:28 +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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if osstatus := C.AudioQueuePause(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
if len(p.unqueuedBufs) < 2 {
|
||||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueuePause failed: %d", osstatus))
|
if osstatus := C.AudioQueuePause(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
||||||
return
|
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueuePause failed: %d", osstatus))
|
||||||
}
|
return
|
||||||
// AudioQueueReset invokes the callback directry.
|
}
|
||||||
q := p.audioQueue
|
// AudioQueueReset invokes the callback directry.
|
||||||
p.cond.L.Unlock()
|
q := p.audioQueue
|
||||||
osstatus := C.AudioQueueReset(q)
|
p.cond.L.Unlock()
|
||||||
p.cond.L.Lock()
|
osstatus := C.AudioQueueReset(q)
|
||||||
if osstatus != C.noErr && p.err == nil {
|
p.cond.L.Lock()
|
||||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueReset failed: %d", osstatus))
|
if osstatus != C.noErr && p.err == nil {
|
||||||
return
|
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueReset failed: %d", osstatus))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p.state = playerPaused
|
p.state = playerPaused
|
||||||
|
Loading…
Reference in New Issue
Block a user