Bug 1322800 part 6 - move NextFrameSeekTask::Is{Audio,Video}SeekComplete(); r?jwwang
MozReview-Commit-ID: D4grujhMgHt
--- 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;