Bug 1456115 - Make last_sample_rate_ in `neteq_impl.cc` atomic. r?dminor draft
authorPaul Adenot <paul@paul.cx>
Mon, 23 Apr 2018 11:55:19 +0200
changeset 786558 2c7df2f6c5fe0ce219db94ecb247317227f0a9d9
parent 786557 cdb53afaa67b41afcc46db53b2a6a282bfc1a9a5
child 786559 fcd101b666349cc20a584b26c1efb6443599f355
push id107512
push userpaul@paul.cx
push dateMon, 23 Apr 2018 15:14:13 +0000
reviewersdminor
bugs1456115
milestone61.0a1
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
media/webrtc/trunk/webrtc/modules/audio_coding/neteq/neteq_impl.cc
media/webrtc/trunk/webrtc/modules/audio_coding/neteq/neteq_impl.h
--- 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_);