From 1f051b50db1742dcaccfa9c4c0be10ae8288c636 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 28 Sep 2017 00:55:18 +0900 Subject: [PATCH] audio/mp3: Handle error when decoding --- audio/mp3/decode_js.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/audio/mp3/decode_js.go b/audio/mp3/decode_js.go index 16d0cb4c5..6da1fdcd5 100644 --- a/audio/mp3/decode_js.go +++ b/audio/mp3/decode_js.go @@ -119,9 +119,12 @@ func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) { case 2: s.rightData = buf.Call("getChannelData", 1).Interface().([]float32) 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) + }, func(err *js.Object) { + ch <- fmt.Errorf("audio/mp3: decoding failed: %s", err.String()) + close(ch) }) if err := <-ch; err != nil { return nil, err