Bug 1322799 part 6 - move AccurateSeekTask::AdjustFastSeekIfNeeded(); r?jwwang
MozReview-Commit-ID: LwvRNpfbrFI
--- a/dom/media/AccurateSeekTask.cpp
+++ b/dom/media/AccurateSeekTask.cpp
@@ -254,26 +254,9 @@ void
AccurateSeekTask::MaybeFinishSeek()
{
AssertOwnerThread();
if (mDoneAudioSeeking && mDoneVideoSeeking) {
Resolve(__func__); // Call to MDSM::SeekCompleted();
}
}
-void
-AccurateSeekTask::AdjustFastSeekIfNeeded(MediaData* aSample)
-{
- AssertOwnerThread();
- if (mTarget.IsFast() &&
- mTarget.GetTime() > mCurrentTimeBeforeSeek &&
- aSample->mTime < mCurrentTimeBeforeSeek.ToMicroseconds()) {
- // We are doing a fastSeek, but we ended up *before* the previous
- // playback position. This is surprising UX, so switch to an accurate
- // seek and decode to the seek target. This is not conformant to the
- // spec, fastSeek should always be fast, but until we get the time to
- // change all Readers to seek to the keyframe after the currentTime
- // in this case, we'll just decode forward. Bug 1026330.
- mTarget.SetType(SeekTarget::Accurate);
- }
-}
-
} // namespace mozilla
--- a/dom/media/AccurateSeekTask.h
+++ b/dom/media/AccurateSeekTask.h
@@ -44,18 +44,16 @@ public:
~AccurateSeekTask();
nsresult DropAudioUpToSeekTarget(MediaData* aSample);
nsresult DropVideoUpToSeekTarget(MediaData* aSample);
void MaybeFinishSeek();
- void AdjustFastSeekIfNeeded(MediaData* aSample);
-
/*
* Internal state.
*/
const media::TimeUnit mCurrentTimeBeforeSeek;
const uint32_t mAudioRate; // Audio sample rate.
bool mDoneAudioSeeking;
bool mDoneVideoSeeking;
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -905,17 +905,17 @@ public:
// Video-only seek doesn't reset audio decoder. There might be pending audio
// requests when AccurateSeekTask::Seek() begins. We will just store the data
// without checking |mDiscontinuity| or calling DropAudioUpToSeekTarget().
if (mTask->mTarget.IsVideoOnly()) {
mTask->mSeekedAudioData = audio.forget();
return;
}
- mTask->AdjustFastSeekIfNeeded(audio);
+ AdjustFastSeekIfNeeded(audio);
if (mTask->mTarget.IsFast()) {
// Non-precise seek; we can stop the seek at the first sample.
mTask->mSeekedAudioData = audio;
mTask->mDoneAudioSeeking = true;
} else {
nsresult rv = mTask->DropAudioUpToSeekTarget(audio);
if (NS_FAILED(rv)) {
@@ -938,17 +938,17 @@ public:
RefPtr<MediaData> video(aVideo);
MOZ_ASSERT(video);
// The MDSM::mDecodedVideoEndTime will be updated once the whole SeekTask is
// resolved.
SSAMPLELOG("HandleVideoDecoded [%lld,%lld]", video->mTime, video->GetEndTime());
- mTask->AdjustFastSeekIfNeeded(video);
+ AdjustFastSeekIfNeeded(video);
if (mTask->mTarget.IsFast()) {
// Non-precise seek. We can stop the seek at the first sample.
mTask->mSeekedVideoData = video;
mTask->mDoneVideoSeeking = true;
} else {
nsresult rv = mTask->DropVideoUpToSeekTarget(video.get());
if (NS_FAILED(rv)) {
@@ -1113,16 +1113,31 @@ private:
void RequestVideoData()
{
MOZ_ASSERT(!mTask->mDoneVideoSeeking);
MOZ_ASSERT(!Reader()->IsRequestingVideoData());
MOZ_ASSERT(!Reader()->IsWaitingVideoData());
Reader()->RequestVideoData(false, media::TimeUnit());
}
+ void AdjustFastSeekIfNeeded(MediaData* aSample)
+ {
+ if (mTask->mTarget.IsFast() &&
+ mTask->mTarget.GetTime() > mTask->mCurrentTimeBeforeSeek &&
+ aSample->mTime < mTask->mCurrentTimeBeforeSeek.ToMicroseconds()) {
+ // We are doing a fastSeek, but we ended up *before* the previous
+ // playback position. This is surprising UX, so switch to an accurate
+ // seek and decode to the seek target. This is not conformant to the
+ // spec, fastSeek should always be fast, but until we get the time to
+ // change all Readers to seek to the keyframe after the currentTime
+ // in this case, we'll just decode forward. Bug 1026330.
+ mTask->mTarget.SetType(SeekTarget::Accurate);
+ }
+ }
+
void OnSeekTaskResolved(const SeekTaskResolveValue& aValue)
{
mSeekTaskRequest.Complete();
if (aValue.mSeekedAudioData) {
mMaster->Push(aValue.mSeekedAudioData);
mMaster->mDecodedAudioEndTime = std::max(
aValue.mSeekedAudioData->GetEndTime(), mMaster->mDecodedAudioEndTime);