Bug 1328547. part 1 - Move MDSM::Dispatch{Audio,Video}DecodeTaskIfNeeded into DecodingState. r?kaku
MozReview-Commit-ID: I2gT77VHutm
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1993,21 +1993,25 @@ DecodingState::Enter()
if (mMaster->CheckIfDecodeComplete()) {
SetState<CompletedState>();
return;
}
mOnAudioPopped = AudioQueue().PopEvent().Connect(
OwnerThread(), [this] () {
- mMaster->DispatchAudioDecodeTaskIfNeeded();
+ if (!mMaster->IsShutdown() && mMaster->NeedToDecodeAudio()) {
+ mMaster->EnsureAudioDecodeTaskQueued();
+ }
});
mOnVideoPopped = VideoQueue().PopEvent().Connect(
OwnerThread(), [this] () {
- mMaster->DispatchVideoDecodeTaskIfNeeded();
+ if (!mMaster->IsShutdown() && mMaster->NeedToDecodeVideo()) {
+ mMaster->EnsureVideoDecodeTaskQueued();
+ }
});
mMaster->UpdateNextFrameStatus(MediaDecoderOwner::NEXT_FRAME_AVAILABLE);
mDecodeStartTime = TimeStamp::Now();
MaybeStopPrerolling();
@@ -3010,25 +3014,16 @@ MediaDecoderStateMachine::DispatchDecode
EnsureAudioDecodeTaskQueued();
}
if (needToDecodeVideo) {
EnsureVideoDecodeTaskQueued();
}
}
void
-MediaDecoderStateMachine::DispatchAudioDecodeTaskIfNeeded()
-{
- MOZ_ASSERT(OnTaskQueue());
- if (!IsShutdown() && NeedToDecodeAudio()) {
- EnsureAudioDecodeTaskQueued();
- }
-}
-
-void
MediaDecoderStateMachine::EnsureAudioDecodeTaskQueued()
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(mState != DECODER_STATE_SEEKING);
MOZ_ASSERT(mState != DECODER_STATE_DECODING_FIRSTFRAME);
SAMPLE_LOG("EnsureAudioDecodeTaskQueued isDecoding=%d status=%s",
IsAudioDecoding(), AudioRequestStatus());
@@ -3072,25 +3067,16 @@ MediaDecoderStateMachine::RequestAudioDa
SAMPLE_LOG("OnAudioNotDecoded aError=%u", aError.Code());
mAudioDataRequest.Complete();
mStateObj->HandleAudioNotDecoded(aError);
})
);
}
void
-MediaDecoderStateMachine::DispatchVideoDecodeTaskIfNeeded()
-{
- MOZ_ASSERT(OnTaskQueue());
- if (!IsShutdown() && NeedToDecodeVideo()) {
- EnsureVideoDecodeTaskQueued();
- }
-}
-
-void
MediaDecoderStateMachine::EnsureVideoDecodeTaskQueued()
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(mState != DECODER_STATE_SEEKING);
MOZ_ASSERT(mState != DECODER_STATE_DECODING_FIRSTFRAME);
SAMPLE_LOG("EnsureVideoDecodeTaskQueued isDecoding=%d status=%s",
IsVideoDecoding(), VideoRequestStatus());
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -443,19 +443,16 @@ protected:
// Dispatches a LoadedMetadataEvent.
// This is threadsafe and can be called on any thread.
// The decoder monitor must be held.
void EnqueueLoadedMetadataEvent();
void EnqueueFirstFrameLoadedEvent();
- void DispatchAudioDecodeTaskIfNeeded();
- void DispatchVideoDecodeTaskIfNeeded();
-
// Dispatch a task to decode audio if there is not.
void EnsureAudioDecodeTaskQueued();
// Dispatch a task to decode video if there is not.
void EnsureVideoDecodeTaskQueued();
// Start a task to decode audio.
void RequestAudioData();