Bug 1203217 - Add some logging when we detect and skip an ID3v2 tag. r=kinetik
authorJan Henning <jh+bugzilla@buttercookie.de>
Sun, 13 Sep 2015 14:33:49 +0200
changeset 295369 dab5c069d6d3428445d448b597aac238600cfc6d
parent 295368 57ab7de3b301bb05df51b94b8d453df45a2026f1
child 295370 bcfee08450fc95eceb46f2fbf60bec97d4c08b50
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1203217
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1203217 - Add some logging when we detect and skip an ID3v2 tag. r=kinetik This also cleans up the indentation for some of the already existing logging.
dom/media/MP3Demuxer.cpp
--- a/dom/media/MP3Demuxer.cpp
+++ b/dom/media/MP3Demuxer.cpp
@@ -232,38 +232,36 @@ MP3TrackDemuxer::ScanUntil(TimeUnit aTim
   if (Duration(mFrameIndex) > aTime) {
     FastSeek(aTime);
   }
 
   MediaByteRange nextRange = FindNextFrame();
   while (SkipNextFrame(nextRange) && Duration(mFrameIndex + 1) < aTime) {
     nextRange = FindNextFrame();
     MP3DEMUXER_LOGV("ScanUntil* avgFrameLen=%f mNumParsedFrames=%" PRIu64
-                " mFrameIndex=%" PRId64 " mOffset=%" PRIu64 " Duration=%" PRId64,
-                aTime, AverageFrameLength(), mNumParsedFrames, mFrameIndex,
-                mOffset, Duration(mFrameIndex + 1));
+                    " mFrameIndex=%" PRId64 " mOffset=%" PRIu64 " Duration=%" PRId64,
+                    aTime, AverageFrameLength(), mNumParsedFrames, mFrameIndex,
+                    mOffset, Duration(mFrameIndex + 1));
   }
 
   MP3DEMUXER_LOG("ScanUntil End avgFrameLen=%f mNumParsedFrames=%" PRIu64
-              " mFrameIndex=%" PRId64 " mOffset=%" PRIu64,
-              aTime, AverageFrameLength(), mNumParsedFrames, mFrameIndex,
-              mOffset);
+                 " mFrameIndex=%" PRId64 " mOffset=%" PRIu64,
+                 aTime, AverageFrameLength(), mNumParsedFrames, mFrameIndex,
+                 mOffset);
 
   return Duration(mFrameIndex);
 }
 
 nsRefPtr<MP3TrackDemuxer::SamplesPromise>
 MP3TrackDemuxer::GetSamples(int32_t aNumSamples) {
   MP3DEMUXER_LOGV("GetSamples(%d) Begin mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
-              " mFrameIndex=%" PRId64
-              " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d "
-              "mChannels=%d",
-              aNumSamples,
-              mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen, mSamplesPerFrame,
-              mSamplesPerSecond, mChannels);
+                  " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d "
+                  "mSamplesPerSecond=%d mChannels=%d",
+                  aNumSamples, mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen,
+                  mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   if (!aNumSamples) {
     return SamplesPromise::CreateAndReject(
         DemuxerFailureReason::DEMUXER_ERROR, __func__);
   }
 
   nsRefPtr<SamplesHolder> frames = new SamplesHolder();
 
@@ -272,23 +270,21 @@ MP3TrackDemuxer::GetSamples(int32_t aNum
     if (!frame) {
       break;
     }
 
     frames->mSamples.AppendElement(frame);
   }
 
   MP3DEMUXER_LOGV("GetSamples() End mSamples.Size()=%d aNumSamples=%d mOffset=%" PRIu64
-              " mNumParsedFrames=%" PRIu64
-              " mFrameIndex=%" PRId64
-              " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d "
-              "mChannels=%d",
-              frames->mSamples.Length(), aNumSamples,
-              mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen, mSamplesPerFrame,
-              mSamplesPerSecond, mChannels);
+                  " mNumParsedFrames=%" PRIu64 " mFrameIndex=%" PRId64
+                  " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d "
+                  "mChannels=%d",
+                  frames->mSamples.Length(), aNumSamples, mOffset, mNumParsedFrames,
+                  mFrameIndex, mTotalFrameLen, mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   if (frames->mSamples.IsEmpty()) {
     return SamplesPromise::CreateAndReject(
         DemuxerFailureReason::END_OF_STREAM, __func__);
   }
   return SamplesPromise::CreateAndResolve(frames, __func__);
 }
 
