Bug 1422677. P1 - move the call to ComputePlaybackRate() out of UpdatePlaybackRate(). r=bechen,gerald

We want to remove the side effect of ComputePlaybackRate(). Anyone who wants
the side effect (updating mPlaybackBytesPerSecond/mPlaybackRateReliable)
should call it explicitly.

MozReview-Commit-ID: 8oHvCl5pewz

--HG--
extra : rebase_source : 3ee54ea32d2d2d7185d9a65c6658a3e700f1fb71
This commit is contained in:
JW Wang 2017-12-01 14:24:27 +08:00
Родитель 834586be68
Коммит d2f91da2bd
1 изменённых файлов: 3 добавлений и 1 удалений

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

@ -274,6 +274,7 @@ ChannelMediaDecoder::NotifyDownloadEnded(nsresult aStatus)
MediaDecoderOwner* owner = GetOwner();
if (NS_SUCCEEDED(aStatus) || aStatus == NS_BASE_STREAM_CLOSED) {
ComputePlaybackRate();
UpdatePlaybackRate();
owner->DownloadSuspended();
// NotifySuspendedStatusChanged will tell the element that download
@ -339,6 +340,7 @@ ChannelMediaDecoder::DurationChanged()
AbstractThread::AutoEnter context(AbstractMainThread());
MediaDecoder::DurationChanged();
// Duration has changed so we should recompute playback rate
ComputePlaybackRate();
UpdatePlaybackRate();
}
@ -349,6 +351,7 @@ ChannelMediaDecoder::DownloadProgressed()
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
AbstractThread::AutoEnter context(AbstractMainThread());
GetOwner()->DownloadProgressed();
ComputePlaybackRate();
UpdatePlaybackRate();
mResource->ThrottleReadahead(ShouldThrottleDownload());
}
@ -377,7 +380,6 @@ ChannelMediaDecoder::UpdatePlaybackRate()
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mResource);
ComputePlaybackRate();
uint32_t rate = mPlaybackBytesPerSecond;
if (mPlaybackRateReliable) {