Bug 1388665 - remove BufferingState::DispatchDecodeTasksIfNeeded().
We will dispatch decoding tasks in Handle{Audio,Video}Decoded() instead.
See comment 0 for the rationale.
MozReview-Commit-ID: 9trJYoMfzJH
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1859,27 +1859,33 @@ public:
}
void Step() override;
State GetState() const override { return DECODER_STATE_BUFFERING; }
void HandleAudioDecoded(AudioData* aAudio) override
{
+ mMaster->PushAudio(aAudio);
+ if (!mMaster->HaveEnoughDecodedAudio()) {
+ mMaster->RequestAudioData();
+ }
// This might be the sample we need to exit buffering.
// Schedule Step() to check it.
- mMaster->PushAudio(aAudio);
mMaster->ScheduleStateMachine();
}
void HandleVideoDecoded(VideoData* aVideo, TimeStamp aDecodeStart) override
{
+ mMaster->PushVideo(aVideo);
+ if (!mMaster->HaveEnoughDecodedVideo()) {
+ mMaster->RequestVideoData(media::TimeUnit());
+ }
// This might be the sample we need to exit buffering.
// Schedule Step() to check it.
- mMaster->PushVideo(aVideo);
mMaster->ScheduleStateMachine();
}
void HandleAudioCanceled() override { mMaster->RequestAudioData(); }
void HandleVideoCanceled() override
{
mMaster->RequestVideoData(media::TimeUnit());
@@ -1916,18 +1922,16 @@ public:
}
mMaster->mVideoDecodeSuspended = true;
mMaster->mOnPlaybackEvent.Notify(MediaEventType::EnterVideoSuspend);
Reader()->SetVideoBlankDecode(true);
}
private:
- void DispatchDecodeTasksIfNeeded();
-
TimeStamp mBufferingStart;
// The maximum number of second we spend buffering when we are short on
// unbuffered data.
const uint32_t mBufferingWait = 15;
};
/**
@@ -2533,35 +2537,16 @@ SeekingState::SeekCompleted()
mMaster->mOnPlaybackEvent.Notify(MediaEventType::Invalidate);
}
GoToNextState();
}
void
MediaDecoderStateMachine::
-BufferingState::DispatchDecodeTasksIfNeeded()
-{
- if (mMaster->IsAudioDecoding()
- && !mMaster->HaveEnoughDecodedAudio()
- && !mMaster->IsRequestingAudioData()
- && !mMaster->IsWaitingAudioData()) {
- mMaster->RequestAudioData();
- }
-
- if (mMaster->IsVideoDecoding()
- && !mMaster->HaveEnoughDecodedVideo()
- && !mMaster->IsRequestingVideoData()
- && !mMaster->IsWaitingVideoData()) {
- mMaster->RequestVideoData(media::TimeUnit());
- }
-}
-
-void
-MediaDecoderStateMachine::
BufferingState::Step()
{
TimeStamp now = TimeStamp::Now();
MOZ_ASSERT(!mBufferingStart.IsNull(), "Must know buffering start time.");
// With buffering heuristics we will remain in the buffering state if
// we've not decoded enough data to begin playback, or if we've not
// downloaded a reasonable amount of data inside our buffering time.
@@ -2571,21 +2556,19 @@ BufferingState::Step()
if ((isLiveStream || !mMaster->mCanPlayThrough)
&& elapsed
< TimeDuration::FromSeconds(mBufferingWait * mMaster->mPlaybackRate)
&& mMaster->HasLowBufferedData(TimeUnit::FromSeconds(mBufferingWait))
&& IsExpectingMoreData()) {
SLOG("Buffering: wait %ds, timeout in %.3lfs",
mBufferingWait, mBufferingWait - elapsed.ToSeconds());
mMaster->ScheduleStateMachineIn(TimeUnit::FromMicroseconds(USECS_PER_S));
- DispatchDecodeTasksIfNeeded();
return;
}
} else if (mMaster->OutOfDecodedAudio() || mMaster->OutOfDecodedVideo()) {
- DispatchDecodeTasksIfNeeded();
MOZ_ASSERT(!mMaster->OutOfDecodedAudio()
|| mMaster->IsRequestingAudioData()
|| mMaster->IsWaitingAudioData());
MOZ_ASSERT(!mMaster->OutOfDecodedVideo()
|| mMaster->IsRequestingVideoData()
|| mMaster->IsWaitingVideoData());
SLOG("In buffering mode, waiting to be notified: outOfAudio: %d, "
"mAudioStatus: %s, outOfVideo: %d, mVideoStatus: %s",