From 2155b2f04a1f418e423442dbb3ba5f33130571a9 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 24 Dec 2017 04:40:20 +0900 Subject: [PATCH] audio/mp3: Channels should be used only once --- audio/mp3/decode_js.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/mp3/decode_js.go b/audio/mp3/decode_js.go index ec5b1ffdf..29610a86d 100644 --- a/audio/mp3/decode_js.go +++ b/audio/mp3/decode_js.go @@ -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.