mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 20:42:07 +01:00
audio/internal/readerdriver: Refactoring
This commit is contained in:
parent
22567d20b6
commit
7eeaef7ff8
@ -96,7 +96,6 @@ type playerImpl struct {
|
||||
err error
|
||||
eof bool
|
||||
cond *sync.Cond
|
||||
started bool
|
||||
volume float64
|
||||
}
|
||||
|
||||
@ -303,7 +302,6 @@ func (p *playerImpl) Play() {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueStart failed: %d", osstatus))
|
||||
return
|
||||
}
|
||||
p.started = true
|
||||
p.state = playerPlay
|
||||
p.cond.Signal()
|
||||
|
||||
@ -323,6 +321,10 @@ func (p *playerImpl) Pause() {
|
||||
if p.state != playerPlay {
|
||||
return
|
||||
}
|
||||
if p.audioQueue == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if osstatus := C.AudioQueuePause(p.audioQueue); osstatus != C.noErr && p.err == nil {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueuePause failed: %d", osstatus))
|
||||
return
|
||||
@ -342,8 +344,10 @@ func (p *playerImpl) Reset() {
|
||||
if p.state == playerClosed {
|
||||
return
|
||||
}
|
||||
if p.audioQueue == nil {
|
||||
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
|
||||
@ -360,7 +364,6 @@ func (p *playerImpl) Reset() {
|
||||
p.setErrorImpl(fmt.Errorf("readerdriver: AudioQueueFlush failed: %d", osstatus))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
p.state = playerPaused
|
||||
p.buf = p.buf[:0]
|
||||
|
Loading…
Reference in New Issue
Block a user