Bug 1456115 - Make last_sample_rate_ in `neteq_impl.cc` atomic. r?dminor
This allows removing locking, and allows other threads to progress without
taking the lock, hence lowering the probability that the lock will be taken for
a long time when we need to pull NeqEQ.
MozReview-Commit-ID: HMO67A0hher
--- a/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -456,17 +456,16 @@ rtc::Optional<uint32_t> NetEqImpl::GetPl
// which is indicated by returning an empty value.
return rtc::Optional<uint32_t>();
}
return rtc::Optional<uint32_t>(
timestamp_scaler_->ToExternal(playout_timestamp_));
}
int NetEqImpl::last_output_sample_rate_hz() const {
- rtc::CritScope lock(&crit_sect_);
return last_output_sample_rate_hz_;
}
rtc::Optional<CodecInst> NetEqImpl::GetDecoder(int payload_type) const {
rtc::CritScope lock(&crit_sect_);
const DecoderDatabase::DecoderInfo* di =
decoder_database_->GetDecoderInfo(payload_type);
if (!di) {
--- a/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/neteq_impl.h
+++ b/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/neteq_impl.h
@@ -378,17 +378,17 @@ class NetEqImpl : public webrtc::NetEq {
std::unique_ptr<Accelerate> accelerate_ GUARDED_BY(crit_sect_);
std::unique_ptr<PreemptiveExpand> preemptive_expand_ GUARDED_BY(crit_sect_);
RandomVector random_vector_ GUARDED_BY(crit_sect_);
std::unique_ptr<ComfortNoise> comfort_noise_ GUARDED_BY(crit_sect_);
Rtcp rtcp_ GUARDED_BY(crit_sect_);
StatisticsCalculator stats_ GUARDED_BY(crit_sect_);
int fs_hz_ GUARDED_BY(crit_sect_);
int fs_mult_ GUARDED_BY(crit_sect_);
- int last_output_sample_rate_hz_ GUARDED_BY(crit_sect_);
+ std::atomic<int> last_output_sample_rate_hz_;
size_t output_size_samples_ GUARDED_BY(crit_sect_);
size_t decoder_frame_length_ GUARDED_BY(crit_sect_);
Modes last_mode_ GUARDED_BY(crit_sect_);
Operations last_operation_ GUARDED_BY(crit_sect_);
std::unique_ptr<int16_t[]> mute_factor_array_ GUARDED_BY(crit_sect_);
size_t decoded_buffer_length_ GUARDED_BY(crit_sect_);
std::unique_ptr<int16_t[]> decoded_buffer_ GUARDED_BY(crit_sect_);
uint32_t playout_timestamp_ GUARDED_BY(crit_sect_);