Bug 1311267 - DecodingFirstFrameState should override HandleDormant().
MozReview-Commit-ID: LGcvRJF3cNC
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -461,16 +461,18 @@ public:
bool HandleEndOfStream() override
{
MaybeFinishDecodeFirstFrame();
return true;
}
RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override;
+ bool HandleDormant(bool aDormant) override;
+
void HandleVideoSuspendTimeout() override
{
// Do nothing for we need to decode the 1st video frame to get the dimensions.
}
void HandleResumeVideoDecoding() override
{
// We never suspend video decoding in this state.
@@ -1250,16 +1252,31 @@ DecodingFirstFrameState::HandleSeek(Seek
MOZ_ASSERT(!mMaster->mQueuedSeek.Exists());
SLOG("Changed state to SEEKING (to %lld)", aTarget.GetTime().ToMicroseconds());
SeekJob seekJob;
seekJob.mTarget = aTarget;
return SetState<SeekingState>(Move(seekJob));
}
+bool
+MediaDecoderStateMachine::
+DecodingFirstFrameState::HandleDormant(bool aDormant)
+{
+ if (aDormant) {
+ // Don't store mQueuedSeek because:
+ // 1. if mQueuedSeek is not empty, respect the latest seek request
+ // and don't overwrite it.
+ // 2. if mQueuedSeek is empty, there is no need to seek when exiting
+ // the dormant state for we are at position 0.
+ SetState<DormantState>();
+ }
+ return true;
+}
+
void
MediaDecoderStateMachine::
DecodingFirstFrameState::MaybeFinishDecodeFirstFrame()
{
MOZ_ASSERT(!mMaster->mSentFirstFrameLoadedEvent);
if ((mMaster->IsAudioDecoding() && mMaster->AudioQueue().GetSize() == 0) ||
(mMaster->IsVideoDecoding() && mMaster->VideoQueue().GetSize() == 0)) {