mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
audio/mp3: Handle error when decoding
This commit is contained in:
parent
fe2380f1ab
commit
1f051b50db
@ -119,9 +119,12 @@ func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
|||||||
case 2:
|
case 2:
|
||||||
s.rightData = buf.Call("getChannelData", 1).Interface().([]float32)
|
s.rightData = buf.Call("getChannelData", 1).Interface().([]float32)
|
||||||
default:
|
default:
|
||||||
ch <- fmt.Errorf("audio/mp3: Number of channels must be 1 or 2 but %d", n)
|
ch <- fmt.Errorf("audio/mp3: number of channels must be 1 or 2 but %d", n)
|
||||||
}
|
}
|
||||||
close(ch)
|
close(ch)
|
||||||
|
}, func(err *js.Object) {
|
||||||
|
ch <- fmt.Errorf("audio/mp3: decoding failed: %s", err.String())
|
||||||
|
close(ch)
|
||||||
})
|
})
|
||||||
if err := <-ch; err != nil {
|
if err := <-ch; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user