зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1322800 part 1 - move NextFrameSeekTask::Seek(); r=jwwang
MozReview-Commit-ID: IOai99XSetN --HG-- extra : rebase_source : a4b61ba24b987f119de020d4909b096c5c1ed118
This commit is contained in:
Родитель
7e66f6869f
Коммит
515f750816
|
@ -1330,6 +1330,23 @@ private:
|
|||
bool mIsVideoQueueFinished = false;
|
||||
};
|
||||
|
||||
/*
|
||||
* Remove samples from the queue until aCompare() returns false.
|
||||
* aCompare A function object with the signature bool(int64_t) which returns
|
||||
* true for samples that should be removed.
|
||||
*/
|
||||
template <typename Function> static void
|
||||
DiscardFrames(MediaQueue<MediaData>& aQueue, const Function& aCompare)
|
||||
{
|
||||
while(aQueue.GetSize() > 0) {
|
||||
if (aCompare(aQueue.PeekFront()->mTime)) {
|
||||
RefPtr<MediaData> releaseMe = aQueue.PopFront();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
class MediaDecoderStateMachine::NextFrameSeekingState
|
||||
: public MediaDecoderStateMachine::SeekingState
|
||||
{
|
||||
|
@ -1352,6 +1369,8 @@ private:
|
|||
mMaster->mDecoderID, OwnerThread(), Reader(), mSeekJob.mTarget,
|
||||
Info(), mMaster->Duration(),mMaster->GetMediaTime(),
|
||||
AudioQueue(), VideoQueue());
|
||||
|
||||
mTask = static_cast<NextFrameSeekTask*>(mSeekTask.get());
|
||||
}
|
||||
|
||||
void ResetMDSM() override
|
||||
|
@ -1361,6 +1380,11 @@ private:
|
|||
|
||||
void DoSeek() override
|
||||
{
|
||||
auto currentTime = mTask->mCurrentTime;
|
||||
DiscardFrames(mTask->mVideoQueue, [currentTime] (int64_t aSampleTime) {
|
||||
return aSampleTime <= currentTime;
|
||||
});
|
||||
|
||||
mSeekTaskRequest.Begin(mSeekTask->Seek(mMaster->Duration())
|
||||
->Then(OwnerThread(), __func__,
|
||||
[this] (const SeekTaskResolveValue& aValue) {
|
||||
|
@ -1369,6 +1393,11 @@ private:
|
|||
[this] (const SeekTaskRejectValue& aValue) {
|
||||
OnSeekTaskRejected(aValue);
|
||||
}));
|
||||
|
||||
if (!mTask->IsVideoRequestPending() && mTask->NeedMoreVideo()) {
|
||||
mTask->RequestVideoData();
|
||||
}
|
||||
mTask->MaybeFinishSeek(); // Might resolve mSeekTaskPromise and modify audio queue.
|
||||
}
|
||||
|
||||
int64_t CalculateNewCurrentTime() const override
|
||||
|
@ -1418,6 +1447,9 @@ private:
|
|||
mMaster->DecodeError(aValue.mError);
|
||||
}
|
||||
|
||||
// For refactoring only, will be removed later.
|
||||
RefPtr<NextFrameSeekTask> mTask;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -235,16 +235,8 @@ NextFrameSeekTask::Seek(const media::TimeUnit&)
|
|||
{
|
||||
AssertOwnerThread();
|
||||
|
||||
auto currentTime = mCurrentTime;
|
||||
DiscardFrames(mVideoQueue, [currentTime] (int64_t aSampleTime) {
|
||||
return aSampleTime <= currentTime;
|
||||
});
|
||||
|
||||
RefPtr<SeekTaskPromise> promise = mSeekTaskPromise.Ensure(__func__);
|
||||
if (!IsVideoRequestPending() && NeedMoreVideo()) {
|
||||
RequestVideoData();
|
||||
}
|
||||
MaybeFinishSeek(); // Might resolve mSeekTaskPromise and modify audio queue.
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче