diff options
Diffstat (limited to 'src/codecs/mad.cpp')
| -rw-r--r-- | src/codecs/mad.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/codecs/mad.cpp b/src/codecs/mad.cpp index 247e33bc..f36636a1 100644 --- a/src/codecs/mad.cpp +++ b/src/codecs/mad.cpp @@ -109,8 +109,9 @@ auto MadMp3Decoder::OpenStream(std::shared_ptr<IStream> input) auto vbr_length = GetVbrLength(header); if (vbr_length) { output.total_samples = vbr_length.value() * channels; - } else { - // FIXME: calculate length using the filesize, assuming CBR. + } else if (input->Size() && header.bitrate > 0) { + auto cbr_length = input->Size().value() / (header.bitrate / 8); + output.total_samples = cbr_length * output.sample_rate_hz * channels; } return output; } |
