Replace runtime thread checks by compile-time checks.
For all private methods of BitrateAllocator.
Bug: None
Change-Id: I9943d3ee4cdfe00a842e7c2258f57d88b96c4dda
Reviewed-on: https://webrtc-review.googlesource.com/72860
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23052}
diff --git a/call/bitrate_allocator.cc b/call/bitrate_allocator.cc
index a300f6d..7227b8f 100644
--- a/call/bitrate_allocator.cc
+++ b/call/bitrate_allocator.cc
@@ -188,7 +188,6 @@
}
void BitrateAllocator::UpdateAllocationLimits() {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
uint32_t total_requested_padding_bitrate = 0;
uint32_t total_requested_min_bitrate = 0;
uint32_t total_requested_max_bitrate = 0;
@@ -267,7 +266,6 @@
BitrateAllocator::ObserverConfigs::iterator
BitrateAllocator::FindObserverConfig(const BitrateAllocatorObserver* observer) {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
for (auto it = bitrate_observer_configs_.begin();
it != bitrate_observer_configs_.end(); ++it) {
if (it->observer == observer)
@@ -278,7 +276,6 @@
BitrateAllocator::ObserverAllocation BitrateAllocator::AllocateBitrates(
uint32_t bitrate) {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
if (bitrate_observer_configs_.empty())
return ObserverAllocation();
@@ -327,7 +324,6 @@
}
BitrateAllocator::ObserverAllocation BitrateAllocator::ZeroRateAllocation() {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
ObserverAllocation allocation;
for (const auto& observer_config : bitrate_observer_configs_)
allocation[observer_config.observer] = 0;
@@ -336,7 +332,6 @@
BitrateAllocator::ObserverAllocation BitrateAllocator::LowRateAllocation(
uint32_t bitrate) {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
ObserverAllocation allocation;
// Start by allocating bitrate to observers enforcing a min bitrate, hence
// remaining_bitrate might turn negative.
@@ -398,7 +393,6 @@
BitrateAllocator::ObserverAllocation BitrateAllocator::NormalRateAllocation(
uint32_t bitrate,
uint32_t sum_min_bitrates) {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
ObserverAllocation allocation;
ObserverAllocation observers_capacities;
for (const auto& observer_config : bitrate_observer_configs_) {
@@ -419,7 +413,6 @@
BitrateAllocator::ObserverAllocation BitrateAllocator::MaxRateAllocation(
uint32_t bitrate,
uint32_t sum_max_bitrates) {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
ObserverAllocation allocation;
for (const auto& observer_config : bitrate_observer_configs_) {
@@ -460,7 +453,6 @@
bool include_zero_allocations,
int max_multiplier,
ObserverAllocation* allocation) {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
RTC_DCHECK_EQ(allocation->size(), bitrate_observer_configs_.size());
ObserverSortingMap list_max_bitrates;
@@ -493,7 +485,6 @@
bool BitrateAllocator::EnoughBitrateForAllObservers(uint32_t bitrate,
uint32_t sum_min_bitrates) {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
if (bitrate < sum_min_bitrates)
return false;
@@ -513,7 +504,6 @@
uint32_t remaining_bitrate,
const ObserverAllocation& observers_capacities,
ObserverAllocation* allocation) {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
RTC_DCHECK_EQ(allocation->size(), bitrate_observer_configs_.size());
RTC_DCHECK_EQ(observers_capacities.size(), bitrate_observer_configs_.size());
diff --git a/call/bitrate_allocator.h b/call/bitrate_allocator.h
index 9cbdc11..9913c4f 100644
--- a/call/bitrate_allocator.h
+++ b/call/bitrate_allocator.h
@@ -166,31 +166,35 @@
// Calculates the minimum requested send bitrate and max padding bitrate and
// calls LimitObserver::OnAllocationLimitsChanged.
- void UpdateAllocationLimits();
+ void UpdateAllocationLimits() RTC_RUN_ON(&sequenced_checker_);
typedef std::vector<ObserverConfig> ObserverConfigs;
ObserverConfigs::iterator FindObserverConfig(
- const BitrateAllocatorObserver* observer);
+ const BitrateAllocatorObserver* observer) RTC_RUN_ON(&sequenced_checker_);
typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap;
typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation;
- ObserverAllocation AllocateBitrates(uint32_t bitrate);
+ ObserverAllocation AllocateBitrates(uint32_t bitrate)
+ RTC_RUN_ON(&sequenced_checker_);
// Allocates zero bitrate to all observers.
- ObserverAllocation ZeroRateAllocation();
+ ObserverAllocation ZeroRateAllocation() RTC_RUN_ON(&sequenced_checker_);
// Allocates bitrate to observers when there isn't enough to allocate the
// minimum to all observers.
- ObserverAllocation LowRateAllocation(uint32_t bitrate);
+ ObserverAllocation LowRateAllocation(uint32_t bitrate)
+ RTC_RUN_ON(&sequenced_checker_);
// Allocates bitrate to all observers when the available bandwidth is enough
// to allocate the minimum to all observers but not enough to allocate the
// max bitrate of each observer.
ObserverAllocation NormalRateAllocation(uint32_t bitrate,
- uint32_t sum_min_bitrates);
+ uint32_t sum_min_bitrates)
+ RTC_RUN_ON(&sequenced_checker_);
// Allocates bitrate to observers when there is enough available bandwidth
// for all observers to be allocated their max bitrate.
ObserverAllocation MaxRateAllocation(uint32_t bitrate,
- uint32_t sum_max_bitrates);
+ uint32_t sum_max_bitrates)
+ RTC_RUN_ON(&sequenced_checker_);
// Splits |bitrate| evenly to observers already in |allocation|.
// |include_zero_allocations| decides if zero allocations should be part of
@@ -199,9 +203,11 @@
void DistributeBitrateEvenly(uint32_t bitrate,
bool include_zero_allocations,
int max_multiplier,
- ObserverAllocation* allocation);
+ ObserverAllocation* allocation)
+ RTC_RUN_ON(&sequenced_checker_);
bool EnoughBitrateForAllObservers(uint32_t bitrate,
- uint32_t sum_min_bitrates);
+ uint32_t sum_min_bitrates)
+ RTC_RUN_ON(&sequenced_checker_);
// From the available |bitrate|, each observer will be allocated a
// proportional amount based upon its bitrate priority. If that amount is
@@ -212,7 +218,7 @@
void DistributeBitrateRelatively(
uint32_t bitrate,
const ObserverAllocation& observers_capacities,
- ObserverAllocation* allocation);
+ ObserverAllocation* allocation) RTC_RUN_ON(&sequenced_checker_);
// Allow packets to be transmitted in up to 2 times max video bitrate if the
// bandwidth estimate allows it.