@@ -363,21 +359,20 @@ MP3TrackDemuxer::Duration(int64_t aNumFr
 }
 
 MediaByteRange
 MP3TrackDemuxer::FindNextFrame() {
   static const int BUFFER_SIZE = 4096;
   static const int MAX_SKIPPED_BYTES = 10 * BUFFER_SIZE;
 
   MP3DEMUXER_LOGV("FindNext() Begin mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
-              " mFrameIndex=%" PRId64
-              " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d "
-              "mChannels=%d",
-              mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen, mSamplesPerFrame,
-              mSamplesPerSecond, mChannels);
+                  " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64
+                  " mSamplesPerFrame=%d mSamplesPerSecond=%d mChannels=%d",
+                  mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen, mSamplesPerFrame,
+                  mSamplesPerSecond, mChannels);
 
   uint8_t buffer[BUFFER_SIZE];
   int32_t read = 0;
   const uint8_t* frameBeg = nullptr;
   const uint8_t* bufferEnd = nullptr;
 
   while (frameBeg == bufferEnd) {
     if ((!mParser.FirstFrame().Length() &&
@@ -395,49 +390,48 @@ MP3TrackDemuxer::FindNextFrame() {
     // If mBytesToSkip is > 0, this skips the rest of an ID3 tag which stretches
     // beyond the current buffer.
     NS_ENSURE_TRUE(mOffset + parseResults.mBytesToSkip >= mOffset, MediaByteRange(0, 0));
     mOffset += parseResults.mBytesToSkip;
   }
 
   if (frameBeg == bufferEnd || !mParser.CurrentFrame().Length()) {
     MP3DEMUXER_LOG("FindNext() Exit frameBeg=%p bufferEnd=%p "
-                "mParser.CurrentFrame().Length()=%d ",
-                frameBeg, bufferEnd, mParser.CurrentFrame().Length());
+                   "mParser.CurrentFrame().Length()=%d ",
+                   frameBeg, bufferEnd, mParser.CurrentFrame().Length());
     return { 0, 0 };
   }
 
   MP3DEMUXER_LOGV("FindNext() End mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
-              " mFrameIndex=%" PRId64 " bufferEnd=%p frameBeg=%p"
-              " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d "
-              "mChannels=%d",
-              mOffset, mNumParsedFrames, mFrameIndex, bufferEnd, frameBeg,
-              mTotalFrameLen, mSamplesPerFrame,
-              mSamplesPerSecond, mChannels);
+                  " mFrameIndex=%" PRId64 " bufferEnd=%p frameBeg=%p"
+                  " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d "
+                  "mChannels=%d",
+                  mOffset, mNumParsedFrames, mFrameIndex, bufferEnd, frameBeg,
+                  mTotalFrameLen, mSamplesPerFrame,
+                  mSamplesPerSecond, mChannels);
 
   const int64_t nextBeg = mOffset - (bufferEnd - frameBeg) + 1;
   return { nextBeg, nextBeg + mParser.CurrentFrame().Length() };
 }
 
 bool
 MP3TrackDemuxer::SkipNextFrame(const MediaByteRange& aRange) {
   if (!mNumParsedFrames || !aRange.Length()) {
     // We can't skip the first frame, since it could contain VBR headers.
     nsRefPtr<MediaRawData> frame(GetNextFrame(aRange));
     return frame;
   }
 
   UpdateState(aRange);
 
   MP3DEMUXER_LOGV("SkipNext() End mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
-              " mFrameIndex=%" PRId64
-              " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d "
-              "mChannels=%d",
-              mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen, mSamplesPerFrame,
-              mSamplesPerSecond, mChannels);
+                  " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64
+                  " mSamplesPerFrame=%d mSamplesPerSecond=%d mChannels=%d",
+                  mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen, mSamplesPerFrame,
+                  mSamplesPerSecond, mChannels);
 
   return true;
 }
 
 already_AddRefed<MediaRawData>
 MP3TrackDemuxer::GetNextFrame(const MediaByteRange& aRange) {
   MP3DEMUXER_LOG("GetNext() Begin({mStart=%" PRId64 " Length()=%" PRId64 "})");
   if (!aRange.Length()) {
@@ -471,21 +465,20 @@ MP3TrackDemuxer::GetNextFrame(const Medi
   if (mNumParsedFrames == 1) {
     // First frame parsed, let's read VBR info if available.
     // TODO: read info that helps with seeking (bug 1163667).
     mParser.ParseVBRHeader(frame->Data(), frame->Data() + frame->Size());
     mFirstFrameOffset = frame->mOffset;
   }
 
   MP3DEMUXER_LOGV("GetNext() End mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
-              " mFrameIndex=%" PRId64
-              " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d "
-              "mChannels=%d",
-              mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen, mSamplesPerFrame,
-              mSamplesPerSecond, mChannels);
+                  " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64
+                  " mSamplesPerFrame=%d mSamplesPerSecond=%d mChannels=%d",
+                  mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen, mSamplesPerFrame,
+                  mSamplesPerSecond, mChannels);
 
   return frame.forget();
 }
 
 void
 MP3TrackDemuxer::UpdateState(const MediaByteRange& aRange) {
   // Prevent overflow.
   if (mTotalFrameLen + aRange.Length() < mTotalFrameLen) {
@@ -610,18 +603,22 @@ FrameParser::Parse(const uint8_t* aBeg, 
     if (id3Beg != aEnd) {
       // ID3 tag found, skip past it.
       const uint32_t tagSize = ID3Parser::ID3Header::SIZE + mID3Parser.Header().Size() +
                                mID3Parser.Header().FooterSize();
       const uint32_t remainingBuffer = aEnd - id3Beg;
       if (tagSize > remainingBuffer) {
         // Skipping across the ID3 tag would take us past the end of the buffer, therefore we
         // return immediately and let the calling function handle skipping the rest of the tag.
+        MP3DEMUXER_LOGV("ID3v2 tag detected, size=%d, "
+                        "needing to skip %d bytes past the current buffer",
+                        tagSize, tagSize - remainingBuffer);
         return { aEnd, tagSize - remainingBuffer };
       }
+      MP3DEMUXER_LOGV("ID3v2 tag detected, size=%d", tagSize);
       aBeg = id3Beg + tagSize;
     }
   }
 
   while (aBeg < aEnd && !mFrame.ParseNext(*aBeg)) {
     ++aBeg;
   }