Bug 1298217. Part 1 - Move the code about decoding metadata to the entry action of DECODER_STATE_DECODING_METADATA.
MozReview-Commit-ID: Dyb0HnMTLpQ
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -876,17 +876,18 @@ nsresult MediaDecoderStateMachine::Init(
OwnerThread(), __func__, this,
&MediaDecoderStateMachine::OnCDMProxyReady,
&MediaDecoderStateMachine::OnCDMProxyNotReady));
#endif
nsresult rv = mReader->Init();
NS_ENSURE_SUCCESS(rv, rv);
- OwnerThread()->Dispatch(NewRunnableMethod(this, &MediaDecoderStateMachine::ReadMetadata));
+ OwnerThread()->Dispatch(NewRunnableMethod<State>(
+ this, &MediaDecoderStateMachine::EnterState, mState.Ref()));
return NS_OK;
}
void
MediaDecoderStateMachine::SetMediaDecoderReaderWrapperCallback()
{
MOZ_ASSERT(OnTaskQueue());
@@ -1089,16 +1090,20 @@ MediaDecoderStateMachine::ExitState(Stat
}
}
void
MediaDecoderStateMachine::EnterState(State aState)
{
MOZ_ASSERT(OnTaskQueue());
switch (aState) {
+ case DECODER_STATE_DECODING_METADATA:
+ mDecodingFirstFrame = true;
+ ReadMetadata();
+ break;
case DECODER_STATE_ERROR:
case DECODER_STATE_SHUTDOWN:
mIsShutdown = true;
break;
default:
break;
}
}
@@ -1216,18 +1221,16 @@ MediaDecoderStateMachine::SetDormant(boo
// rely on it here as well.
mReader->ReleaseResources();
return;
}
// Exit dormant state.
SetState(DECODER_STATE_DECODING_METADATA);
- mDecodingFirstFrame = true;
- ReadMetadata();
}
RefPtr<ShutdownPromise>
MediaDecoderStateMachine::Shutdown()
{
MOZ_ASSERT(OnTaskQueue());
// Once we've entered the shutdown state here there's no going back.