Bug 1298217. Part 2 - Move some code to the entry action of DECODER_STATE_DORMANT.
MozReview-Commit-ID: 9q35AhxS5IP
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1094,16 +1094,24 @@ void
MediaDecoderStateMachine::EnterState(State aState)
{
MOZ_ASSERT(OnTaskQueue());
switch (aState) {
case DECODER_STATE_DECODING_METADATA:
mDecodingFirstFrame = true;
ReadMetadata();
break;
+ case DECODER_STATE_DORMANT:
+ DiscardSeekTaskIfExist();
+ if (IsPlaying()) {
+ StopPlayback();
+ }
+ Reset();
+ mReader->ReleaseResources();
+ break;
case DECODER_STATE_ERROR:
case DECODER_STATE_SHUTDOWN:
mIsShutdown = true;
break;
default:
break;
}
}
@@ -1198,34 +1206,16 @@ MediaDecoderStateMachine::SetDormant(boo
SeekTarget::Accurate,
MediaDecoderEventVisibility::Suppressed);
// SeekJob asserts |mTarget.IsValid() == !mPromise.IsEmpty()| so we
// need to create the promise even it is not used at all.
RefPtr<MediaDecoder::SeekPromise> unused = mQueuedSeek.mPromise.Ensure(__func__);
}
SetState(DECODER_STATE_DORMANT);
-
- // Discard the current seek task.
- DiscardSeekTaskIfExist();
-
- if (IsPlaying()) {
- StopPlayback();
- }
-
- Reset();
-
- // Note that we do not wait for the decode task queue to go idle before
- // queuing the ReleaseResources task - instead, we disconnect promises,
- // reset state, and put a ResetDecode in the decode task queue. Any tasks
- // that run after ResetDecode are supposed to run with a clean slate. We
- // rely on that in other places (i.e. seeking), so it seems reasonable to
- // rely on it here as well.
- mReader->ReleaseResources();
-
return;
}
// Exit dormant state.
SetState(DECODER_STATE_DECODING_METADATA);
}
RefPtr<ShutdownPromise>