Bug 1303655. Part 1 - Move some code to Decodingstate::Enter(). draft
authorJW Wang <jwwang@mozilla.com>
Tue, 06 Sep 2016 16:51:45 +0800
changeset 415334 3c747388db01dffc6c222a673350e1e879285295
parent 415333 c0799cf593ae60cc6c0b5e10a536d426601ed923
child 415335 105b38cf5763d4c4669071fb0135213a3f804b92
push id29852
push userjwwang@mozilla.com
push dateTue, 20 Sep 2016 06:50:15 +0000
bugs1303655
milestone51.0a1
Bug 1303655. Part 1 - Move some code to Decodingstate::Enter(). MozReview-Commit-ID: JjhmE0cgOn
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -425,17 +425,38 @@ public:
 class MediaDecoderStateMachine::DecodingState
   : public MediaDecoderStateMachine::StateObject
 {
 public:
   explicit DecodingState(Master* aPtr) : StateObject(aPtr) {}
 
   void Enter() override
   {
-    mMaster->StartDecoding();
+    MOZ_ASSERT(mMaster->mSentFirstFrameLoadedEvent);
+    // Pending seek should've been handled by DECODING_FIRSTFRAME before
+    // transitioning to DECODING.
+    MOZ_ASSERT(!mMaster->mQueuedSeek.Exists());
+
+    if (mMaster->CheckIfDecodeComplete()) {
+      SetState(DECODER_STATE_COMPLETED);
+      return;
+    }
+
+    mMaster->mDecodeStartTime = TimeStamp::Now();
+
+    // Reset other state to pristine values before starting decode.
+    mMaster->mIsAudioPrerolling = !mMaster->DonePrerollingAudio() &&
+                                  !Reader()->IsWaitingAudioData();
+    mMaster->mIsVideoPrerolling = !mMaster->DonePrerollingVideo() &&
+                                  !Reader()->IsWaitingVideoData();
+
+    // Ensure that we've got tasks enqueued to decode data if we need to.
+    mMaster->DispatchDecodeTasksIfNeeded();
+
+    mMaster->ScheduleStateMachine();
   }
 
   void Step() override
   {
     mMaster->StepDecoding();
   }
 
   State GetState() const override