]> granicus.if.org Git - taglib/commitdiff
Add some supplementary comments.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 22 Dec 2015 08:06:40 +0000 (17:06 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 22 Dec 2015 08:06:40 +0000 (17:06 +0900)
taglib/mpeg/mpegproperties.cpp
tests/test_mpeg.cpp

index 8507f38d6e899f1e2cb69bf66f68786b7051a214..b9ae8675e6ce18f8c3dd14f815781a4143231d20 100644 (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.");
index 9b972382daf904e7df07d0309e1c4022cf8a74ab..455fde2ce8f419a3c0c6b8ecd72535aed228db74 100644 (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);
     }