Bug 1300956. Part 3 - Implement DormantState. r=kaku
authorJW Wang <jwwang@mozilla.com>
Tue, 06 Sep 2016 11:07:55 +0800
changeset 313186 174da142669cd40e4c4f7cb15ef7c538ce8541af
parent 313185 782c54cd404f894cdd1f101fb5a7b1648f29baa9
child 313187 30b53fa5af1379222391b9dfdcd0bf290adb0cbc
push id30674
push userkwierso@gmail.com
push dateThu, 08 Sep 2016 22:03:48 +0000
treeherdermozilla-central@5d854c8d0765 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaku
bugs1300956
milestone51.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 1300956. Part 3 - Implement DormantState. r=kaku MozReview-Commit-ID: 85IjZCdFjyJ
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -246,16 +246,38 @@ public:
   explicit WaitForCDMState(Master* aPtr) : StateObject(aPtr) {}
 
   State GetState() const override
   {
     return DECODER_STATE_WAIT_FOR_CDM;
   }
 };
 
+class MediaDecoderStateMachine::DormantState
+  : public MediaDecoderStateMachine::StateObject
+{
+public:
+  explicit DormantState(Master* aPtr) : StateObject(aPtr) {}
+
+  void Enter() override
+  {
+    mMaster->DiscardSeekTaskIfExist();
+    if (mMaster->IsPlaying()) {
+      mMaster->StopPlayback();
+    }
+    mMaster->Reset();
+    mMaster->mReader->ReleaseResources();
+  }
+
+  State GetState() const override
+  {
+    return DECODER_STATE_DORMANT;
+  }
+};
+
 #define INIT_WATCHABLE(name, val) \
   name(val, "MediaDecoderStateMachine::" #name)
 #define INIT_MIRROR(name, val) \
   name(mTaskQueue, val, "MediaDecoderStateMachine::" #name " (Mirror)")
 #define INIT_CANONICAL(name, val) \
   name(mTaskQueue, val, "MediaDecoderStateMachine::" #name " (Canonical)")
 
 MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
@@ -1116,16 +1138,19 @@ MediaDecoderStateMachine::SetState(State
 
   switch (mState) {
     case DECODER_STATE_DECODING_METADATA:
       mStateObj = MakeUnique<DecodeMetadataState>(this);
       break;
     case DECODER_STATE_WAIT_FOR_CDM:
       mStateObj = MakeUnique<WaitForCDMState>(this);
       break;
+    case DECODER_STATE_DORMANT:
+      mStateObj = MakeUnique<DormantState>(this);
+      break;
     default:
       mStateObj = nullptr;
       break;
   }
 
   EnterState();
 }
 
@@ -1159,24 +1184,16 @@ MediaDecoderStateMachine::EnterState()
 
   if (mStateObj) {
     MOZ_ASSERT(mState == mStateObj->GetState());
     mStateObj->Enter();
     return;
   }
 
   switch (mState) {
-    case DECODER_STATE_DORMANT:
-      DiscardSeekTaskIfExist();
-      if (IsPlaying()) {
-        StopPlayback();
-      }
-      Reset();
-      mReader->ReleaseResources();
-      break;
     case DECODER_STATE_DECODING_FIRSTFRAME:
       DecodeFirstFrame();
       break;
     case DECODER_STATE_DECODING:
       StartDecoding();
       break;
     case DECODER_STATE_BUFFERING:
       StartBuffering();