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 <srte@webrtc.org>
Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24382}diff --git a/modules/congestion_controller/rtp/send_side_congestion_controller.cc b/modules/congestion_controller/rtp/send_side_congestion_controller.cc
index 5205940..661abb9 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 @@
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 @@
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::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(