Bug 1207198: P2. Defer dormant request while ReadMetadata is pending in MDSM. r=sotaro

This commit is contained in:
Jean-Yves Avenard 2015-10-21 20:19:42 +11:00
parent e7316ae5cf
commit 90071cc1a9
2 changed files with 20 additions and 0 deletions

View File

@ -1246,6 +1246,18 @@ MediaDecoderStateMachine::SetDormant(bool aDormant)
return;
}
if (mMetadataRequest.Exists()) {
if (mPendingDormant && mPendingDormant.ref() != aDormant && !aDormant) {
// We already have a dormant request pending; the new request would have
// resumed from dormant, we can just cancel any pending dormant requests.
mPendingDormant.reset();
} else {
mPendingDormant = Some(aDormant);
}
return;
}
mPendingDormant.reset();
DECODER_LOG("SetDormant=%d", aDormant);
if (aDormant) {
@ -1906,6 +1918,11 @@ MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
mMetadataRequest.Complete();
if (mPendingDormant) {
SetDormant(mPendingDormant.ref());
return;
}
// Set mode to PLAYBACK after reading metadata.
mResource->SetReadMode(MediaCacheStream::MODE_PLAYBACK);
mDecoder->DispatchSetMediaSeekable(mReader->IsMediaSeekable());

View File

@ -1086,6 +1086,9 @@ private:
// been written to the MediaStream.
Watchable<bool> mAudioCompleted;
// Set if MDSM receives dormant request during reading metadata.
Maybe<bool> mPendingDormant;
// Flag whether we notify metadata before decoding the first frame or after.
//
// Note that the odd semantics here are designed to replicate the current