mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
audio/mp3: Channels should be used only once
This commit is contained in:
parent
e14257d76d
commit
2155b2f04a
@ -176,12 +176,13 @@ func decode(context *audio.Context, buf []byte) (*Stream, error) {
|
||||
switch n := buf.Get("numberOfChannels").Int(); n {
|
||||
case 1:
|
||||
s.rightData = s.leftData
|
||||
close(ch)
|
||||
case 2:
|
||||
s.rightData = buf.Call("getChannelData", 1).Interface().([]float32)
|
||||
close(ch)
|
||||
default:
|
||||
ch <- fmt.Errorf("audio/mp3: number of channels must be 1 or 2 but %d", n)
|
||||
}
|
||||
close(ch)
|
||||
}, func(err *js.Object) {
|
||||
if err != nil {
|
||||
ch <- fmt.Errorf("audio/mp3: decodeAudioData failed: %v", err)
|
||||
@ -190,7 +191,6 @@ func decode(context *audio.Context, buf []byte) (*Stream, error) {
|
||||
// from the next frame (#438).
|
||||
ch <- errTryAgain
|
||||
}
|
||||
close(ch)
|
||||
})
|
||||
|
||||
// GopherJS's bug? Without Gosched(), receiving might block forever.
|
||||
|
Loading…
Reference in New Issue
Block a user