Bug 905008 - Block bogus MetadataLoaded event. r=doublec

This commit is contained in:
Sotaro Ikeda 2013-08-26 12:11:58 -04:00
parent 114c49012c
commit 0496338b24
2 changed files with 14 additions and 3 deletions

View File

@ -139,12 +139,14 @@ void MediaDecoder::SetDormantIfNecessary(bool aDormant)
mNextState = PLAY_STATE_PAUSED;
}
mNextState = mPlayState;
mIsDormant = aDormant;
mIsDormant = true;
mIsExitingDormant = false;
ChangeState(PLAY_STATE_LOADING);
} else if ((aDormant != true) && (mPlayState == PLAY_STATE_LOADING)) {
// exit dormant state
// just trigger to state machine.
// trigger to state machine.
mDecoderStateMachine->SetDormant(false);
mIsExitingDormant = true;
}
}
@ -371,6 +373,7 @@ MediaDecoder::MediaDecoder() :
mSameOriginMedia(false),
mReentrantMonitor("media.decoder"),
mIsDormant(false),
mIsExitingDormant(false),
mPlayState(PLAY_STATE_PAUSED),
mNextState(PLAY_STATE_PAUSED),
mCalledResourceLoaded(false),
@ -724,8 +727,11 @@ void MediaDecoder::MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool
{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if (mPlayState == PLAY_STATE_LOADING && mIsDormant) {
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
@ -1187,6 +1193,7 @@ void MediaDecoder::ChangeState(PlayState aState)
if (aState!= PLAY_STATE_LOADING) {
mIsDormant = false;
mIsExitingDormant = false;
}
GetReentrantMonitor().NotifyAll();

View File

@ -1035,6 +1035,10 @@ public:
// 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