mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-14 13:02:08 +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
|
err error
|
||||||
eof bool
|
eof bool
|
||||||
cond *sync.Cond
|
cond *sync.Cond
|
||||||
|
started bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type players struct {
|
type players struct {
|
||||||
@ -297,6 +298,7 @@ func (p *playerImpl) Play() {
|
|||||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueStart failed: %d", osstatus))
|
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueStart failed: %d", osstatus))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
p.started = true
|
||||||
p.state = playerPlay
|
p.state = playerPlay
|
||||||
p.cond.Signal()
|
p.cond.Signal()
|
||||||
|
|
||||||
@ -335,7 +337,8 @@ func (p *playerImpl) Reset() {
|
|||||||
if p.state == playerClosed {
|
if p.state == playerClosed {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// TODO: Pausing and resetting seems not immediately?
|
|
||||||
|
if p.started {
|
||||||
if osstatus := C.AudioQueuePause(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
if osstatus := C.AudioQueuePause(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
||||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueuePause failed: %d", osstatus))
|
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueuePause failed: %d", osstatus))
|
||||||
return
|
return
|
||||||
@ -344,6 +347,7 @@ func (p *playerImpl) Reset() {
|
|||||||
p.cond.L.Unlock()
|
p.cond.L.Unlock()
|
||||||
if osstatus := C.AudioQueueReset(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
if osstatus := C.AudioQueueReset(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
||||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueReset failed: %d", osstatus))
|
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueReset failed: %d", osstatus))
|
||||||
|
p.cond.L.Lock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.cond.L.Lock()
|
p.cond.L.Lock()
|
||||||
@ -351,6 +355,7 @@ func (p *playerImpl) Reset() {
|
|||||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueFlush failed: %d", osstatus))
|
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueFlush failed: %d", osstatus))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p.state = playerPaused
|
p.state = playerPaused
|
||||||
p.buf = p.buf[:0]
|
p.buf = p.buf[:0]
|
||||||
|
Loading…
Reference in New Issue
Block a user