Bug 1190558 - Reset MP3 frame parser on track demuxer reset. r=kinetik

This commit is contained in:
Eugen Sawin 2015-07-31 22:45:10 +02:00
parent da17ea5369
commit a67895de46
2 changed files with 9 additions and 6 deletions

View File

@ -164,7 +164,7 @@ MP3TrackDemuxer::FastSeek(TimeUnit aTime) {
// Quick seek to the beginning of the stream.
mOffset = mFirstFrameOffset;
mFrameIndex = 0;
mParser.FinishParsing();
mParser.EndFrameSession();
return TimeUnit();
}
@ -176,7 +176,8 @@ MP3TrackDemuxer::FastSeek(TimeUnit aTime) {
mSamplesPerSecond / mSamplesPerFrame;
mOffset = mFirstFrameOffset + numFrames * AverageFrameLength();
mFrameIndex = numFrames;
mParser.FinishParsing();
mParser.EndFrameSession();
return Duration(mFrameIndex);
}
@ -234,6 +235,8 @@ MP3TrackDemuxer::Reset() {
mSamplesPerFrame = 0;
mSamplesPerSecond = 0;
mChannels = 0;
mParser.Reset();
}
nsRefPtr<MP3TrackDemuxer::SkipAccessPointPromise>
@ -392,7 +395,7 @@ MP3TrackDemuxer::UpdateState(const MediaByteRange& aRange) {
MOZ_ASSERT(mFrameIndex > 0);
// Prepare the parser for the next frame parsing session.
mParser.FinishParsing();
mParser.EndFrameSession();
}
int32_t
@ -440,7 +443,7 @@ FrameParser::Reset() {
}
void
FrameParser::FinishParsing() {
FrameParser::EndFrameSession() {
if (!mID3Parser.Header().IsValid()) {
// Reset ID3 tags only if we have not parsed a valid ID3 header yet.
mID3Parser.Reset();

View File

@ -256,7 +256,7 @@ public:
// Constructor.
FrameParser();
// Returns the currently parsed frame. Reset via Reset or FinishParsing.
// Returns the currently parsed frame. Reset via Reset or EndFrameSession.
const Frame& CurrentFrame() const;
#ifdef ENABLE_TESTS
@ -280,7 +280,7 @@ public:
// - sets PrevFrame to CurrentFrame
// - resets the CurrentFrame
// - resets ID3Header if no valid header was parsed yet
void FinishParsing();
void EndFrameSession();
// Parses given buffer [aBeg, aEnd) for a valid frame header.
// Returns begin of frame header if a frame header was found or aEnd otherwise.