Bug 1331070 - delay seek request until decoding first frames for non-MSE media. r=kaku

See see bug 1321198 comment 17. This is a workaround to alleviate the issue
which seems to happen on win8 x64 opt only.

MozReview-Commit-ID: Lr4viEjuFkC

--HG--
extra : rebase_source : 99895cf6f6f13d5f4d698f76db7acda15d8cee77
This commit is contained in:
JW Wang 2017-02-08 18:15:28 +08:00
Родитель 8bf0d34e6a
Коммит 553e846993
4 изменённых файлов: 34 добавлений и 1 удалений

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

@ -242,6 +242,9 @@ public:
// Return true if the decoder has reached the end of playback.
bool IsEnded() const;
// True if we are playing a MediaSource object.
virtual bool IsMSE() const { return false; }
// Return true if the MediaDecoderOwner's error attribute is not null.
// Must be called before Shutdown().
bool OwnerHasError() const;

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

@ -521,6 +521,13 @@ public:
void Enter();
void Exit() override
{
// mPendingSeek is either moved in MaybeFinishDecodeFirstFrame()
// or should be rejected here before transition to SHUTDOWN.
mPendingSeek.RejectIfExists(__func__);
}
State GetState() const override
{
return DECODER_STATE_DECODING_FIRSTFRAME;
@ -592,10 +599,24 @@ public:
MOZ_ASSERT(false, "Shouldn't have suspended video decoding.");
}
RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override
{
if (mMaster->mIsMSE) {
return StateObject::HandleSeek(aTarget);
}
// Delay seek request until decoding first frames for non-MSE media.
SLOG("Not Enough Data to seek at this stage, queuing seek");
mPendingSeek.RejectIfExists(__func__);
mPendingSeek.mTarget.emplace(aTarget);
return mPendingSeek.mPromise.Ensure(__func__);
}
private:
// Notify FirstFrameLoaded if having decoded first frames and
// transition to SEEKING if there is any pending seek, or DECODING otherwise.
void MaybeFinishDecodeFirstFrame();
SeekJob mPendingSeek;
};
/**
@ -2099,7 +2120,11 @@ DecodingFirstFrameState::MaybeFinishDecodeFirstFrame()
}
mMaster->FinishDecodeFirstFrame();
SetState<DecodingState>();
if (mPendingSeek.Exists()) {
SetSeekingState(Move(mPendingSeek), EventVisibility::Observable);
} else {
SetState<DecodingState>();
}
}
void
@ -2547,6 +2572,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
mVideoDecodeSuspendTimer(mTaskQueue),
mOutputStreamManager(new OutputStreamManager()),
mResource(aDecoder->GetResource()),
mIsMSE(aDecoder->IsMSE()),
INIT_MIRROR(mBuffered, TimeIntervals()),
INIT_MIRROR(mEstimatedDuration, NullableTimeUnit()),
INIT_MIRROR(mExplicitDuration, Maybe<double>()),

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

@ -693,6 +693,8 @@ private:
RefPtr<CDMProxy> mCDMProxy;
MozPromiseRequestHolder<MediaDecoder::CDMProxyPromise> mCDMProxyPromise;
const bool mIsMSE;
private:
// The buffered range. Mirrored from the decoder thread.
Mirror<media::TimeIntervals> mBuffered;

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

@ -76,6 +76,8 @@ public:
MediaEventSource<void>* WaitingForKeyEvent() override;
bool IsMSE() const override { return true; }
private:
void DoSetMediaSourceDuration(double aDuration);
media::TimeInterval ClampIntervalToEnd(const media::TimeInterval& aInterval);