Bug 1322800 part 7 - move NextFrameSeekTask::NeedMoreVideo(); r?jwwang
MozReview-Commit-ID: AMA5OIkVQpT
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1391,17 +1391,17 @@ private:
->Then(OwnerThread(), __func__,
[this] (const SeekTaskResolveValue& aValue) {
OnSeekTaskResolved(aValue);
},
[this] (const SeekTaskRejectValue& aValue) {
OnSeekTaskRejected(aValue);
}));
- if (!mTask->IsVideoRequestPending() && mTask->NeedMoreVideo()) {
+ if (!mTask->IsVideoRequestPending() && NeedMoreVideo()) {
RequestVideoData();
}
MaybeFinishSeek(); // Might resolve mSeekTaskPromise and modify audio queue.
}
void HandleAudioDecoded(MediaData* aAudio) override
{
MOZ_ASSERT(aAudio);
@@ -1427,17 +1427,17 @@ private:
// resolved.
SSAMPLELOG("OnVideoDecoded [%lld,%lld]", aVideo->mTime, aVideo->GetEndTime());
if (aVideo->mTime > mTask->mCurrentTime) {
mTask->mSeekedVideoData = aVideo;
}
- if (mTask->NeedMoreVideo()) {
+ if (NeedMoreVideo()) {
RequestVideoData();
return;
}
MaybeFinishSeek();
}
void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) override
@@ -1462,17 +1462,17 @@ private:
SSAMPLELOG("OnVideoNotDecoded (aError=%u)", aError.Code());
if (aError == NS_ERROR_DOM_MEDIA_END_OF_STREAM) {
mTask->mIsVideoQueueFinished = true;
}
// Video seek not finished.
- if (mTask->NeedMoreVideo()) {
+ if (NeedMoreVideo()) {
switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
Reader()->WaitForData(MediaData::VIDEO_DATA);
break;
case NS_ERROR_DOM_MEDIA_CANCELED:
RequestVideoData();
break;
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
@@ -1502,17 +1502,17 @@ private:
// trigger further audio decode tasks if MDSM itself needs to play audio.
MaybeFinishSeek();
}
void HandleVideoWaited(MediaData::Type aType) override
{
MOZ_ASSERT(mSeekTaskRequest.Exists(), "Seek shouldn't be finished");
- if (mTask->NeedMoreVideo()) {
+ if (NeedMoreVideo()) {
RequestVideoData();
return;
}
MaybeFinishSeek();
}
void HandleNotWaited(const WaitForDataRejectValue& aRejection) override
{
@@ -1523,17 +1523,17 @@ private:
{
// We don't make an audio decode request here, instead, let MDSM to
// trigger further audio decode tasks if MDSM itself needs to play audio.
MaybeFinishSeek();
break;
}
case MediaData::VIDEO_DATA:
{
- if (mTask->NeedMoreVideo()) {
+ if (NeedMoreVideo()) {
// Reject if we can't finish video seeking.
mTask->RejectIfExist(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
return;
}
MaybeFinishSeek();
break;
}
default:
@@ -1590,28 +1590,37 @@ private:
mMaster->DecodeError(aValue.mError);
}
void RequestVideoData()
{
Reader()->RequestVideoData(false, media::TimeUnit());
}
+ bool NeedMoreVideo() const
+ {
+ // Need to request video when we have none and video queue is not finished.
+ return mTask->mVideoQueue.GetSize() == 0 &&
+ !mTask->mSeekedVideoData &&
+ !mTask->mVideoQueue.IsFinished() &&
+ !mTask->mIsVideoQueueFinished;
+ }
+
bool IsAudioSeekComplete() const
{
// Don't finish seek until there are no pending requests. Otherwise, we might
// lose audio samples for the promise is resolved asynchronously.
return !Reader()->IsRequestingAudioData() && !Reader()->IsWaitingAudioData();
}
bool IsVideoSeekComplete() const
{
// Don't finish seek until there are no pending requests. Otherwise, we might
// lose video samples for the promise is resolved asynchronously.
- return !mTask->IsVideoRequestPending() && !mTask->NeedMoreVideo();
+ return !mTask->IsVideoRequestPending() && !NeedMoreVideo();
}
void MaybeFinishSeek()
{
if (IsAudioSeekComplete() && IsVideoSeekComplete()) {
mTask->UpdateSeekTargetTime();
auto time = mTask->mTarget.GetTime().ToMicroseconds();
--- a/dom/media/NextFrameSeekTask.cpp
+++ b/dom/media/NextFrameSeekTask.cpp
@@ -98,27 +98,16 @@ NextFrameSeekTask::Seek(const media::Tim
AssertOwnerThread();
RefPtr<SeekTaskPromise> promise = mSeekTaskPromise.Ensure(__func__);
return promise;
}
bool
-NextFrameSeekTask::NeedMoreVideo() const
-{
- AssertOwnerThread();
- // Need to request video when we have none and video queue is not finished.
- return mVideoQueue.GetSize() == 0 &&
- !mSeekedVideoData &&
- !mVideoQueue.IsFinished() &&
- !mIsVideoQueueFinished;
-}
-
-bool
NextFrameSeekTask::IsVideoRequestPending() const
{
AssertOwnerThread();
return mReader->IsRequestingVideoData() || mReader->IsWaitingVideoData();
}
void
NextFrameSeekTask::UpdateSeekTargetTime()
--- a/dom/media/NextFrameSeekTask.h
+++ b/dom/media/NextFrameSeekTask.h
@@ -49,18 +49,16 @@ public:
void HandleAudioWaited(MediaData::Type aType) override;
void HandleVideoWaited(MediaData::Type aType) override;
void HandleNotWaited(const WaitForDataRejectValue& aRejection) override;
~NextFrameSeekTask();
- bool NeedMoreVideo() const;
-
bool IsVideoRequestPending() const;
// Update the seek target's time before resolving this seek task, the updated
// time will be used in the MDSM::SeekCompleted() to update the MDSM's position.
void UpdateSeekTargetTime();
/*
* Data shared with MDSM.