Bug 1008012 - |mBasePosition| should be updated after seeking otherwise GetVideoStreamPosition will get the wrong value. r=cpearce
authorJW Wang <jwwang@mozilla.com>
Wed, 21 May 2014 00:41:00 +0200
changeset 203824 57b906c6096428bf57f368c25b0cd8efb02f4b79
parent 203823 cb41521cda402abba838f62104d052d05476442c
child 203825 cb3b68267af4cca0ad4996f5c6fa4a46d125183c
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1008012
milestone32.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 1008012 - |mBasePosition| should be updated after seeking otherwise GetVideoStreamPosition will get the wrong value. r=cpearce
content/media/MediaDecoderStateMachine.cpp
--- a/content/media/MediaDecoderStateMachine.cpp
+++ b/content/media/MediaDecoderStateMachine.cpp
@@ -1435,17 +1435,16 @@ void MediaDecoderStateMachine::Seek(cons
   NS_ASSERTION(mEndTime != -1, "Should know end time by now");
   int64_t seekTime = aTarget.mTime + mStartTime;
   seekTime = std::min(seekTime, mEndTime);
   seekTime = std::max(mStartTime, seekTime);
   NS_ASSERTION(seekTime >= mStartTime && seekTime <= mEndTime,
                "Can only seek in range [0,duration]");
   mSeekTarget = SeekTarget(seekTime, aTarget.mType);
 
-  mBasePosition = seekTime - mStartTime;
   DECODER_LOG(PR_LOG_DEBUG, "Changed state to SEEKING (to %lld)", mSeekTarget.mTime);
   mState = DECODER_STATE_SEEKING;
   if (mDecoder->GetDecodedStream()) {
     mDecoder->RecreateDecodedStream(seekTime - mStartTime);
   }
   ScheduleStateMachine();
 }
 
@@ -1915,16 +1914,22 @@ void MediaDecoderStateMachine::DecodeSee
     currentTimeChanged = true;
     // Stop playback now to ensure that while we're outside the monitor
     // dispatching SeekingStarted, playback doesn't advance and mess with
     // mCurrentFrameTime that we've setting to seekTime here.
     StopPlayback();
     UpdatePlaybackPositionInternal(seekTime);
   }
 
+  // Update mBasePosition only after StopPlayback() which will call GetClock()
+  // which will call GetVideoStreamPosition() which will read mBasePosition.
+  // If we update mBasePosition too early in Seek(), |pos -= mBasePosition|
+  // will be wrong and assertion will fail in GetVideoStreamPosition().
+  mBasePosition = seekTime - mStartTime;
+
   // SeekingStarted will do a UpdateReadyStateForData which will
   // inform the element and its users that we have no frames
   // to display
   {
     ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
     nsCOMPtr<nsIRunnable> startEvent =
       NS_NewRunnableMethod(mDecoder, &MediaDecoder::SeekingStarted);
     NS_DispatchToMainThread(startEvent, NS_DISPATCH_SYNC);