audio/mp3: Refactoring

This commit is contained in:
Hajime Hoshi 2017-06-26 02:03:23 +09:00
parent 9130c490c2
commit 3be2b2516f

View File

@ -58,8 +58,9 @@ func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
var s audio.ReadSeekCloser = d
size := d.Length()
if d.SampleRate() != context.SampleRate() {
s = convert.NewResampling(s, d.Length(), d.SampleRate(), context.SampleRate())
size = size * int64(context.SampleRate()) / int64(d.SampleRate())
r := convert.NewResampling(s, d.Length(), d.SampleRate(), context.SampleRate())
s = r
size = r.Size()
}
return &Stream{
inner: s,