mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/internal/readerdriver: Bug fix: AudioQueue{Pause,Reset,Flush} cannot be called before AudioQueueStart
This commit is contained in:
parent
bc22ab53b2
commit
9df1092507
@ -96,6 +96,7 @@ type playerImpl struct {
|
||||
err error
|
||||
eof bool
|
||||
cond *sync.Cond
|
||||
started bool
|
||||
}
|
||||
|
||||
type players struct {
|
||||
@ -297,6 +298,7 @@ func (p *playerImpl) Play() {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueStart failed: %d", osstatus))
|
||||
return
|
||||
}
|
||||
p.started = true
|
||||
p.state = playerPlay
|
||||
p.cond.Signal()
|
||||
|
||||
@ -335,21 +337,24 @@ func (p *playerImpl) Reset() {
|
||||
if p.state == playerClosed {
|
||||
return
|
||||
}
|
||||
// TODO: Pausing and resetting seems not immediately?
|
||||
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.
|
||||
p.cond.L.Unlock()
|
||||
if osstatus := C.AudioQueueReset(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueReset failed: %d", osstatus))
|
||||
return
|
||||
}
|
||||
p.cond.L.Lock()
|
||||
if osstatus := C.AudioQueueFlush(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueFlush failed: %d", osstatus))
|
||||
return
|
||||
|
||||
if p.started {
|
||||
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.
|
||||
p.cond.L.Unlock()
|
||||
if osstatus := C.AudioQueueReset(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueReset failed: %d", osstatus))
|
||||
p.cond.L.Lock()
|
||||
return
|
||||
}
|
||||
p.cond.L.Lock()
|
||||
if osstatus := C.AudioQueueFlush(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueFlush failed: %d", osstatus))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
p.state = playerPaused
|
||||
|
Loading…
Reference in New Issue
Block a user