Bug 1456115 - Make last_sample_rate_ in `neteq_impl.cc` atomic. r=dminor
authorPaul Adenot <paul@paul.cx>
Mon, 23 Apr 2018 11:55:19 +0200
changeset 469069 956b62a9c5a437c2bfdfac6605332283f9c14086
parent 469068 4a1df66695dd96b715503b2a27359471de6c57e4
child 469070 c4b87fb85648eb1309d3135489371a0a713b366f
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdminor
bugs1456115
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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_);