From 875039446c7828b1a6090b535f8ecb6f7dad3cf0 Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Mon, 8 Sep 2014 16:55:20 +1200 Subject: [PATCH] Bug 1062664 - Don't update MediaSourceReader::mLast{Audio,Video}Time when seeking. r=cajbir Any On{Audio,Video}Decoded callbacks triggered before we request a new sample from a reader after seeking should not be used to compute the last sample time because they originate from the reader we're switching away from and cause us to switch back to it after seeking. --- .../media/mediasource/MediaSourceReader.cpp | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/content/media/mediasource/MediaSourceReader.cpp b/content/media/mediasource/MediaSourceReader.cpp index b91f4c89d4b..ae0be7c6502 100644 --- a/content/media/mediasource/MediaSourceReader.cpp +++ b/content/media/mediasource/MediaSourceReader.cpp @@ -84,6 +84,7 @@ MediaSourceReader::RequestAudioData() GetCallback()->OnDecodeError(); return; } + mAudioIsSeeking = false; SwitchAudioReader(double(mLastAudioTime) / USECS_PER_S); mAudioReader->RequestAudioData(); } @@ -104,14 +105,12 @@ MediaSourceReader::OnAudioDecoded(AudioData* aSample) mDropAudioBeforeThreshold = false; } - // If we are seeking we need to make sure the first sample decoded after - // that seek has the mDiscontinuity field set to ensure the media decoder - // state machine picks up that the seek is complete. - if (mAudioIsSeeking) { - mAudioIsSeeking = false; - aSample->mDiscontinuity = true; + // Any OnAudioDecoded callbacks received while mAudioIsSeeking must be not + // update our last used timestamp, as these are emitted by the reader we're + // switching away from. + if (!mAudioIsSeeking) { + mLastAudioTime = aSample->mTime + aSample->mDuration; } - mLastAudioTime = aSample->mTime + aSample->mDuration; GetCallback()->OnAudioDecoded(aSample); } @@ -146,6 +145,7 @@ MediaSourceReader::RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThres mDropAudioBeforeThreshold = true; mDropVideoBeforeThreshold = true; } + mVideoIsSeeking = false; SwitchVideoReader(double(mLastVideoTime) / USECS_PER_S); mVideoReader->RequestVideoData(aSkipToNextKeyframe, aTimeThreshold); } @@ -166,14 +166,12 @@ MediaSourceReader::OnVideoDecoded(VideoData* aSample) mDropVideoBeforeThreshold = false; } - // If we are seeking we need to make sure the first sample decoded after - // that seek has the mDiscontinuity field set to ensure the media decoder - // state machine picks up that the seek is complete. - if (mVideoIsSeeking) { - mVideoIsSeeking = false; - aSample->mDiscontinuity = true; + // Any OnVideoDecoded callbacks received while mVideoIsSeeking must be not + // update our last used timestamp, as these are emitted by the reader we're + // switching away from. + if (!mVideoIsSeeking) { + mLastVideoTime = aSample->mTime + aSample->mDuration; } - mLastVideoTime = aSample->mTime + aSample->mDuration; GetCallback()->OnVideoDecoded(aSample); }