Bug 1322800 part 6 - move NextFrameSeekTask::Is{Audio,Video}SeekComplete(); r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Wed, 14 Dec 2016 15:10:25 +0800
changeset 450261 8032fb9b691df1eaba58d1b69ee8f44e56444236
parent 450260 3933568cc266355e16b50d6010158bd7931a2d19
child 450262 1a2a270a2e5bff764282a367cf970fb2d9a18452
child 450335 d2bd51bbeccd3ec59bbbb1ba7a417b72dd47985b
push id38817
push userbmo:kaku@mozilla.com
push dateFri, 16 Dec 2016 08:40:33 +0000
reviewersjwwang
bugs1322800
milestone53.0a1
Bug 1322800 part 6 - move NextFrameSeekTask::Is{Audio,Video}SeekComplete(); r?jwwang MozReview-Commit-ID: D4grujhMgHt
dom/media/MediaDecoderStateMachine.cpp
dom/media/NextFrameSeekTask.cpp
dom/media/NextFrameSeekTask.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1590,19 +1590,33 @@ private:
     mMaster->DecodeError(aValue.mError);
   }
 
   void RequestVideoData()
   {
     Reader()->RequestVideoData(false, media::TimeUnit());
   }
 
+  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();
+  }
+
   void MaybeFinishSeek()
   {
-    if (mTask->IsAudioSeekComplete() && mTask->IsVideoSeekComplete()) {
+    if (IsAudioSeekComplete() && IsVideoSeekComplete()) {
       mTask->UpdateSeekTargetTime();
 
       auto time = mTask->mTarget.GetTime().ToMicroseconds();
       DiscardFrames(mTask->mAudioQueue, [time] (int64_t aSampleTime) {
         return aSampleTime < time;
       });
 
       mTask->Resolve(__func__); // Call to MDSM::SeekCompleted();
--- a/dom/media/NextFrameSeekTask.cpp
+++ b/dom/media/NextFrameSeekTask.cpp
@@ -115,34 +115,16 @@ NextFrameSeekTask::NeedMoreVideo() const
 
 bool
 NextFrameSeekTask::IsVideoRequestPending() const
 {
   AssertOwnerThread();
   return mReader->IsRequestingVideoData() || mReader->IsWaitingVideoData();
 }
 
-bool
-NextFrameSeekTask::IsAudioSeekComplete() const
-{
-  AssertOwnerThread();
-  // Don't finish seek until there are no pending requests. Otherwise, we might
-  // lose audio samples for the promise is resolved asynchronously.
-  return !mReader->IsRequestingAudioData() && !mReader->IsWaitingAudioData();
-}
-
-bool
-NextFrameSeekTask::IsVideoSeekComplete() const
-{
-  AssertOwnerThread();
-  // Don't finish seek until there are no pending requests. Otherwise, we might
-  // lose video samples for the promise is resolved asynchronously.
-  return !IsVideoRequestPending() && !NeedMoreVideo();
-}
-
 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
@@ -53,20 +53,16 @@ public:
   void HandleNotWaited(const WaitForDataRejectValue& aRejection) override;
 
   ~NextFrameSeekTask();
 
   bool NeedMoreVideo() const;
 
   bool IsVideoRequestPending() const;
 
-  bool IsAudioSeekComplete() const;
-
-  bool IsVideoSeekComplete() 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;