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}
This commit is contained in:
tommi 2017-02-27 05:41:24 -08:00 committed by Commit bot
parent c20b9950ef
commit ea5f06f7e6
2 changed files with 7 additions and 9 deletions

View File

@ -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<uint32_t> ssrcs;
GetSsrcs(&ssrcs);
observer_->OnReceiveBitrateChanged(ssrcs, target_bitrate);

View File

@ -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;
}