diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index 87221cd96efb..7bc2ec15c52a 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -325,7 +325,6 @@ MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity) if (IsShutdown() || !mDecoderStateMachine || - mPlayState == PLAY_STATE_SHUTDOWN || !mOwner->GetVideoFrameContainer() || (mOwner->GetMediaElement() && mOwner->GetMediaElement()->IsBeingDestroyed()) || !mDormantSupported) @@ -425,12 +424,13 @@ void MediaDecoder::Pause() { MOZ_ASSERT(NS_IsMainThread()); - if (mPlayState == PLAY_STATE_LOADING || - IsEnded()) { + if (IsShutdown()) { + return; + } + if (mPlayState == PLAY_STATE_LOADING || IsEnded()) { mNextState = PLAY_STATE_PAUSED; return; } - ChangeState(PLAY_STATE_PAUSED); } @@ -504,7 +504,6 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner) , mVideoFrameContainer(aOwner->GetVideoFrameContainer()) , mPlaybackStatistics(new MediaChannelStatistics()) , mPinnedForSeek(false) - , mShuttingDown(false) , mPausedForPlaybackRateNull(false) , mMinimizePreroll(false) , mMediaTracksConstructed(false) @@ -611,8 +610,6 @@ MediaDecoder::Shutdown() return; } - mShuttingDown = true; - // Unwatch all watch targets to prevent further notifications. mWatchManager.Shutdown(); @@ -1078,7 +1075,7 @@ bool MediaDecoder::IsEndedOrShutdown() const { MOZ_ASSERT(NS_IsMainThread()); - return IsEnded() || mPlayState == PLAY_STATE_SHUTDOWN; + return IsEnded() || IsShutdown(); } bool @@ -1127,7 +1124,7 @@ bool MediaDecoder::IsShutdown() const { MOZ_ASSERT(NS_IsMainThread()); - return mShuttingDown; + return mPlayState == PLAY_STATE_SHUTDOWN; } void @@ -1341,15 +1338,12 @@ void MediaDecoder::ChangeState(PlayState aState) { MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(!IsShutdown(), "SHUTDOWN is the final state."); if (mNextState == aState) { mNextState = PLAY_STATE_PAUSED; } - if (mPlayState == PLAY_STATE_SHUTDOWN) { - return; - } - DECODER_LOG("ChangeState %s => %s", PlayStateStr(), ToPlayStateStr(aState)); mPlayState = aState; diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index f70a4880ed82..637e884cd988 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -684,12 +684,6 @@ protected: // while seeking. bool mPinnedForSeek; - // True if the decoder is being shutdown. At this point all events that - // are currently queued need to return immediately to prevent javascript - // being run that operates on the element and decoder during shutdown. - // Read/Write from the main thread only. - bool mShuttingDown; - // True if the playback is paused because the playback rate member is 0.0. bool mPausedForPlaybackRateNull;