Bug 1420608. P1 - don't switch off blank decoder when seeking begins. r=gerald

When looping videos in a background tab, SeekingState::Enter() will switch off
blank decoder and then DecodingState::Enter() will switch it on again. It is a
waste of CPU cycles when the tab never goes to the foreground. The overhread is
even more significant when looping short files.

We should resume video decoding only when necessary that is we check in
DecodingState::Enter() to see if mVideoDecodeSuspended matches mVideoDecodeMode.

MozReview-Commit-ID: 54vq7mEjWQf

--HG--
extra : rebase_source : ce04310d06df2effd65d8c301e07c7fef01bdbd1
extra : intermediate-source : 83dff897174fb440e5da24843186ff9fd39d15c9
extra : source : d0834777c96255e15dc44d1865bd354ab67ec8fe
This commit is contained in:
JW Wang 2017-12-07 11:38:23 +08:00
Родитель 0e4b69db0c
Коммит 9d9ec003d1
1 изменённых файлов: 11 добавлений и 11 удалений

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

@ -833,15 +833,6 @@ public:
mSeekJob = Move(aSeekJob);
mVisibility = aVisibility;
// Always switch off the blank decoder otherwise we might become visible
// in the middle of seeking and won't have a valid video frame to show
// when seek is done.
if (mMaster->mVideoDecodeSuspended) {
mMaster->mVideoDecodeSuspended = false;
mMaster->mOnPlaybackEvent.Notify(MediaPlaybackEvent::ExitVideoSuspend);
Reader()->SetVideoBlankDecode(false);
}
// Suppressed visibility comes from two cases: (1) leaving dormant state,
// and (2) resuming suspended video decoder. We want both cases to be
// transparent to the user. So we only notify the change when the seek
@ -884,8 +875,7 @@ public:
void HandleResumeVideoDecoding(const TimeUnit&) override
{
// We set mVideoDecodeSuspended to false in Enter().
MOZ_ASSERT(false, "Shouldn't have suspended video decoding.");
// Do nothing. We will resume video decoding in the decoding state.
}
protected:
@ -2116,6 +2106,10 @@ StateObject::HandleResumeVideoDecoding(const TimeUnit& aTarget)
{
MOZ_ASSERT(mMaster->mVideoDecodeSuspended);
mMaster->mVideoDecodeSuspended = false;
mMaster->mOnPlaybackEvent.Notify(MediaPlaybackEvent::ExitVideoSuspend);
Reader()->SetVideoBlankDecode(false);
// Start counting recovery time from right now.
TimeStamp start = TimeStamp::Now();
@ -2278,6 +2272,12 @@ DecodingState::Enter()
{
MOZ_ASSERT(mMaster->mSentFirstFrameLoadedEvent);
if (mMaster->mVideoDecodeSuspended &&
mMaster->mVideoDecodeMode == VideoDecodeMode::Normal) {
StateObject::HandleResumeVideoDecoding(mMaster->GetMediaTime());
return;
}
if (mMaster->mVideoDecodeMode == VideoDecodeMode::Suspend &&
!mMaster->mVideoDecodeSuspendTimer.IsScheduled() &&
!mMaster->mVideoDecodeSuspended) {