From 4932aa185cc5320f05174a10501394b11df63c2d Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Mon, 6 Aug 2018 16:01:16 +0200 Subject: [PATCH] Avoids posting tasks in congestion controller. This CL makes calls to send side congestion controller that originates from the task queue execute directly rather than posting a task. This ensures that side effects are applied by the time the call returns. This reduces the risk that the task queue version of the congestion controller introduces races that does not exist in the process thread based version. Bug: webrtc:9586 Change-Id: I82de032dc971c791a0f86d20ccbd47cbb09eba4b Reviewed-on: https://webrtc-review.googlesource.com/85360 Commit-Queue: Sebastian Jansson Reviewed-by: Christoffer Rodbro Cr-Commit-Position: refs/heads/master@{#24382} --- .../rtp/send_side_congestion_controller.cc | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/modules/congestion_controller/rtp/send_side_congestion_controller.cc b/modules/congestion_controller/rtp/send_side_congestion_controller.cc index 5205940de1..661abb99f3 100644 --- a/modules/congestion_controller/rtp/send_side_congestion_controller.cc +++ b/modules/congestion_controller/rtp/send_side_congestion_controller.cc @@ -461,15 +461,12 @@ void SendSideCongestionController::SetAllocatedSendBitrateLimits( int64_t min_send_bitrate_bps, int64_t max_padding_bitrate_bps, int64_t max_total_bitrate_bps) { - task_queue_->PostTask([this, min_send_bitrate_bps, max_padding_bitrate_bps, - max_total_bitrate_bps]() { - RTC_DCHECK_RUN_ON(task_queue_); - streams_config_.min_pacing_rate = DataRate::bps(min_send_bitrate_bps); - streams_config_.max_padding_rate = DataRate::bps(max_padding_bitrate_bps); - streams_config_.max_total_allocated_bitrate = - DataRate::bps(max_total_bitrate_bps); - UpdateStreamsConfig(); - }); + RTC_DCHECK_RUN_ON(task_queue_); + streams_config_.min_pacing_rate = DataRate::bps(min_send_bitrate_bps); + streams_config_.max_padding_rate = DataRate::bps(max_padding_bitrate_bps); + streams_config_.max_total_allocated_bitrate = + DataRate::bps(max_total_bitrate_bps); + UpdateStreamsConfig(); } // TODO(holmer): Split this up and use SetBweBitrates in combination with @@ -529,11 +526,9 @@ RtcpBandwidthObserver* SendSideCongestionController::GetBandwidthObserver() { void SendSideCongestionController::SetPerPacketFeedbackAvailable( bool available) { - task_queue_->PostTask([this, available]() { - RTC_DCHECK_RUN_ON(task_queue_); - packet_feedback_available_ = available; - MaybeRecreateControllers(); - }); + RTC_DCHECK_RUN_ON(task_queue_); + packet_feedback_available_ = available; + MaybeRecreateControllers(); } void SendSideCongestionController::EnablePeriodicAlrProbing(bool enable) { @@ -741,11 +736,9 @@ void SendSideCongestionController::WaitOnTasksForTest() { } void SendSideCongestionController::SetPacingFactor(float pacing_factor) { - task_queue_->PostTask([this, pacing_factor]() { - RTC_DCHECK_RUN_ON(task_queue_); - streams_config_.pacing_factor = pacing_factor; - UpdateStreamsConfig(); - }); + RTC_DCHECK_RUN_ON(task_queue_); + streams_config_.pacing_factor = pacing_factor; + UpdateStreamsConfig(); } void SendSideCongestionController::SetAllocatedBitrateWithoutFeedback(