Bug 1303666 - Move the code of StepDecoding() into Decodingstate::Step().
MozReview-Commit-ID: FW7BVyrRA7s
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -459,17 +459,33 @@ public:
if (!mDecodeStartTime.IsNull()) {
TimeDuration decodeDuration = TimeStamp::Now() - mDecodeStartTime;
SLOG("Exiting DECODING, decoded for %.3lfs", decodeDuration.ToSeconds());
}
}
void Step() override
{
- mMaster->StepDecoding();
+ if (mMaster->mPlayState != MediaDecoder::PLAY_STATE_PLAYING &&
+ mMaster->IsPlaying()) {
+ // We're playing, but the element/decoder is in paused state. Stop
+ // playing!
+ mMaster->StopPlayback();
+ }
+
+ // Start playback if necessary so that the clock can be properly queried.
+ mMaster->MaybeStartPlayback();
+
+ mMaster->UpdatePlaybackPositionPeriodically();
+
+ MOZ_ASSERT(!mMaster->IsPlaying() ||
+ mMaster->IsStateMachineScheduled(),
+ "Must have timer scheduled");
+
+ mMaster->MaybeStartBuffering();
}
State GetState() const override
{
return DECODER_STATE_DECODING;
}
private:
@@ -2560,39 +2576,16 @@ MediaDecoderStateMachine::RunStateMachin
MOZ_ASSERT(OnTaskQueue());
mDelayedScheduler.Reset(); // Must happen on state machine task queue.
mDispatchedStateMachine = false;
mStateObj->Step();
}
void
-MediaDecoderStateMachine::StepDecoding()
-{
- MOZ_ASSERT(OnTaskQueue());
-
- if (mPlayState != MediaDecoder::PLAY_STATE_PLAYING && IsPlaying()) {
- // We're playing, but the element/decoder is in paused state. Stop
- // playing!
- StopPlayback();
- }
-
- // Start playback if necessary so that the clock can be properly queried.
- MaybeStartPlayback();
-
- UpdatePlaybackPositionPeriodically();
-
- NS_ASSERTION(!IsPlaying() ||
- IsStateMachineScheduled(),
- "Must have timer scheduled");
-
- MaybeStartBuffering();
-}
-
-void
MediaDecoderStateMachine::Reset(TrackSet aTracks)
{
MOZ_ASSERT(OnTaskQueue());
DECODER_LOG("MediaDecoderStateMachine::Reset");
// We should be resetting because we're seeking, shutting down, or entering
// dormant state. We could also be in the process of going dormant, and have
// just switched to exiting dormant before we finished entering dormant,
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -533,18 +533,16 @@ protected:
// Completes the seek operation, moves onto the next appropriate state.
void SeekCompleted();
// Queries our state to see whether the decode has finished for all streams.
bool CheckIfDecodeComplete();
// Performs one "cycle" of the state machine.
void RunStateMachine();
- // Perform one cycle of the DECODING state.
- void StepDecoding();
bool IsStateMachineScheduled() const;
// These return true if the respective stream's decode has not yet reached
// the end of stream.
bool IsAudioDecoding();
bool IsVideoDecoding();