Bug 1300956. Part 5 - Implement DecodingState.
MozReview-Commit-ID: Kx5oRrT8DD0
--- 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;