Bug 1283718. Part 3 - replace some code with new helpers. r=kaku
MozReview-Commit-ID: 3fHSEoxdh9u
--- a/dom/media/NextFrameSeekTask.cpp
+++ b/dom/media/NextFrameSeekTask.cpp
@@ -145,32 +145,20 @@ DropAllMediaDataBeforeCurrentPosition(Me
RefPtr<NextFrameSeekTask::SeekTaskPromise>
NextFrameSeekTask::Seek(const media::TimeUnit&)
{
AssertOwnerThread();
DropAllMediaDataBeforeCurrentPosition(mAudioQueue, mVideoQueue,
mCurrentTimeBeforeSeek);
- // While creating this seek task object, MDSM might had already ask the
- // wrapper to decode a media sample or the MDSM is waiting a media data.
- // If so, we cannot resolve the SeekTaskPromise immediately because there is
- // a latency of running the resolving runnable. Instead, if there is a pending
- // media request, we wait for it.
- bool hasPendingRequests = mReader->IsRequestingAudioData() ||
- mReader->IsWaitingAudioData() ||
- mReader->IsRequestingVideoData() ||
- mReader->IsWaitingVideoData();
-
- bool needMoreVideo = mVideoQueue.GetSize() == 0 && !mVideoQueue.IsFinished();
-
- if (needMoreVideo) {
+ if (NeedMoreVideo()) {
EnsureVideoDecodeTaskQueued();
}
- if (hasPendingRequests || needMoreVideo) {
+ if (!IsAudioSeekComplete() || !IsVideoSeekComplete()) {
return mSeekTaskPromise.Ensure(__func__);
}
UpdateSeekTargetTime();
SeekTaskResolveValue val = {}; // Zero-initialize data members.
return SeekTask::SeekTaskPromise::CreateAndResolve(val, __func__);
}
@@ -183,19 +171,17 @@ NextFrameSeekTask::IsVideoDecoding() con
void
NextFrameSeekTask::EnsureVideoDecodeTaskQueued()
{
AssertOwnerThread();
SAMPLE_LOG("EnsureVideoDecodeTaskQueued isDecoding=%d status=%s",
IsVideoDecoding(), VideoRequestStatus());
- if (!IsVideoDecoding() ||
- mReader->IsRequestingVideoData() ||
- mReader->IsWaitingVideoData()) {
+ if (!IsVideoDecoding() || IsVideoRequestPending()) {
return;
}
RequestVideoData();
}
const char*
NextFrameSeekTask::VideoRequestStatus()