Bug 1261312 - make sure that audio/video decode task is filed again; r=jwwang
The idea is that we can call Ensure{Audio/Video}DecodeTaskQueued() directly
since the conditions in the DispatchDecodeTasksIfNeeded() have already been
checked.
MozReview-Commit-ID: 9xataQiuSIx
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -776,17 +776,21 @@ MediaDecoderStateMachine::OnNotDecoded(M
MOZ_ASSERT(mReader->IsWaitForDataSupported(),
"Readers that send WAITING_FOR_DATA need to implement WaitForData");
RefPtr<MediaDecoderStateMachine> self = this;
WaitRequestRef(aType).Begin(InvokeAsync(DecodeTaskQueue(), mReader.get(), __func__,
&MediaDecoderReader::WaitForData, aType)
->Then(OwnerThread(), __func__,
[self] (MediaData::Type aType) -> void {
self->WaitRequestRef(aType).Complete();
- self->DispatchDecodeTasksIfNeeded();
+ if (aType == MediaData::AUDIO_DATA) {
+ self->EnsureAudioDecodeTaskQueued();
+ } else {
+ self->EnsureVideoDecodeTaskQueued();
+ }
},
[self] (WaitForDataRejectValue aRejection) -> void {
self->WaitRequestRef(aRejection.mType).Complete();
}));
// We are out of data to decode and will enter buffering mode soon.
// We want to play the frames we have already decoded, so we stop pre-rolling
// and ensure that loadeddata is fired as required.
@@ -797,17 +801,21 @@ MediaDecoderStateMachine::OnNotDecoded(M
}
if (mState == DECODER_STATE_BUFFERING || mState == DECODER_STATE_DECODING) {
MaybeFinishDecodeFirstFrame();
}
return;
}
if (aReason == MediaDecoderReader::CANCELED) {
- DispatchDecodeTasksIfNeeded();
+ if (isAudio) {
+ EnsureAudioDecodeTaskQueued();
+ } else {
+ EnsureVideoDecodeTaskQueued();
+ }
return;
}
// This is an EOS. Finish off the queue, and then handle things based on our
// state.
MOZ_ASSERT(aReason == MediaDecoderReader::END_OF_STREAM);
if (!isAudio && mState == DECODER_STATE_SEEKING &&
mCurrentSeek.Exists() && mFirstVideoFrameAfterSeek) {