Bug 1364866 - Part 0 - Cleanups. r?esawin
MozReview-Commit-ID: 7mLH5W9gBp2
--- a/dom/media/MP3Demuxer.cpp
+++ b/dom/media/MP3Demuxer.cpp
@@ -415,18 +415,20 @@ MP3TrackDemuxer::Duration(int64_t aNumFr
const double usPerFrame = USECS_PER_S * mSamplesPerFrame / mSamplesPerSecond;
return TimeUnit::FromMicroseconds(aNumFrames * usPerFrame);
}
MediaByteRange
MP3TrackDemuxer::FindFirstFrame()
{
- // Get engough successive frames to avoid invalid frame from cut stream.
- // However, some website use very short mp3 file so using the same value as Chrome.
+ // We attempt to find multiple successive frames to avoid locking onto a false
+ // positive if we're fed a stream that has been cut mid-frame.
+ // For compatibility reasons we have to use the same frame count as Chrome, since
+ // some web sites actually use a file that short to test our playback capabilities.
static const int MIN_SUCCESSIVE_FRAMES = 3;
MediaByteRange candidateFrame = FindNextFrame();
int numSuccFrames = candidateFrame.Length() > 0;
MediaByteRange currentFrame = candidateFrame;
MP3LOGV("FindFirst() first candidate frame: mOffset=%" PRIu64
" Length()=%" PRIu64,
candidateFrame.mStart, candidateFrame.Length());
@@ -457,17 +459,17 @@ MP3TrackDemuxer::FindFirstFrame()
MP3LOGV("FindFirst() new candidate frame: mOffset=%" PRIu64
" Length()=%" PRIu64,
candidateFrame.mStart, candidateFrame.Length());
}
}
if (numSuccFrames >= MIN_SUCCESSIVE_FRAMES) {
MP3LOG("FindFirst() accepting candidate frame: "
- "successiveFrames=%d", numSuccFrames);
+ "successiveFrames=%d", numSuccFrames);
} else {
MP3LOG("FindFirst() no suitable first frame found");
}
return candidateFrame;
}
static bool
VerifyFrameConsistency(const FrameParser::Frame& aFrame1,