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:
@ -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() {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user