faiface / beep

A little package that brings sound to any Go application. Suitable for playback and audio-processing.
MIT License
2.08k stars 151 forks source link

panic: runtime error: index out of range #81

Open jiazhiguy opened 4 years ago

jiazhiguy commented 4 years ago
    resp, err := http.Get(path)
    if err != nil {
        return err
    }
    f =resp.Body
           defer f.Close()
    streamer, format, err := mp3.Decode(f)
    if err != nil {
        log.Println(err)
        return
    }

when the connect end of playing

panic: runtime error: index out of range goroutine 114 [running]: github.com/hajimehoshi/go-mp3.(Decoder).Seek(0xc0000463c0, 0x0, 0x0, 0xc0000041c0, 0xc0001b20a0, 0xbf92202440488091) D:/workbench/go/src/github.com/hajimehoshi/go-mp3/decode.go:103 +0x3b7 github.com/faiface/beep/mp3.(decoder).Seek(0xc0001b2000, 0x0, 0x180, 0x180) D:/workbench/go/src/github.com/faiface/beep/mp3/decode.go:90 +0x1d1 github.com/faiface/beep.(loop).Stream(0xc000004380, 0xc000460000, 0x180, 0x180, 0xbfd0fc21f843f088, 0x3556301) D:/workbench/go/src/github.com/faiface/beep/compositors.go:63 +0x12d github.com/faiface/beep.(Resampler).Stream(0xc0001d8080, 0xc000268000, 0x17e, 0x17e, 0x200, 0x3556301) D:/workbench/go/src/github.com/faiface/beep/resample.go:103 +0x148 github.com/faiface/beep.(Ctrl).Stream(0xc0000043c0, 0xc000268000, 0x200, 0x200, 0x200, 0x936401) D:/workbench/go/src/github.com/faiface/beep/ctrl.go:43 +0xa7 github.com/faiface/beep/effects.(Volume).Stream(0xc0001882d0, 0xc000268000, 0x200, 0x200, 0x200, 0xc000040e01) D:/workbench/go/src/github.com/faiface/beep/effects/volume.go:31 +0x5c github.com/faiface/beep.Seq.func1(0xc000268000, 0x200, 0x200, 0x200, 0xc000268001) D:/workbench/go/src/github.com/faiface/beep/compositors.go:86 +0xcd github.com/faiface/beep.StreamerFunc.Stream(0xc0001883c0, 0xc000268000, 0x200, 0x200, 0x200, 0x49ac01) D:/workbench/go/src/github.com/faiface/beep/interface.go:100 +0x4b github.com/faiface/beep.(*Mixer).Stream(0xcfc5b0, 0xc000420000, 0x113a, 0xf3a, 0x0, 0x0) D:/workbench/go/src/github.com/faiface/beep/mixer.go:42 +0x193 github.com/faiface/beep/speaker.update() D:/workbench/go/src/github.com/faiface/beep/speaker/speaker.go:109 +0x6c github.com/faiface/beep/speaker.Init.func1() D:/workbench/go/src/github.com/faiface/beep/speaker/speaker.go:52 +0x2b created by github.com/faiface/beep/speaker.Init D:/workbench/go/src/github.com/faiface/beep/speaker/speaker.go:48 +0x1e2 exit status 2

youshy commented 4 years ago

Forgot about

defer streamer.Close()

Also, is that the full code?

skuzzymiglet commented 4 years ago

Hey @jiazhiguy, I got this panic when I did a ResampleRatio with an infinite (division by zero). Is this what happened?