From cf6d8435723dae85f7be75046caf7c9132fd328a Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 26 Nov 2016 02:06:15 +0900 Subject: [PATCH] vorbis: Return error when decoding fails --- audio/vorbis/decode_js.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/audio/vorbis/decode_js.go b/audio/vorbis/decode_js.go index 1717ad885..f9002c5a2 100644 --- a/audio/vorbis/decode_js.go +++ b/audio/vorbis/decode_js.go @@ -86,7 +86,7 @@ func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) { return nil, err } s := &Stream{} - ch := make(chan struct{}) + ch := make(chan error) klass := js.Global.Get("OfflineAudioContext") if klass == js.Undefined { @@ -102,7 +102,12 @@ func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) { s.leftData = buf.Call("getChannelData", 0).Interface().([]float32) s.rightData = buf.Call("getChannelData", 1).Interface().([]float32) close(ch) + }, func() { + ch <- errors.New("vorbis: decodeAudioData failed (Safari might not be able to decode Ogg/Vorbis).") + close(ch) }) - <-ch + if err := <-ch; err != nil { + return nil, err + } return s, nil }