From d2f91da2bd7398467ee8477dc40f29c0d00c9435 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Fri, 1 Dec 2017 14:24:27 +0800 Subject: [PATCH] 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 --- dom/media/ChannelMediaDecoder.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dom/media/ChannelMediaDecoder.cpp b/dom/media/ChannelMediaDecoder.cpp index cf1497f9ad39..22b32ec8ae75 100644 --- a/dom/media/ChannelMediaDecoder.cpp +++ b/dom/media/ChannelMediaDecoder.cpp @@ -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) {