diff --git a/audio/channel_send.cc b/audio/channel_send.cc index abdb9807d9..a8b93ccd2a 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -641,6 +641,7 @@ void ChannelSend::ModifyEncoder( } void ChannelSend::SetBitRate(int bitrate_bps, int64_t probing_interval_ms) { + rtc::CritScope lock(&bitrate_crit_section_); audio_coding_->ModifyEncoder([&](std::unique_ptr* encoder) { if (*encoder) { (*encoder)->OnReceivedUplinkBandwidth(bitrate_bps, probing_interval_ms); @@ -651,6 +652,7 @@ void ChannelSend::SetBitRate(int bitrate_bps, int64_t probing_interval_ms) { } int ChannelSend::GetBitRate() const { + rtc::CritScope lock(&bitrate_crit_section_); return configured_bitrate_bps_; } diff --git a/audio/channel_send.h b/audio/channel_send.h index 6fefd281d0..63e8d04e86 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -324,7 +324,9 @@ class ChannelSend rtc::scoped_refptr frame_encryptor_; // E2EE Frame Encryption Options webrtc::CryptoOptions crypto_options_; - int configured_bitrate_bps_ = 0; + + rtc::CriticalSection bitrate_crit_section_; + int configured_bitrate_bps_ RTC_GUARDED_BY(bitrate_crit_section_) = 0; }; } // namespace voe