Bug 1283718. Part 2 - fix the logic of IsVideoSeekComplete(). r=kaku draft
authorJW Wang <jwwang@mozilla.com>
Thu, 07 Jul 2016 11:23:11 +0800
changeset 386076 670e70671e5e2449371b270303d933b6c044d091
parent 386075 35ceb5ffd735878431764f34ea51892f82ed7ac8
child 386077 0532da9c0b61f4c36acb52f397683e4560dc9a6a
push id22615
push userjwwang@mozilla.com
push dateMon, 11 Jul 2016 03:16:53 +0000
reviewerskaku
bugs1283718
milestone50.0a1
Bug 1283718. Part 2 - fix the logic of IsVideoSeekComplete(). r=kaku MozReview-Commit-ID: L1u5P5hWMAA
dom/media/NextFrameSeekTask.cpp
dom/media/NextFrameSeekTask.h
--- a/dom/media/NextFrameSeekTask.cpp
+++ b/dom/media/NextFrameSeekTask.cpp
@@ -217,32 +217,49 @@ NextFrameSeekTask::RequestVideoData()
   AssertOwnerThread();
   SAMPLE_LOG("Queueing video task - queued=%i, decoder-queued=%o",
              !!mSeekedVideoData, mReader->SizeOfVideoQueueInFrames());
 
   mReader->RequestVideoData(false, media::TimeUnit());
 }
 
 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();
+}
+
+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()
+NextFrameSeekTask::IsVideoSeekComplete() const
 {
   AssertOwnerThread();
-  SAMPLE_LOG("IsVideoSeekComplete() curTarVal=%d vqFin=%d vqSz=%d",
-      mSeekJob.Exists(), mIsVideoQueueFinished, !!mSeekedVideoData);
-
-  return mIsVideoQueueFinished || mSeekedVideoData;
+  // 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::CheckIfSeekComplete()
 {
   AssertOwnerThread();
 
   const bool audioSeekComplete = IsAudioSeekComplete();
--- a/dom/media/NextFrameSeekTask.h
+++ b/dom/media/NextFrameSeekTask.h
@@ -46,19 +46,23 @@ private:
   bool IsVideoDecoding() const;
 
   void EnsureVideoDecodeTaskQueued();
 
   const char* VideoRequestStatus();
 
   void RequestVideoData();
 
+  bool NeedMoreVideo() const;
+
+  bool IsVideoRequestPending() const;
+
   bool IsAudioSeekComplete() const;
 
-  bool IsVideoSeekComplete();
+  bool IsVideoSeekComplete() const;
 
   void CheckIfSeekComplete();
 
   void OnAudioDecoded(MediaData* aAudioSample);
 
   void OnAudioNotDecoded(MediaDecoderReader::NotDecodedReason aReason);
 
   void OnVideoDecoded(MediaData* aVideoSample);