mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
audio/internal/readerdriver: Refactoring
This commit is contained in:
parent
49172a235b
commit
5f773a3277
10
audio/internal/oboe/binding_android.go
vendored
10
audio/internal/oboe/binding_android.go
vendored
@ -76,6 +76,9 @@ func (p *Player) AppendBuffer(buf []byte) {
|
||||
}
|
||||
|
||||
func (p *Player) Play() error {
|
||||
if p.player == 0 {
|
||||
return fmt.Errorf("oboe: player is already closed at Play")
|
||||
}
|
||||
if msg := C.Player_Play(p.player); msg != nil {
|
||||
return fmt.Errorf("oboe: Player_Play failed: %s", C.GoString(msg))
|
||||
}
|
||||
@ -83,6 +86,9 @@ func (p *Player) Play() error {
|
||||
}
|
||||
|
||||
func (p *Player) Pause() error {
|
||||
if p.player == 0 {
|
||||
return fmt.Errorf("oboe: player is already closed at Pause")
|
||||
}
|
||||
if msg := C.Player_Pause(p.player); msg != nil {
|
||||
return fmt.Errorf("oboe: Player_Pause failed: %s", C.GoString(msg))
|
||||
}
|
||||
@ -95,9 +101,13 @@ func (p *Player) SetVolume(volume float64) {
|
||||
|
||||
func (p *Player) Close() error {
|
||||
runtime.SetFinalizer(p, nil)
|
||||
if p.player == 0 {
|
||||
return fmt.Errorf("oboe: player is already closed at Close")
|
||||
}
|
||||
if msg := C.Player_Close(p.player); msg != nil {
|
||||
return fmt.Errorf("oboe: Player_Close failed: %s", C.GoString(msg))
|
||||
}
|
||||
p.player = 0
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -157,14 +157,12 @@ func (p *player) Reset() {
|
||||
if p.p == nil {
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
p.p = nil
|
||||
p.cond.Signal()
|
||||
}()
|
||||
if err := p.p.Close(); err != nil {
|
||||
p.setErrorImpl(err)
|
||||
return
|
||||
}
|
||||
p.p = nil
|
||||
p.cond.Signal()
|
||||
}
|
||||
|
||||
func (p *player) Volume() float64 {
|
||||
|
Loading…
Reference in New Issue
Block a user