Account for rounding errors in dyanmic pacing mode.

Keeps behavior for old periodic processing.
Rounding sleep time reduced chance for small bursts of busy-looping when
time approaches 0.
Also fixes a DCHECK which may trigger if there are rounding errors in
the timing.

Bug: webrtc:10809
Change-Id: Iba8450f906fd6ab3b1da97e04507b16ac6bbde3f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160000
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29841}
This commit is contained in:
Erik Språng
2019-11-19 11:24:31 +01:00
committed by Commit Bot
parent 83b286202b
commit 3b1a8bb00c
2 changed files with 9 additions and 4 deletions

View File

@ -150,8 +150,12 @@ int64_t PacedSender::TimeUntilNextProcess() {
rtc::CritScope cs(&critsect_);
Timestamp next_send_time = pacing_controller_.NextSendTime();
return std::max(TimeDelta::Zero(), next_send_time - clock_->CurrentTime())
.ms();
TimeDelta sleep_time =
std::max(TimeDelta::Zero(), next_send_time - clock_->CurrentTime());
if (process_mode_ == PacingController::ProcessMode::kDynamic) {
return sleep_time.RoundTo(TimeDelta::ms(1)).ms();
}
return sleep_time.ms();
}
void PacedSender::Process() {

View File

@ -586,8 +586,9 @@ RoundRobinPacketQueue::QueuedPacket* PacingController::GetPendingPacket(
}
} else {
// In dynamic mode we should never try get a non-probe packet until
// the media debt is actually zero.
RTC_DCHECK(media_debt_.IsZero());
// the media debt is actually zero. Since there can be rounding errors,
// allow some discrepancy.
RTC_DCHECK_LE(media_debt_, media_rate_ * kMinSleepTime);
}
}
}