Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include "webrtc/modules/audio_processing/agc2/gain_controller2.h" | |
| 12 | |
| 13 #include "webrtc/base/checks.h" | |
| 14 #include "webrtc/modules/audio_processing/audio_buffer.h" | |
| 15 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" | |
| 16 | |
| 17 namespace webrtc { | |
| 18 | |
| 19 int GainController2::instance_count_ = 0; | |
| 20 | |
| 21 GainController2::GainController2(int sample_rate_hz) | |
| 22 : data_dumper_(new ApmDataDumper(instance_count_)), | |
| 23 gain_applier_(data_dumper_.get()), | |
| 24 hard_coded_gain_(0.9f) { | |
| 25 RTC_DCHECK(sample_rate_hz == AudioProcessing::kSampleRate8kHz || | |
| 26 sample_rate_hz == AudioProcessing::kSampleRate16kHz || | |
| 27 sample_rate_hz == AudioProcessing::kSampleRate32kHz || | |
| 28 sample_rate_hz == AudioProcessing::kSampleRate48kHz); | |
| 29 data_dumper_->InitiateNewSetOfRecordings(); | |
| 30 data_dumper_->DumpRaw("agc2_hard_coded_gain", 1, &hard_coded_gain_); | |
| 31 gain_applier_.Initialize(sample_rate_hz); | |
| 32 ++instance_count_; | |
|
peah-webrtc
2017/05/16 13:06:57
This increement needs to be atomic as APM can be i
AleBzk
2017/05/18 08:31:37
Thanks, great to learn this.
Then the same change
peah-webrtc
2017/05/18 10:51:18
Good point :-) I guess the reason for that not bei
| |
| 33 } | |
| 34 | |
| 35 GainController2::~GainController2() = default; | |
| 36 | |
| 37 void GainController2::Process(AudioBuffer* audio) { | |
| 38 RTC_DCHECK_LT(0, audio->num_channels()); | |
| 39 int num_saturations = gain_applier_.Process(hard_coded_gain_, audio); | |
| 40 data_dumper_->DumpRaw("agc2_num_saturations", 1, &num_saturations); | |
| 41 } | |
| 42 | |
| 43 bool GainController2::Validate( | |
| 44 const AudioProcessing::Config::GainController2& config) { | |
| 45 return true; | |
| 46 } | |
| 47 | |
| 48 std::string GainController2::ToString( | |
| 49 const AudioProcessing::Config::GainController2& config) { | |
| 50 std::stringstream ss; | |
| 51 ss << "{" | |
| 52 << "enabled: " << (config.enabled ? "true" : "false") << "}"; | |
| 53 return ss.str(); | |
| 54 } | |
| 55 | |
| 56 } // namespace webrtc | |
| OLD | NEW |