Bug 1322800 part 8 - move NextFrameSeekTask::IsVideoRequestPending(); r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Wed, 14 Dec 2016 15:18:49 +0800
changeset 450336 b088252c9e09428294af891c6d18361286328d92
parent 450335 d2bd51bbeccd3ec59bbbb1ba7a417b72dd47985b
child 450337 a9116197ff7686cac2230c1fb31a0d6d4b5389cb
push id38836
push userbmo:kaku@mozilla.com
push dateFri, 16 Dec 2016 10:40:27 +0000
reviewersjwwang
bugs1322800
milestone53.0a1
Bug 1322800 part 8 - move NextFrameSeekTask::IsVideoRequestPending(); r?jwwang MozReview-Commit-ID: 9MEHVQUt7T0
dom/media/MediaDecoderStateMachine.cpp
dom/media/NextFrameSeekTask.cpp
dom/media/NextFrameSeekTask.h
--- 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() && NeedMoreVideo()) {
+    if (!IsVideoRequestPending() && NeedMoreVideo()) {
       RequestVideoData();
     }
     MaybeFinishSeek(); // Might resolve mSeekTaskPromise and modify audio queue.
   }
 
   void HandleAudioDecoded(MediaData* aAudio) override
   {
     MOZ_ASSERT(aAudio);
@@ -1599,28 +1599,33 @@ private:
   {
     // 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 IsVideoRequestPending() const
+  {
+    return Reader()->IsRequestingVideoData() || Reader()->IsWaitingVideoData();
+  }
+
   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() && !NeedMoreVideo();
+    return !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
@@ -97,23 +97,16 @@ NextFrameSeekTask::Seek(const media::Tim
 {
   AssertOwnerThread();
 
   RefPtr<SeekTaskPromise> promise = mSeekTaskPromise.Ensure(__func__);
 
   return promise;
 }
 
-bool
-NextFrameSeekTask::IsVideoRequestPending() const
-{
-  AssertOwnerThread();
-  return mReader->IsRequestingVideoData() || mReader->IsWaitingVideoData();
-}
-
 void
 NextFrameSeekTask::UpdateSeekTargetTime()
 {
   AssertOwnerThread();
 
   RefPtr<MediaData> data = mVideoQueue.PeekFront();
   if (data) {
     mTarget.SetTime(TimeUnit::FromMicroseconds(data->mTime));
--- 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 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.
    */
   MediaQueue<MediaData>& mAudioQueue;