Bug 1346498 part 4 - remove mIsVisible cannonical-mirror pair; r?jwwang
The role of MDSM::mIsVisible and MDSM::VisibilityChanged() have been replaced by
the MDSM::mVideoDecodeMode and MDSM::VideoDecodeModeChanged() completely.
MozReview-Commit-ID: 8sW0s8ilF1E
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -410,17 +410,16 @@ MediaDecoder::MediaDecoder(MediaDecoderO
, INIT_CANONICAL(mPlayState, PLAY_STATE_LOADING)
, INIT_CANONICAL(mNextState, PLAY_STATE_PAUSED)
, INIT_CANONICAL(mLogicallySeeking, false)
, INIT_CANONICAL(mSameOriginMedia, false)
, INIT_CANONICAL(mMediaPrincipalHandle, PRINCIPAL_HANDLE_NONE)
, INIT_CANONICAL(mPlaybackBytesPerSecond, 0.0)
, INIT_CANONICAL(mPlaybackRateReliable, true)
, INIT_CANONICAL(mDecoderPosition, 0)
- , INIT_CANONICAL(mIsVisible, !aOwner->IsHidden())
, INIT_CANONICAL(mHasSuspendTaint, false)
, mTelemetryReported(false)
, mIsMediaElement(!!aOwner->GetMediaElement())
, mElement(aOwner->GetMediaElement())
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mAbstractMainThread);
MediaMemoryTracker::AddMediaDecoder(this);
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -806,19 +806,16 @@ protected:
Canonical<bool> mPlaybackRateReliable;
// Current decoding position in the stream. This is where the decoder
// is up to consuming the stream. This is not adjusted during decoder
// seek operations, but it's updated at the end when we start playing
// back again.
Canonical<int64_t> mDecoderPosition;
- // True if the decoder is visible.
- Canonical<bool> mIsVisible;
-
// True if the decoder has a suspend taint - meaning suspend-video-decoder is
// disabled.
Canonical<bool> mHasSuspendTaint;
public:
AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() override;
AbstractCanonical<double>* CanonicalVolume() { return &mVolume; }
AbstractCanonical<bool>* CanonicalPreservesPitch()
@@ -854,17 +851,16 @@ public:
AbstractCanonical<bool>* CanonicalPlaybackRateReliable()
{
return &mPlaybackRateReliable;
}
AbstractCanonical<int64_t>* CanonicalDecoderPosition()
{
return &mDecoderPosition;
}
- AbstractCanonical<bool>* CanonicalIsVisible() { return &mIsVisible; }
AbstractCanonical<bool>* CanonicalHasSuspendTaint() { return &mHasSuspendTaint; }
private:
// Notify owner when the audible state changed
void NotifyAudibleStateChanged();
/* Functions called by ResourceCallback */
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2166,21 +2166,22 @@ DecodingFirstFrameState::MaybeFinishDeco
}
void
MediaDecoderStateMachine::
DecodingState::Enter()
{
MOZ_ASSERT(mMaster->mSentFirstFrameLoadedEvent);
- if (!mMaster->mIsVisible
+ if (mMaster->mVideoDecodeMode == VideoDecodeMode::Suspend
&& !mMaster->mVideoDecodeSuspendTimer.IsScheduled()
&& !mMaster->mVideoDecodeSuspended) {
- // If we are not visible and the timer is not schedule, it means the timer
- // has timed out and we should suspend video decoding now if necessary.
+ // If the VideoDecodeMode is Suspend and the timer is not schedule, it means
+ // the timer has timed out and we should suspend video decoding now if
+ // necessary.
HandleVideoSuspendTimeout();
}
if (!mMaster->IsVideoDecoding() && !mMaster->IsAudioDecoding()) {
SetState<CompletedState>();
return;
}
@@ -2551,17 +2552,16 @@ ShutdownState::Enter()
master->mNextPlayState.DisconnectIfConnected();
master->mVolume.DisconnectIfConnected();
master->mPreservesPitch.DisconnectIfConnected();
master->mSameOriginMedia.DisconnectIfConnected();
master->mMediaPrincipalHandle.DisconnectIfConnected();
master->mPlaybackBytesPerSecond.DisconnectIfConnected();
master->mPlaybackRateReliable.DisconnectIfConnected();
master->mDecoderPosition.DisconnectIfConnected();
- master->mIsVisible.DisconnectIfConnected();
master->mHasSuspendTaint.DisconnectIfConnected();
master->mDuration.DisconnectAll();
master->mIsShutdown.DisconnectAll();
master->mNextFrameStatus.DisconnectAll();
master->mCurrentPosition.DisconnectAll();
master->mPlaybackOffset.DisconnectAll();
master->mIsAudioDataAudible.DisconnectAll();
@@ -2620,17 +2620,16 @@ MediaDecoderStateMachine::MediaDecoderSt
INIT_MIRROR(mNextPlayState, MediaDecoder::PLAY_STATE_PAUSED),
INIT_MIRROR(mVolume, 1.0),
INIT_MIRROR(mPreservesPitch, true),
INIT_MIRROR(mSameOriginMedia, false),
INIT_MIRROR(mMediaPrincipalHandle, PRINCIPAL_HANDLE_NONE),
INIT_MIRROR(mPlaybackBytesPerSecond, 0.0),
INIT_MIRROR(mPlaybackRateReliable, true),
INIT_MIRROR(mDecoderPosition, 0),
- INIT_MIRROR(mIsVisible, true),
INIT_MIRROR(mHasSuspendTaint, false),
INIT_CANONICAL(mDuration, NullableTimeUnit()),
INIT_CANONICAL(mIsShutdown, false),
INIT_CANONICAL(mNextFrameStatus, MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE),
INIT_CANONICAL(mCurrentPosition, 0),
INIT_CANONICAL(mPlaybackOffset, 0),
INIT_CANONICAL(mIsAudioDataAudible, false)
{
@@ -2692,20 +2691,17 @@ MediaDecoderStateMachine::Initialization
&MediaDecoderStateMachine::RecomputeDuration);
mWatchManager.Watch(mExplicitDuration,
&MediaDecoderStateMachine::RecomputeDuration);
mWatchManager.Watch(mObservedDuration,
&MediaDecoderStateMachine::RecomputeDuration);
mWatchManager.Watch(mPlayState, &MediaDecoderStateMachine::PlayStateChanged);
if (MediaPrefs::MDSMSuspendBackgroundVideoEnabled()) {
- mIsVisible.Connect(aDecoder->CanonicalIsVisible());
mHasSuspendTaint.Connect(aDecoder->CanonicalHasSuspendTaint());
- mWatchManager.Watch(mIsVisible,
- &MediaDecoderStateMachine::VisibilityChanged);
mWatchManager.Watch(mHasSuspendTaint,
&MediaDecoderStateMachine::SuspendTaintChanged);
}
MOZ_ASSERT(!mStateObj);
auto* s = new DecodeMetadataState(this);
mStateObj.reset(s);
s->Enter();
@@ -3023,44 +3019,16 @@ void MediaDecoderStateMachine::PlayState
// assume the user is likely to want to keep playing in future. This needs
// to happen before we invoke StartDecoding().
mMinimizePreroll = false;
}
mStateObj->HandlePlayStateChanged(mPlayState);
}
-void MediaDecoderStateMachine::VisibilityChanged()
-{
- MOZ_ASSERT(OnTaskQueue());
- DECODER_LOG("VisibilityChanged: mIsVisible=%d, mVideoDecodeSuspended=%c",
- mIsVisible.Ref(), mVideoDecodeSuspended ? 'T' : 'F');
-
- // Start timer to trigger suspended decoding state when going invisible.
- if (!mIsVisible) {
- TimeStamp target = TimeStamp::Now() + SuspendBackgroundVideoDelay();
-
- RefPtr<MediaDecoderStateMachine> self = this;
- mVideoDecodeSuspendTimer.Ensure(target,
- [=]() { self->OnSuspendTimerResolved(); },
- [] () { MOZ_DIAGNOSTIC_ASSERT(false); });
- mOnPlaybackEvent.Notify(MediaEventType::StartVideoSuspendTimer);
- return;
- }
-
- // Resuming from suspended decoding
-
- // If suspend timer exists, destroy it.
- CancelSuspendTimer();
-
- if (mVideoDecodeSuspended) {
- mStateObj->HandleResumeVideoDecoding();
- }
-}
-
void MediaDecoderStateMachine::SuspendTaintChanged()
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(mHasSuspendTaint); // Suspend taint is only ever set.
CancelSuspendTimer();
// Resume from suspended decoding.
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -749,19 +749,16 @@ private:
Mirror<double> mPlaybackBytesPerSecond;
// True if mPlaybackBytesPerSecond is a reliable estimate.
Mirror<bool> mPlaybackRateReliable;
// Current decoding position in the stream.
Mirror<int64_t> mDecoderPosition;
- // IsVisible, mirrored from the media decoder.
- Mirror<bool> mIsVisible;
-
// HasSuspendTaint, mirrored from the media decoder.
Mirror<bool> mHasSuspendTaint;
// Duration of the media. This is guaranteed to be non-null after we finish
// decoding the first frame.
Canonical<media::NullableTimeUnit> mDuration;
// Whether we're currently in or transitioning to shutdown state.