Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Unified Diff: webrtc/call/bitrate_allocator.cc

Issue 2060403002: Add task queue to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@move_getpadding
Patch Set: Revert fix for asan, protect instead. Added destruction observer to frames in ViEEncoder tests. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/call/bitrate_allocator.cc
diff --git a/webrtc/call/bitrate_allocator.cc b/webrtc/call/bitrate_allocator.cc
index 7e6242210cff6c78845446a9b3f65b67dfce5fa5..e2b1977280a86c68da820d00ff815ba3fcb8523b 100644
--- a/webrtc/call/bitrate_allocator.cc
+++ b/webrtc/call/bitrate_allocator.cc
@@ -54,7 +54,9 @@ BitrateAllocator::BitrateAllocator(LimitObserver* limit_observer)
last_rtt_(0),
num_pause_events_(0),
clock_(Clock::GetRealTimeClock()),
- last_bwe_log_time_(0) {}
+ last_bwe_log_time_(0) {
+ thread_checker_.DetachFromThread();
+}
BitrateAllocator::~BitrateAllocator() {
RTC_LOGGED_HISTOGRAM_COUNTS_100("WebRTC.Call.NumberOfPauseEvents",
@@ -64,7 +66,7 @@ BitrateAllocator::~BitrateAllocator() {
void BitrateAllocator::OnNetworkChanged(uint32_t target_bitrate_bps,
uint8_t fraction_loss,
int64_t rtt) {
- rtc::CritScope lock(&crit_sect_);
+ RTC_DCHECK_RUN_ON(&thread_checker_);
last_bitrate_bps_ = target_bitrate_bps;
last_non_zero_bitrate_bps_ =
target_bitrate_bps > 0 ? target_bitrate_bps : last_non_zero_bitrate_bps_;
@@ -117,7 +119,7 @@ void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer,
uint32_t max_bitrate_bps,
uint32_t pad_up_bitrate_bps,
bool enforce_min_bitrate) {
- rtc::CritScope lock(&crit_sect_);
+ RTC_DCHECK_RUN_ON(&thread_checker_);
auto it = FindObserverConfig(observer);
// Update settings if the observer already exists, create a new one otherwise.
@@ -155,36 +157,33 @@ void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer,
}
void BitrateAllocator::UpdateAllocationLimits() {
+ RTC_DCHECK_RUN_ON(&thread_checker_);
uint32_t total_requested_padding_bitrate = 0;
uint32_t total_requested_min_bitrate = 0;
- {
- rtc::CritScope lock(&crit_sect_);
for (const auto& config : bitrate_observer_configs_) {
if (config.enforce_min_bitrate) {
total_requested_min_bitrate += config.min_bitrate_bps;
}
total_requested_padding_bitrate += config.pad_up_bitrate_bps;
}
- }
limit_observer_->OnAllocationLimitsChanged(total_requested_min_bitrate,
total_requested_padding_bitrate);
}
void BitrateAllocator::RemoveObserver(BitrateAllocatorObserver* observer) {
- {
- rtc::CritScope lock(&crit_sect_);
- auto it = FindObserverConfig(observer);
- if (it != bitrate_observer_configs_.end()) {
- bitrate_observer_configs_.erase(it);
+ RTC_DCHECK_RUN_ON(&thread_checker_);
+ auto it = FindObserverConfig(observer);
+ if (it != bitrate_observer_configs_.end()) {
+ bitrate_observer_configs_.erase(it);
}
- }
+
UpdateAllocationLimits();
}
int BitrateAllocator::GetStartBitrate(BitrateAllocatorObserver* observer) {
- rtc::CritScope lock(&crit_sect_);
+ RTC_DCHECK_RUN_ON(&thread_checker_);
const auto& it = FindObserverConfig(observer);
if (it == bitrate_observer_configs_.end()) {
// This observer hasn't been added yet, just give it its fair share.

Powered by Google App Engine
This is Rietveld 408576698