Bug 1289004. Part 3 - Remove MediaDecoder::mShuttingDown. r?cpearce
MozReview-Commit-ID: DoJ4UFuyz2h
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -320,17 +320,16 @@ MediaDecoder::IsHeuristicDormantSupporte
void
MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
{
MOZ_ASSERT(NS_IsMainThread());
if (IsShutdown() ||
!mDecoderStateMachine ||
- mPlayState == PLAY_STATE_SHUTDOWN ||
!mOwner->GetVideoFrameContainer() ||
(mOwner->GetMediaElement() && mOwner->GetMediaElement()->IsBeingDestroyed()) ||
!mDormantSupported)
{
return;
}
DECODER_LOG("UpdateDormantState aTimeout=%d aActivity=%d mIsDormant=%d "
@@ -420,22 +419,23 @@ MediaDecoder::CancelDormantTimer()
mDormantTimer->Cancel();
}
}
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);
}
void
MediaDecoder::SetVolume(double aVolume)
{
MOZ_ASSERT(NS_IsMainThread());
mVolume = aVolume;
@@ -499,17 +499,16 @@ MediaDecoder::MediaDecoder(MediaDecoderO
#endif
, mIgnoreProgressData(false)
, mInfiniteStream(false)
, mOwner(aOwner)
, mFrameStats(new FrameStatistics())
, mVideoFrameContainer(aOwner->GetVideoFrameContainer())
, mPlaybackStatistics(new MediaChannelStatistics())
, mPinnedForSeek(false)
- , mShuttingDown(false)
, mPausedForPlaybackRateNull(false)
, mMinimizePreroll(false)
, mMediaTracksConstructed(false)
, mFiredMetadataLoaded(false)
, mIsDormant(false)
, mIsHeuristicDormantSupported(
Preferences::GetBool("media.decoder.heuristic.dormant.enabled", false))
, mHeuristicDormantTimeout(
@@ -606,18 +605,16 @@ void
MediaDecoder::Shutdown()
{
MOZ_ASSERT(NS_IsMainThread());
if (IsShutdown()) {
return;
}
- mShuttingDown = true;
-
// Unwatch all watch targets to prevent further notifications.
mWatchManager.Shutdown();
mResourceCallback->Disconnect();
#ifdef MOZ_EME
mCDMProxyPromiseHolder.RejectIfExists(true, __func__);
#endif
@@ -1073,17 +1070,17 @@ MediaDecoder::IsSeeking() const
MOZ_ASSERT(NS_IsMainThread());
return mLogicallySeeking;
}
bool
MediaDecoder::IsEndedOrShutdown() const
{
MOZ_ASSERT(NS_IsMainThread());
- return IsEnded() || mPlayState == PLAY_STATE_SHUTDOWN;
+ return IsEnded() || IsShutdown();
}
bool
MediaDecoder::OwnerHasError() const
{
MOZ_ASSERT(NS_IsMainThread());
return IsShutdown() || mOwner->HasError();
}
@@ -1122,17 +1119,17 @@ MediaDecoder::IsEnded() const
MOZ_ASSERT(NS_IsMainThread());
return mPlayState == PLAY_STATE_ENDED;
}
bool
MediaDecoder::IsShutdown() const
{
MOZ_ASSERT(NS_IsMainThread());
- return mShuttingDown;
+ return mPlayState == PLAY_STATE_SHUTDOWN;
}
void
MediaDecoder::PlaybackEnded()
{
MOZ_ASSERT(NS_IsMainThread());
if (IsShutdown() ||
@@ -1336,25 +1333,22 @@ MediaDecoder::SeekingStarted(MediaDecode
mOwner->SeekStarted();
}
}
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;
if (mPlayState == PLAY_STATE_PLAYING) {
ConstructMediaTracks();
} else if (IsEnded()) {
RemoveMediaTracks();
}
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -679,22 +679,16 @@ protected:
// this estimate is "decode time" (where the "current time" is the
// time of the last decoded video frame).
RefPtr<MediaChannelStatistics> mPlaybackStatistics;
// True when our media stream has been pinned. We pin the stream
// 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;
// Be assigned from media element during the initialization and pass to
// AudioStream Class.
dom::AudioChannel mAudioChannel;
// True if the decoder has been directed to minimize its preroll before