Bug 1283718. Part 3 - replace some code with new helpers. r=kaku draft
authorJW Wang <jwwang@mozilla.com>
Thu, 07 Jul 2016 11:32:27 +0800
changeset 386077 0532da9c0b61f4c36acb52f397683e4560dc9a6a
parent 386076 670e70671e5e2449371b270303d933b6c044d091
child 386078 404b594b91473fecf2d445e402685ce080ae55aa
push id22615
push userjwwang@mozilla.com
push dateMon, 11 Jul 2016 03:16:53 +0000
reviewerskaku
bugs1283718
milestone50.0a1
Bug 1283718. Part 3 - replace some code with new helpers. r=kaku MozReview-Commit-ID: 3fHSEoxdh9u
dom/media/NextFrameSeekTask.cpp
--- 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()