Bug 1299064. Part 1 - move |SetState(nextState)| and ScheduleStateMachine() to the bottom of SeekCompleted(). draft
authorJW Wang <jwwang@mozilla.com>
Tue, 30 Aug 2016 15:04:43 +0800
changeset 407872 26d89928a634a486b5c968f68f623e4869cd1813
parent 407818 506facea63169a29e04eb140663da1730052db64
child 407873 dc73b6ec26383cc85e5584fd914381c274116c52
push id28067
push userjwwang@mozilla.com
push dateWed, 31 Aug 2016 05:18:30 +0000
bugs1299064
milestone51.0a1
Bug 1299064. Part 1 - move |SetState(nextState)| and ScheduleStateMachine() to the bottom of SeekCompleted(). UpdatePlaybackPositionInternal(), |mQuickBuffering = false| and |mMediaSink->Redraw| should belong to the exit action of SEEKING. By change the order of the statements, we have a better definition/scope for the jobs of each state. MozReview-Commit-ID: 6WESdwaD8Ba
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2176,39 +2176,39 @@ MediaDecoderStateMachine::SeekCompleted(
   // data requests.
 
   if (mDecodingFirstFrame) {
     // We were resuming from dormant, or initiated a seek early.
     // We can fire loadeddata now.
     FinishDecodeFirstFrame();
   }
 
-  if (nextState == DECODER_STATE_DECODING) {
-    SetState(DECODER_STATE_DECODING);
-  } else {
-    SetState(nextState);
-  }
-
   // Ensure timestamps are up to date.
   UpdatePlaybackPositionInternal(newCurrentTime);
 
   // Try to decode another frame to detect if we're at the end...
   DECODER_LOG("Seek completed, mCurrentPosition=%lld", mCurrentPosition.Ref());
 
   // Reset quick buffering status. This ensures that if we began the
   // seek while quick-buffering, we won't bypass quick buffering mode
   // if we need to buffer after the seek.
   mQuickBuffering = false;
 
-  ScheduleStateMachine();
-
   if (video) {
     mMediaSink->Redraw(mInfo.mVideo);
     mOnPlaybackEvent.Notify(MediaEventType::Invalidate);
   }
+
+  if (nextState == DECODER_STATE_DECODING) {
+    SetState(DECODER_STATE_DECODING);
+  } else {
+    SetState(nextState);
+  }
+
+  ScheduleStateMachine();
 }
 
 RefPtr<ShutdownPromise>
 MediaDecoderStateMachine::BeginShutdown()
 {
   return InvokeAsync(OwnerThread(), this, __func__,
                      &MediaDecoderStateMachine::Shutdown);
 }