Skip to content

Commit

Permalink
audio: add more info for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Sep 10, 2024
1 parent df821f0 commit 26feb26
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion audio/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func newContext(sampleRate int) (context, chan struct{}, error) {
ChannelCount: channelCount,
Format: oto.FormatFloat32LE,
})
err = addErrorInfoForContextCreation(err)
err = addErrorInfo(err)
return &contextProxy{ctx}, ready, err
}

Expand Down
6 changes: 3 additions & 3 deletions audio/error_ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import (
"fmt"
)

// addErrorInfoForContextCreation adds an additional information to the error when creating an audio context.
// See also hajimehoshi/oto#93.
func addErrorInfoForContextCreation(err error) error {
// addErrorInfo adds an additional information to the error when creating an audio context.
// See also ebitengine/oto#93.
func addErrorInfo(err error) error {
if err == nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion audio/error_notios.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

package audio

func addErrorInfoForContextCreation(err error) error {
func addErrorInfo(err error) error {
return err
}
12 changes: 6 additions & 6 deletions audio/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (f *playerFactory) suspend() error {
if f.context == nil {
return nil
}
return f.context.Suspend()
return addErrorInfo(f.context.Suspend())
}

func (f *playerFactory) resume() error {
Expand All @@ -122,7 +122,7 @@ func (f *playerFactory) resume() error {
if f.context == nil {
return nil
}
return f.context.Resume()
return addErrorInfo(f.context.Resume())
}

func (f *playerFactory) error() error {
Expand All @@ -132,7 +132,7 @@ func (f *playerFactory) error() error {
if f.context == nil {
return nil
}
return f.context.Err()
return addErrorInfo(f.context.Err())
}

func (f *playerFactory) initContextIfNeeded() (<-chan struct{}, error) {
Expand Down Expand Up @@ -263,7 +263,7 @@ func (p *playerImpl) Close() error {
}()
p.player.Pause()
p.stopwatch.stop()
return p.player.Close()
return addErrorInfo(p.player.Close())
}
return nil
}
Expand Down Expand Up @@ -293,7 +293,7 @@ func (p *playerImpl) SetPosition(offset time.Duration) error {

pos := p.stream.timeDurationToPos(offset)
if _, err := p.player.Seek(pos, io.SeekStart); err != nil {
return err
return addErrorInfo(err)
}
p.lastSamples = -1
// Just after setting a position, the buffer size should be 0 as no data is sent.
Expand All @@ -312,7 +312,7 @@ func (p *playerImpl) Err() error {
if p.player == nil {
return nil
}
return p.player.Err()
return addErrorInfo(p.player.Err())
}

func (p *playerImpl) SetBufferSize(bufferSize time.Duration) {
Expand Down

0 comments on commit 26feb26

Please sign in to comment.