Bug 1314884. Part 1 - move the calculation of seek target into DormantState::Enter() so we don't need to pass a SeekJob to the function. r=kaku

MozReview-Commit-ID: FyFp509dxwl

--HG--
extra : rebase_source : 4d6d229de4871d11b690b28b5b96463cc3b27973
extra : source : 9d718f819b6a79b67b0125972b8419b99021b75f
This commit is contained in:
JW Wang 2016-11-03 14:54:40 +08:00
Родитель b178d68440
Коммит 314f08257b
1 изменённых файлов: 13 добавлений и 12 удалений

Просмотреть файл

@ -403,12 +403,22 @@ class MediaDecoderStateMachine::DormantState
public:
explicit DormantState(Master* aPtr) : StateObject(aPtr) {}
void Enter(SeekJob aPendingSeek)
void Enter()
{
mPendingSeek = Move(aPendingSeek);
if (mMaster->IsPlaying()) {
mMaster->StopPlayback();
}
// Calculate the position to seek to when exiting dormant.
auto t = mMaster->mMediaSink->IsStarted()
? mMaster->GetClock()
: mMaster->GetMediaTime();
mPendingSeek.mTarget = SeekTarget(
t, SeekTarget::Accurate, MediaDecoderEventVisibility::Suppressed);
// SeekJob asserts |mTarget.IsValid() == !mPromise.IsEmpty()| so we
// need to create the promise even it is not used at all.
RefPtr<MediaDecoder::SeekPromise> x = mPendingSeek.mPromise.Ensure(__func__);
mMaster->Reset();
mMaster->mReader->ReleaseResources();
}
@ -686,16 +696,7 @@ private:
void EnterDormant()
{
auto t = mMaster->mMediaSink->IsStarted()
? mMaster->GetClock()
: mMaster->GetMediaTime();
SeekJob seekJob;
seekJob.mTarget = SeekTarget(t, SeekTarget::Accurate,
MediaDecoderEventVisibility::Suppressed);
// SeekJob asserts |mTarget.IsValid() == !mPromise.IsEmpty()| so we
// need to create the promise even it is not used at all.
RefPtr<MediaDecoder::SeekPromise> unused = seekJob.mPromise.Ensure(__func__);
SetState<DormantState>(Move(seekJob));
SetState<DormantState>();
}
void StartDormantTimer()