Merge pull request #855 from shaforostoff/broken_mp3

fix reading audioproperties for broken mp3 files
This commit is contained in:
Urs Fleisch 2020-12-28 09:05:31 +01:00
commit 4d3ab73d2e

View File

@ -200,13 +200,14 @@ void MPEG::Properties::read(File *file)
const long lastFrameOffset = file->lastFrameOffset();
if(lastFrameOffset < 0) {
debug("MPEG::Properties::read() -- Could not find an MPEG frame in the stream.");
return;
}
const Header lastHeader(file, lastFrameOffset, false);
const long streamLength = lastFrameOffset - firstFrameOffset + lastHeader.frameLength();
if(streamLength > 0)
d->length = static_cast<int>(streamLength * 8.0 / d->bitrate + 0.5);
else
{
const Header lastHeader(file, lastFrameOffset, false);
const long streamLength = lastFrameOffset - firstFrameOffset + lastHeader.frameLength();
if (streamLength > 0)
d->length = static_cast<int>(streamLength * 8.0 / d->bitrate + 0.5);
}
}
d->sampleRate = firstHeader.sampleRate();