diff --git a/modules/pacing/paced_sender.cc b/modules/pacing/paced_sender.cc index 56eed92682..0a3d3c0b34 100644 --- a/modules/pacing/paced_sender.cc +++ b/modules/pacing/paced_sender.cc @@ -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() { diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc index 6a8e203758..5b7dda3640 100644 --- a/modules/pacing/pacing_controller.cc +++ b/modules/pacing/pacing_controller.cc @@ -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); } } }