Bug 1300956. Part 5 - Implement DecodingState. r=kaku
authorJW Wang <jwwang@mozilla.com>
Tue, 06 Sep 2016 11:14:09 +0800
changeset 354473 b9ea5ce506a7318e037aa519a8af63aa307f8ab6
parent 354472 30b53fa5af1379222391b9dfdcd0bf290adb0cbc
child 354474 d12930f864f388289533fa2813829f0ce19b1747
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [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 5 - Implement DecodingState. r=kaku MozReview-Commit-ID: Kx5oRrT8DD0
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -285,16 +285,38 @@ public:
   }
 
   State GetState() const override
   {
     return DECODER_STATE_DECODING_FIRSTFRAME;
   }
 };
 
+class MediaDecoderStateMachine::DecodingState
+  : public MediaDecoderStateMachine::StateObject
+{
+public:
+  explicit DecodingState(Master* aPtr) : StateObject(aPtr) {}
+
+  void Enter() override
+  {
+    mMaster->StartDecoding();
+  }
+
+  void Step() override
+  {
+    mMaster->StepDecoding();
+  }
+
+  State GetState() const override
+  {
+    return DECODER_STATE_DECODING;
+  }
+};
+
 #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,
@@ -1161,16 +1183,19 @@ MediaDecoderStateMachine::SetState(State
       mStateObj = MakeUnique<WaitForCDMState>(this);
       break;
     case DECODER_STATE_DORMANT:
       mStateObj = MakeUnique<DormantState>(this);
       break;
     case DECODER_STATE_DECODING_FIRSTFRAME:
       mStateObj = MakeUnique<DecodingFirstFrameState>(this);
       break;
+    case DECODER_STATE_DECODING:
+      mStateObj = MakeUnique<DecodingState>(this);
+      break;
     default:
       mStateObj = nullptr;
       break;
   }
 
   EnterState();
 }
 
@@ -1204,19 +1229,16 @@ MediaDecoderStateMachine::EnterState()
 
   if (mStateObj) {
     MOZ_ASSERT(mState == mStateObj->GetState());
     mStateObj->Enter();
     return;
   }
 
   switch (mState) {
-    case DECODER_STATE_DECODING:
-      StartDecoding();
-      break;
     case DECODER_STATE_BUFFERING:
       StartBuffering();
       break;
     case DECODER_STATE_COMPLETED:
       ScheduleStateMachine();
       break;
     case DECODER_STATE_SHUTDOWN:
       mIsShutdown = true;
@@ -2370,19 +2392,16 @@ MediaDecoderStateMachine::RunStateMachin
   mDispatchedStateMachine = false;
 
   if (mStateObj) {
     mStateObj->Step();
     return;
   }
 
   switch (mState) {
-    case DECODER_STATE_DECODING:
-      StepDecoding();
-      return;
     case DECODER_STATE_BUFFERING:
       StepBuffering();
       return;
     case DECODER_STATE_COMPLETED:
       StepCompleted();
       return;
     default:
       return;