Add some supplementary comments.

This commit is contained in:
Tsuda Kageyu 2015-12-22 17:06:40 +09:00
parent 12da0ebd6d
commit 22708a0af6
2 changed files with 9 additions and 1 deletions

View File

@ -205,6 +205,11 @@ void MPEG::Properties::read(File *file)
d->bitrate = firstHeader.bitrate();
// Look for the last MPEG audio frame to calculate the stream length.
// This actually finds the second last valid frame, since MPEG::Header requires
// the next frame header to check if the frame length is calculated correctly.
long lastFrameOffset = file->lastFrameOffset();
if(lastFrameOffset < 0) {
debug("MPEG::Properties::read() -- Could not find an MPEG frame in the stream.");

View File

@ -93,10 +93,13 @@ public:
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT(!f.audioProperties()->xingHeader());
// This actually finds the second last valid frame, since MPEG::Header requires
// the next frame header to check if the frame length is calculated correctly.
long last = f.lastFrameOffset();
MPEG::Header lastHeader(&f, last);
while (!lastHeader.isValid()) {
while(!lastHeader.isValid()) {
last = f.previousFrameOffset(last);
lastHeader = MPEG::Header(&f, last);
}