Closed Hundemeier closed 6 years ago
The Seeker implementation of the mp3 decoder is not fully correct. The Position() method returns incorrect values after seeking.
f, err := os.Open("./test.mp3") if err != nil { log.Fatal(err) } s, format, err := mp3.Decode(f) if err != nil { log.Fatal(err) } speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10)) speaker.Play(s) fmt.Println("Position:", s.Position()) time.Sleep(3 * time.Second) s.Seek(0) fmt.Println("Position:", s.Position()) select {}
The above example works fine with the wav-decoder.
Expected output:
Position: 0 Position: 0
Real output (with my mp3 testfile):
Position: 0 Position: 145530
A quick fix would be to add the following line to
mp3/decode.go -> Seek()
d.pos = int64(p)*gomp3BytesPerFrame
But I do not know if this has sideffects with the go-mp3 library.
Yes, you're very much right! The fix you proposed is correct. Do you want to submit a PR for the fix?
Fixed by #40
The Seeker implementation of the mp3 decoder is not fully correct. The Position() method returns incorrect values after seeking.
The above example works fine with the wav-decoder.
Expected output:
Real output (with my mp3 testfile):
A quick fix would be to add the following line to
d.pos = int64(p)*gomp3BytesPerFrame
But I do not know if this has sideffects with the go-mp3 library.