From ea5f06f7e6b317debb3030fd3b73ca5926eec0dd Mon Sep 17 00:00:00 2001 From: tommi Date: Mon, 27 Feb 2017 05:41:24 -0800 Subject: [PATCH] Remove extra call to TimeUntilNextProcess from within Process. I noticed while profiling calls to TimeUntilNextProcess. It's benign, but the implementation seems to be done to accomodate the test rather than the other way around, so I'm making the test behave more like a ProcessThread would. BUG=None Review-Url: https://codereview.webrtc.org/2715133002 Cr-Commit-Position: refs/heads/master@{#16867} --- .../remote_bitrate_estimator_single_stream.cc | 13 +++++-------- .../remote_bitrate_estimator_unittest_helper.cc | 3 ++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc index 51d79cd9c2..094bf0d65b 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc +++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc @@ -143,9 +143,6 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket( } void RemoteBitrateEstimatorSingleStream::Process() { - if (TimeUntilNextProcess() > 0) { - return; - } { CriticalSectionScoped cs(crit_sect_.get()); UpdateEstimate(clock_->TimeInMilliseconds()); @@ -157,11 +154,10 @@ int64_t RemoteBitrateEstimatorSingleStream::TimeUntilNextProcess() { if (last_process_time_ < 0) { return 0; } - { - CriticalSectionScoped cs_(crit_sect_.get()); - return last_process_time_ + process_interval_ms_ - - clock_->TimeInMilliseconds(); - } + CriticalSectionScoped cs_(crit_sect_.get()); + RTC_DCHECK_GT(process_interval_ms_, 0); + return last_process_time_ + process_interval_ms_ - + clock_->TimeInMilliseconds(); } void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) { @@ -202,6 +198,7 @@ void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) { uint32_t target_bitrate = remote_rate->UpdateBandwidthEstimate(now_ms); if (remote_rate->ValidEstimate()) { process_interval_ms_ = remote_rate->GetFeedbackInterval(); + RTC_DCHECK_GT(process_interval_ms_, 0); std::vector ssrcs; GetSsrcs(&ssrcs); observer_->OnReceiveBitrateChanged(ssrcs, target_bitrate); diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc index b77550f121..fef4d8dfb2 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc +++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc @@ -270,7 +270,8 @@ bool RemoteBitrateEstimatorTest::GenerateAndProcessFrame(uint32_t ssrc, delete packet; packets.pop_front(); } - bitrate_estimator_->Process(); + if (bitrate_estimator_->TimeUntilNextProcess() <= 0) + bitrate_estimator_->Process(); clock_.AdvanceTimeMicroseconds(next_time_us - clock_.TimeInMicroseconds()); return overuse; }