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 787248 990a600b616bfb730be60d8af1154f4303d2597a
parent 787247 960ca31f6b6fb2738d54f6683431484fb976e12d
child 787830 92ecc6a6097a7784947d9528a255b5d399081921
child 787832 ac3f6606f9f640524c240381af11eaa1033f806e
push id107695
push userpaul@paul.cx
push dateTue, 24 Apr 2018 16:04:50 +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_);