зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1322799 part 11 - disconnect AccurateSeekingState and SeekTask; r=jwwang
MozReview-Commit-ID: LeMtvoNkVFD --HG-- extra : rebase_source : c4b64b26c19f3a016a053752e29f5a2a09e747a0
This commit is contained in:
Родитель
1bfa6a5e5d
Коммит
6c5c0bdd5f
|
@ -884,7 +884,8 @@ public:
|
||||||
|
|
||||||
void Exit() override
|
void Exit() override
|
||||||
{
|
{
|
||||||
SeekingState::Exit();
|
// Disconnect MediaDecoder.
|
||||||
|
mSeekJob.RejectIfExists(__func__);
|
||||||
|
|
||||||
// Disconnect MediaDecoderReaderWrapper.
|
// Disconnect MediaDecoderReaderWrapper.
|
||||||
mSeekRequest.DisconnectIfExists();
|
mSeekRequest.DisconnectIfExists();
|
||||||
|
@ -892,7 +893,7 @@ public:
|
||||||
|
|
||||||
void HandleAudioDecoded(MediaData* aAudio) override
|
void HandleAudioDecoded(MediaData* aAudio) override
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mSeekTaskRequest.Exists(), "Seek shouldn't be finished");
|
MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking, "Seek shouldn't be finished");
|
||||||
|
|
||||||
RefPtr<MediaData> audio(aAudio);
|
RefPtr<MediaData> audio(aAudio);
|
||||||
MOZ_ASSERT(audio);
|
MOZ_ASSERT(audio);
|
||||||
|
@ -919,7 +920,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
nsresult rv = DropAudioUpToSeekTarget(audio);
|
nsresult rv = DropAudioUpToSeekTarget(audio);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
mTask->RejectIfExist(rv, __func__);
|
OnSeekTaskRejected(rv);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -933,7 +934,7 @@ public:
|
||||||
|
|
||||||
void HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) override
|
void HandleVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStart) override
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mSeekTaskRequest.Exists(), "Seek shouldn't be finished");
|
MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking, "Seek shouldn't be finished");
|
||||||
|
|
||||||
RefPtr<MediaData> video(aVideo);
|
RefPtr<MediaData> video(aVideo);
|
||||||
MOZ_ASSERT(video);
|
MOZ_ASSERT(video);
|
||||||
|
@ -952,7 +953,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
nsresult rv = DropVideoUpToSeekTarget(video.get());
|
nsresult rv = DropVideoUpToSeekTarget(video.get());
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
mTask->RejectIfExist(rv, __func__);
|
OnSeekTaskRejected(rv);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -966,7 +967,7 @@ public:
|
||||||
|
|
||||||
void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) override
|
void HandleNotDecoded(MediaData::Type aType, const MediaResult& aError) override
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mSeekTaskRequest.Exists(), "Seek shouldn't be finished");
|
MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking, "Seek shouldn't be finished");
|
||||||
|
|
||||||
SSAMPLELOG("OnNotDecoded type=%d reason=%u", aType, aError.Code());
|
SSAMPLELOG("OnNotDecoded type=%d reason=%u", aType, aError.Code());
|
||||||
|
|
||||||
|
@ -1009,12 +1010,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a decode error, delegate to the generic error path.
|
// This is a decode error, delegate to the generic error path.
|
||||||
mTask->RejectIfExist(aError, __func__);
|
OnSeekTaskRejected(aError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleAudioWaited(MediaData::Type aType) override
|
void HandleAudioWaited(MediaData::Type aType) override
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mSeekTaskRequest.Exists(), "Seek shouldn't be finished");
|
MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking, "Seek shouldn't be finished");
|
||||||
|
|
||||||
// Ignore pending requests from video-only seek.
|
// Ignore pending requests from video-only seek.
|
||||||
if (mSeekJob.mTarget.IsVideoOnly()) {
|
if (mSeekJob.mTarget.IsVideoOnly()) {
|
||||||
|
@ -1025,14 +1026,14 @@ public:
|
||||||
|
|
||||||
void HandleVideoWaited(MediaData::Type aType) override
|
void HandleVideoWaited(MediaData::Type aType) override
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mSeekTaskRequest.Exists(), "Seek shouldn't be finished");
|
MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking, "Seek shouldn't be finished");
|
||||||
|
|
||||||
RequestVideoData();
|
RequestVideoData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleNotWaited(const WaitForDataRejectValue& aRejection) override
|
void HandleNotWaited(const WaitForDataRejectValue& aRejection) override
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mSeekTaskRequest.Exists(), "Seek shouldn't be finished");
|
MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking, "Seek shouldn't be finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1041,12 +1042,6 @@ private:
|
||||||
mCurrentTimeBeforeSeek = TimeUnit::FromMicroseconds(mMaster->GetMediaTime());
|
mCurrentTimeBeforeSeek = TimeUnit::FromMicroseconds(mMaster->GetMediaTime());
|
||||||
mDoneAudioSeeking = !Info().HasAudio() || mSeekJob.mTarget.IsVideoOnly();
|
mDoneAudioSeeking = !Info().HasAudio() || mSeekJob.mTarget.IsVideoOnly();
|
||||||
mDoneVideoSeeking = !Info().HasVideo();
|
mDoneVideoSeeking = !Info().HasVideo();
|
||||||
|
|
||||||
mSeekTask = new AccurateSeekTask(
|
|
||||||
mMaster->mDecoderID, OwnerThread(), Reader(), mSeekJob.mTarget,
|
|
||||||
Info(), mMaster->Duration(), mMaster->GetMediaTime());
|
|
||||||
|
|
||||||
mTask = static_cast<AccurateSeekTask*>(mSeekTask.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetMDSM() override
|
void ResetMDSM() override
|
||||||
|
@ -1069,16 +1064,6 @@ private:
|
||||||
[this] (nsresult aResult) {
|
[this] (nsresult aResult) {
|
||||||
OnSeekRejected(aResult);
|
OnSeekRejected(aResult);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Let SeekTask handle the following operations once the demuxer seeking is done.
|
|
||||||
mSeekTaskRequest.Begin(mSeekTask->Seek(mMaster->Duration())
|
|
||||||
->Then(OwnerThread(), __func__,
|
|
||||||
[this] (const SeekTaskResolveValue& aValue) {
|
|
||||||
OnSeekTaskResolved(aValue);
|
|
||||||
},
|
|
||||||
[this] (const SeekTaskRejectValue& aValue) {
|
|
||||||
OnSeekTaskRejected(aValue);
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t CalculateNewCurrentTime() const override
|
int64_t CalculateNewCurrentTime() const override
|
||||||
|
@ -1130,7 +1115,7 @@ private:
|
||||||
mSeekRequest.Complete();
|
mSeekRequest.Complete();
|
||||||
|
|
||||||
MOZ_ASSERT(NS_FAILED(aResult), "Cancels should also disconnect mSeekRequest");
|
MOZ_ASSERT(NS_FAILED(aResult), "Cancels should also disconnect mSeekRequest");
|
||||||
mTask->RejectIfExist(aResult, __func__);
|
OnSeekTaskRejected(aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestAudioData()
|
void RequestAudioData()
|
||||||
|
@ -1279,50 +1264,46 @@ private:
|
||||||
void MaybeFinishSeek()
|
void MaybeFinishSeek()
|
||||||
{
|
{
|
||||||
if (mDoneAudioSeeking && mDoneVideoSeeking) {
|
if (mDoneAudioSeeking && mDoneVideoSeeking) {
|
||||||
mTask->Resolve(__func__); // Call to MDSM::SeekCompleted();
|
OnSeekTaskResolved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnSeekTaskResolved(const SeekTaskResolveValue& aValue)
|
void OnSeekTaskResolved()
|
||||||
{
|
{
|
||||||
mSeekTaskRequest.Complete();
|
if (mSeekedAudioData) {
|
||||||
|
mMaster->Push(mSeekedAudioData);
|
||||||
if (aValue.mSeekedAudioData) {
|
|
||||||
mMaster->Push(aValue.mSeekedAudioData);
|
|
||||||
mMaster->mDecodedAudioEndTime = std::max(
|
mMaster->mDecodedAudioEndTime = std::max(
|
||||||
aValue.mSeekedAudioData->GetEndTime(), mMaster->mDecodedAudioEndTime);
|
mSeekedAudioData->GetEndTime(), mMaster->mDecodedAudioEndTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aValue.mSeekedVideoData) {
|
if (mSeekedVideoData) {
|
||||||
mMaster->Push(aValue.mSeekedVideoData);
|
mMaster->Push(mSeekedVideoData);
|
||||||
mMaster->mDecodedVideoEndTime = std::max(
|
mMaster->mDecodedVideoEndTime = std::max(
|
||||||
aValue.mSeekedVideoData->GetEndTime(), mMaster->mDecodedVideoEndTime);
|
mSeekedVideoData->GetEndTime(), mMaster->mDecodedVideoEndTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aValue.mIsAudioQueueFinished) {
|
if (mIsAudioQueueFinished) {
|
||||||
AudioQueue().Finish();
|
AudioQueue().Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aValue.mIsVideoQueueFinished) {
|
if (mIsVideoQueueFinished) {
|
||||||
VideoQueue().Finish();
|
VideoQueue().Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
SeekCompleted();
|
SeekCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnSeekTaskRejected(const SeekTaskRejectValue& aValue)
|
void OnSeekTaskRejected(MediaResult aError)
|
||||||
{
|
{
|
||||||
mSeekTaskRequest.Complete();
|
if (mIsAudioQueueFinished) {
|
||||||
|
|
||||||
if (aValue.mIsAudioQueueFinished) {
|
|
||||||
AudioQueue().Finish();
|
AudioQueue().Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aValue.mIsVideoQueueFinished) {
|
if (mIsVideoQueueFinished) {
|
||||||
VideoQueue().Finish();
|
VideoQueue().Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
mMaster->DecodeError(aValue.mError);
|
mMaster->DecodeError(aError);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче