Bug 1283718. Part 2 - fix the logic of IsVideoSeekComplete(). r=kaku
MozReview-Commit-ID: L1u5P5hWMAA
--- 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);