Backed out changeset 22484b7bbff3 (bug 1108728) for mochitest-11 bustage on a CLOSED TREE

This commit is contained in:
Wes Kocher 2014-12-11 15:19:50 -08:00
parent 12fb9a1937
commit 449c5fc2eb
2 changed files with 39 additions and 11 deletions

View File

@ -125,7 +125,8 @@ void MediaDecoder::SetDormantIfNecessary(bool aDormant)
if (!mDecoderStateMachine ||
!mDecoderStateMachine->IsDormantNeeded() ||
mPlayState == PLAY_STATE_SHUTDOWN) {
mPlayState == PLAY_STATE_SHUTDOWN ||
mIsDormant == aDormant) {
return;
}
@ -139,11 +140,14 @@ void MediaDecoder::SetDormantIfNecessary(bool aDormant)
mRequestedSeekTarget = SeekTarget(timeUsecs, SeekTarget::Accurate);
mNextState = mPlayState;
mIsDormant = true;
mIsExitingDormant = false;
ChangeState(PLAY_STATE_LOADING);
} else {
} else if (!aDormant && mPlayState == PLAY_STATE_LOADING) {
// exit dormant state
// trigger to state machine.
mDecoderStateMachine->SetDormant(false);
mIsExitingDormant = true;
}
}
@ -151,7 +155,7 @@ void MediaDecoder::Pause()
{
MOZ_ASSERT(NS_IsMainThread());
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if (mPlayState == PLAY_STATE_LOADING ||
if ((mPlayState == PLAY_STATE_LOADING && mIsDormant) ||
mPlayState == PLAY_STATE_SEEKING ||
mPlayState == PLAY_STATE_ENDED) {
mNextState = PLAY_STATE_PAUSED;
@ -428,6 +432,8 @@ MediaDecoder::MediaDecoder() :
mMediaSeekable(true),
mSameOriginMedia(false),
mReentrantMonitor("media.decoder"),
mIsDormant(false),
mIsExitingDormant(false),
mPlayState(PLAY_STATE_LOADING),
mNextState(PLAY_STATE_PAUSED),
mIgnoreProgressData(false),
@ -594,13 +600,12 @@ nsresult MediaDecoder::Play()
}
nsresult res = ScheduleStateMachineThread();
NS_ENSURE_SUCCESS(res,res);
if (mPlayState == PLAY_STATE_LOADING || mPlayState == PLAY_STATE_SEEKING) {
if ((mPlayState == PLAY_STATE_LOADING && mIsDormant) || mPlayState == PLAY_STATE_SEEKING) {
mNextState = PLAY_STATE_PLAYING;
return NS_OK;
}
if (mPlayState == PLAY_STATE_ENDED) {
if (mPlayState == PLAY_STATE_ENDED)
return Seek(0, SeekTarget::PrevSyncPoint);
}
ChangeState(PLAY_STATE_PLAYING);
return NS_OK;
@ -623,7 +628,7 @@ nsresult MediaDecoder::Seek(double aTime, SeekTarget::Type aSeekType)
// If we are already in the seeking state, then setting mRequestedSeekTarget
// above will result in the new seek occurring when the current seek
// completes.
if (mPlayState != PLAY_STATE_LOADING && mPlayState != PLAY_STATE_SEEKING) {
if ((mPlayState != PLAY_STATE_LOADING || !mIsDormant) && mPlayState != PLAY_STATE_SEEKING) {
bool paused = false;
if (mOwner) {
paused = mOwner->GetPaused();
@ -698,6 +703,12 @@ void MediaDecoder::MetadataLoaded(nsAutoPtr<MediaInfo> aInfo,
{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if (mPlayState == PLAY_STATE_LOADING && mIsDormant && !mIsExitingDormant) {
return;
} else if (mPlayState == PLAY_STATE_LOADING && mIsDormant && mIsExitingDormant) {
mIsDormant = false;
mIsExitingDormant = false;
}
mDuration = mDecoderStateMachine ? mDecoderStateMachine->GetDuration() : -1;
// Duration has changed so we should recompute playback rate
UpdatePlaybackRate();
@ -730,6 +741,10 @@ void MediaDecoder::FirstFrameLoaded(nsAutoPtr<MediaInfo> aInfo)
aInfo->mAudio.mChannels, aInfo->mAudio.mRate,
aInfo->HasAudio(), aInfo->HasVideo());
if (mPlayState == PLAY_STATE_LOADING && mIsDormant && !mIsExitingDormant) {
return;
}
mInfo = aInfo.forget();
if (mOwner) {
@ -814,8 +829,7 @@ bool MediaDecoder::IsSameOriginMedia()
bool MediaDecoder::IsSeeking() const
{
MOZ_ASSERT(NS_IsMainThread());
return mPlayState == PLAY_STATE_SEEKING ||
(mPlayState == PLAY_STATE_LOADING && mRequestedSeekTarget.IsValid());
return mPlayState == PLAY_STATE_SEEKING;
}
bool MediaDecoder::IsEnded() const
@ -830,7 +844,7 @@ void MediaDecoder::PlaybackEnded()
if (mShuttingDown ||
mPlayState == PLAY_STATE_SEEKING ||
(mPlayState == PLAY_STATE_LOADING)) {
(mPlayState == PLAY_STATE_LOADING && mIsDormant)) {
return;
}
@ -1127,7 +1141,8 @@ void MediaDecoder::ChangeState(PlayState aState)
mNextState = PLAY_STATE_PAUSED;
}
if (mPlayState == PLAY_STATE_SHUTDOWN) {
if ((mPlayState == PLAY_STATE_LOADING && mIsDormant && aState != PLAY_STATE_SHUTDOWN) ||
mPlayState == PLAY_STATE_SHUTDOWN) {
GetReentrantMonitor().NotifyAll();
return;
}
@ -1152,6 +1167,11 @@ void MediaDecoder::ChangeState(PlayState aState)
ApplyStateToStateMachine(mPlayState);
if (aState!= PLAY_STATE_LOADING) {
mIsDormant = false;
mIsExitingDormant = false;
}
GetReentrantMonitor().NotifyAll();
}

View File

@ -1124,6 +1124,14 @@ protected:
// without holding the monitor.
nsAutoPtr<DecodedStreamData> mDecodedStream;
// True if this decoder is in dormant state.
// Should be true only when PlayState is PLAY_STATE_LOADING.
bool mIsDormant;
// True if this decoder is exiting from dormant state.
// Should be true only when PlayState is PLAY_STATE_LOADING.
bool mIsExitingDormant;
// Set to one of the valid play states.
// This can only be changed on the main thread while holding the decoder
// monitor. Thus, it can be safely read while holding the decoder monitor