Bug 1123535 - Run MediaDecoderReader::ReleaseMediaResources on decode task queue. r=jwwang
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1962,17 +1962,17 @@ MediaDecoderStateMachine::EnsureAudioDec
{
AssertCurrentThreadInMonitor();
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
"Should be on state machine or decode thread.");
SAMPLE_LOG("EnsureAudioDecodeTaskQueued isDecoding=%d status=%d",
IsAudioDecoding(), mAudioRequestStatus);
- if (mState >= DECODER_STATE_COMPLETED) {
+ if (mState >= DECODER_STATE_COMPLETED || mState == DECODER_STATE_DORMANT) {
return NS_OK;
}
MOZ_ASSERT(mState >= DECODER_STATE_DECODING_FIRSTFRAME);
if (IsAudioDecoding() && mAudioRequestStatus == RequestStatus::Idle && !mWaitingForDecoderSeek) {
RefPtr<nsIRunnable> task(
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::DecodeAudio));
@@ -2007,17 +2007,17 @@ MediaDecoderStateMachine::EnsureVideoDec
AssertCurrentThreadInMonitor();
SAMPLE_LOG("EnsureVideoDecodeTaskQueued isDecoding=%d status=%d",
IsVideoDecoding(), mVideoRequestStatus);
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
"Should be on state machine or decode thread.");
- if (mState >= DECODER_STATE_COMPLETED) {
+ if (mState >= DECODER_STATE_COMPLETED || mState == DECODER_STATE_DORMANT) {
return NS_OK;
}
MOZ_ASSERT(mState >= DECODER_STATE_DECODING_FIRSTFRAME);
if (IsVideoDecoding() && mVideoRequestStatus == RequestStatus::Idle && !mWaitingForDecoderSeek) {
RefPtr<nsIRunnable> task(
NS_NewRunnableMethod(this, &MediaDecoderStateMachine::DecodeVideo));
@@ -2761,22 +2761,20 @@ nsresult MediaDecoderStateMachine::RunSt
if (IsPlaying()) {
StopPlayback();
}
StopAudioThread();
FlushDecoding();
// Now that those threads are stopped, there's no possibility of
// mPendingWakeDecoder being needed again. Revoke it.
mPendingWakeDecoder = nullptr;
- {
- ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
- // Wait for the thread decoding, if any, to exit.
- DecodeTaskQueue()->AwaitIdle();
- mReader->ReleaseMediaResources();
- }
+ DebugOnly<nsresult> rv = DecodeTaskQueue()->Dispatch(
+ NS_NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseMediaResources));
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+
return NS_OK;
}
case DECODER_STATE_WAIT_FOR_RESOURCES: {
return NS_OK;
}
case DECODER_STATE_DECODING_NONE: {