MPEG: Properties::xingHeader() should return null if a VBR header is not found.

This commit is contained in:
Tsuda Kageyu 2015-05-26 11:54:57 +09:00
parent 9ec6d28239
commit f82be353b4
2 changed files with 6 additions and 4 deletions

View File

@ -178,10 +178,12 @@ void MPEG::Properties::read(File *file)
file->seek(first + 4);
d->xingHeader = new XingHeader(file->readBlock(firstHeader.frameLength() - 4));
if(!d->xingHeader->isValid()) {
delete d->xingHeader;
d->xingHeader = 0;
}
if(d->xingHeader->isValid() &&
firstHeader.samplesPerFrame() > 0 &&
firstHeader.sampleRate() > 0) {
if(d->xingHeader && firstHeader.samplesPerFrame() > 0 && firstHeader.sampleRate() > 0) {
// Read the length and the bitrate from the VBR header.

View File

@ -79,7 +79,7 @@ public:
CPPUNIT_ASSERT_EQUAL(64, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT(!f.audioProperties()->xingHeader()->isValid());
CPPUNIT_ASSERT(!f.audioProperties()->xingHeader());
long last = f.lastFrameOffset();