audio: Bug fix: Adjust data size after resampling

This commit is contained in:
Hajime Hoshi 2017-01-16 11:25:46 +09:00
parent bb435b7296
commit 2439d407df
2 changed files with 2 additions and 0 deletions

View File

@ -191,6 +191,7 @@ func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
}
if sampleRate != context.SampleRate() {
s = convert.NewResampling(s, size, sampleRate, context.SampleRate())
size = size * int64(context.SampleRate()) / int64(sampleRate)
}
return &Stream{s, size}, nil
}

View File

@ -213,6 +213,7 @@ chunks:
}
if sampleRateFrom != sampleRateTo {
s = convert.NewResampling(s, dataSize, sampleRateFrom, sampleRateTo)
dataSize = dataSize * int64(sampleRateTo) / int64(sampleRateFrom)
}
return &Stream{s, dataSize}, nil
}