Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 1772453002: Removing dependency of the EchoControlMobileImpl class on ProcessingComponent. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Changes in response to reviewer comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 assert(false); 74 assert(false);
75 return false; 75 return false;
76 } 76 }
77 } // namespace 77 } // namespace
78 78
79 // Throughout webrtc, it's assumed that success is represented by zero. 79 // Throughout webrtc, it's assumed that success is represented by zero.
80 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero"); 80 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero");
81 81
82 struct AudioProcessingImpl::ApmPublicSubmodules { 82 struct AudioProcessingImpl::ApmPublicSubmodules {
83 ApmPublicSubmodules() 83 ApmPublicSubmodules() : gain_control(nullptr) {}
84 : echo_cancellation(nullptr),
85 echo_control_mobile(nullptr),
86 gain_control(nullptr) {}
87 // Accessed externally of APM without any lock acquired. 84 // Accessed externally of APM without any lock acquired.
88 std::unique_ptr<EchoCancellationImpl> echo_cancellation; 85 std::unique_ptr<EchoCancellationImpl> echo_cancellation;
89 EchoControlMobileImpl* echo_control_mobile; 86 std::unique_ptr<EchoControlMobileImpl> echo_control_mobile;
90 GainControlImpl* gain_control; 87 GainControlImpl* gain_control;
91 std::unique_ptr<HighPassFilterImpl> high_pass_filter; 88 std::unique_ptr<HighPassFilterImpl> high_pass_filter;
92 std::unique_ptr<LevelEstimatorImpl> level_estimator; 89 std::unique_ptr<LevelEstimatorImpl> level_estimator;
93 std::unique_ptr<NoiseSuppressionImpl> noise_suppression; 90 std::unique_ptr<NoiseSuppressionImpl> noise_suppression;
94 std::unique_ptr<VoiceDetectionImpl> voice_detection; 91 std::unique_ptr<VoiceDetectionImpl> voice_detection;
95 std::unique_ptr<GainControlForExperimentalAgc> 92 std::unique_ptr<GainControlForExperimentalAgc>
96 gain_control_for_experimental_agc; 93 gain_control_for_experimental_agc;
97 94
98 // Accessed internally from both render and capture. 95 // Accessed internally from both render and capture.
99 std::unique_ptr<TransientSuppressor> transient_suppressor; 96 std::unique_ptr<TransientSuppressor> transient_suppressor;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 config.Get<Beamforming>().array_geometry, 160 config.Get<Beamforming>().array_geometry,
164 config.Get<Beamforming>().target_direction), 161 config.Get<Beamforming>().target_direction),
165 capture_nonlocked_(config.Get<Beamforming>().enabled) 162 capture_nonlocked_(config.Get<Beamforming>().enabled)
166 { 163 {
167 { 164 {
168 rtc::CritScope cs_render(&crit_render_); 165 rtc::CritScope cs_render(&crit_render_);
169 rtc::CritScope cs_capture(&crit_capture_); 166 rtc::CritScope cs_capture(&crit_capture_);
170 167
171 public_submodules_->echo_cancellation.reset( 168 public_submodules_->echo_cancellation.reset(
172 new EchoCancellationImpl(this, &crit_render_, &crit_capture_)); 169 new EchoCancellationImpl(this, &crit_render_, &crit_capture_));
173 public_submodules_->echo_control_mobile = 170 public_submodules_->echo_control_mobile.reset(
174 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_); 171 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_));
175 public_submodules_->gain_control = 172 public_submodules_->gain_control =
176 new GainControlImpl(this, &crit_capture_, &crit_capture_); 173 new GainControlImpl(this, &crit_capture_, &crit_capture_);
177 public_submodules_->high_pass_filter.reset( 174 public_submodules_->high_pass_filter.reset(
178 new HighPassFilterImpl(&crit_capture_)); 175 new HighPassFilterImpl(&crit_capture_));
179 public_submodules_->level_estimator.reset( 176 public_submodules_->level_estimator.reset(
180 new LevelEstimatorImpl(&crit_capture_)); 177 new LevelEstimatorImpl(&crit_capture_));
181 public_submodules_->noise_suppression.reset( 178 public_submodules_->noise_suppression.reset(
182 new NoiseSuppressionImpl(&crit_capture_)); 179 new NoiseSuppressionImpl(&crit_capture_));
183 public_submodules_->voice_detection.reset( 180 public_submodules_->voice_detection.reset(
184 new VoiceDetectionImpl(&crit_capture_)); 181 new VoiceDetectionImpl(&crit_capture_));
185 public_submodules_->gain_control_for_experimental_agc.reset( 182 public_submodules_->gain_control_for_experimental_agc.reset(
186 new GainControlForExperimentalAgc(public_submodules_->gain_control, 183 new GainControlForExperimentalAgc(public_submodules_->gain_control,
187 &crit_capture_)); 184 &crit_capture_));
188 private_submodules_->component_list.push_back( 185 private_submodules_->component_list.push_back(
189 public_submodules_->echo_control_mobile);
190 private_submodules_->component_list.push_back(
191 public_submodules_->gain_control); 186 public_submodules_->gain_control);
192 } 187 }
193 188
194 SetExtraOptions(config); 189 SetExtraOptions(config);
195 } 190 }
196 191
197 AudioProcessingImpl::~AudioProcessingImpl() { 192 AudioProcessingImpl::~AudioProcessingImpl() {
198 // Depends on gain_control_ and 193 // Depends on gain_control_ and
199 // public_submodules_->gain_control_for_experimental_agc. 194 // public_submodules_->gain_control_for_experimental_agc.
200 private_submodules_->agc_manager.reset(); 195 private_submodules_->agc_manager.reset();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 308
314 // Initialize all components. 309 // Initialize all components.
315 for (auto item : private_submodules_->component_list) { 310 for (auto item : private_submodules_->component_list) {
316 int err = item->Initialize(); 311 int err = item->Initialize();
317 if (err != kNoError) { 312 if (err != kNoError) {
318 return err; 313 return err;
319 } 314 }
320 } 315 }
321 316
322 InitializeEchoCanceller(); 317 InitializeEchoCanceller();
318 InitializeEchoControlMobile();
323 InitializeExperimentalAgc(); 319 InitializeExperimentalAgc();
324 InitializeTransient(); 320 InitializeTransient();
325 InitializeBeamformer(); 321 InitializeBeamformer();
326 InitializeIntelligibility(); 322 InitializeIntelligibility();
327 InitializeHighPassFilter(); 323 InitializeHighPassFilter();
328 InitializeNoiseSuppression(); 324 InitializeNoiseSuppression();
329 InitializeLevelEstimator(); 325 InitializeLevelEstimator();
330 InitializeVoiceDetection(); 326 InitializeVoiceDetection();
331 327
332 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 328 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1082
1087 EchoCancellation* AudioProcessingImpl::echo_cancellation() const { 1083 EchoCancellation* AudioProcessingImpl::echo_cancellation() const {
1088 // Adding a lock here has no effect as it allows any access to the submodule 1084 // Adding a lock here has no effect as it allows any access to the submodule
1089 // from the returned pointer. 1085 // from the returned pointer.
1090 return public_submodules_->echo_cancellation.get(); 1086 return public_submodules_->echo_cancellation.get();
1091 } 1087 }
1092 1088
1093 EchoControlMobile* AudioProcessingImpl::echo_control_mobile() const { 1089 EchoControlMobile* AudioProcessingImpl::echo_control_mobile() const {
1094 // Adding a lock here has no effect as it allows any access to the submodule 1090 // Adding a lock here has no effect as it allows any access to the submodule
1095 // from the returned pointer. 1091 // from the returned pointer.
1096 return public_submodules_->echo_control_mobile; 1092 return public_submodules_->echo_control_mobile.get();
1097 } 1093 }
1098 1094
1099 GainControl* AudioProcessingImpl::gain_control() const { 1095 GainControl* AudioProcessingImpl::gain_control() const {
1100 // Adding a lock here has no effect as it allows any access to the submodule 1096 // Adding a lock here has no effect as it allows any access to the submodule
1101 // from the returned pointer. 1097 // from the returned pointer.
1102 if (constants_.use_experimental_agc) { 1098 if (constants_.use_experimental_agc) {
1103 return public_submodules_->gain_control_for_experimental_agc.get(); 1099 return public_submodules_->gain_control_for_experimental_agc.get();
1104 } 1100 }
1105 return public_submodules_->gain_control; 1101 return public_submodules_->gain_control;
1106 } 1102 }
(...skipping 21 matching lines...) Expand all
1128 // from the returned pointer. 1124 // from the returned pointer.
1129 return public_submodules_->voice_detection.get(); 1125 return public_submodules_->voice_detection.get();
1130 } 1126 }
1131 1127
1132 bool AudioProcessingImpl::is_data_processed() const { 1128 bool AudioProcessingImpl::is_data_processed() const {
1133 // The beamformer, noise suppressor and highpass filter 1129 // The beamformer, noise suppressor and highpass filter
1134 // modify the data. 1130 // modify the data.
1135 if (capture_nonlocked_.beamformer_enabled || 1131 if (capture_nonlocked_.beamformer_enabled ||
1136 public_submodules_->high_pass_filter->is_enabled() || 1132 public_submodules_->high_pass_filter->is_enabled() ||
1137 public_submodules_->noise_suppression->is_enabled() || 1133 public_submodules_->noise_suppression->is_enabled() ||
1138 public_submodules_->echo_cancellation->is_enabled()) { 1134 public_submodules_->echo_cancellation->is_enabled() ||
1135 public_submodules_->echo_control_mobile->is_enabled()) {
1139 return true; 1136 return true;
1140 } 1137 }
1141 1138
1142 // All of the private submodules modify the data. 1139 // All of the private submodules modify the data.
1143 for (auto item : private_submodules_->component_list) { 1140 for (auto item : private_submodules_->component_list) {
1144 if (item->is_component_enabled()) { 1141 if (item->is_component_enabled()) {
1145 return true; 1142 return true;
1146 } 1143 }
1147 } 1144 }
1148 1145
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 1244
1248 void AudioProcessingImpl::InitializeNoiseSuppression() { 1245 void AudioProcessingImpl::InitializeNoiseSuppression() {
1249 public_submodules_->noise_suppression->Initialize(num_proc_channels(), 1246 public_submodules_->noise_suppression->Initialize(num_proc_channels(),
1250 proc_sample_rate_hz()); 1247 proc_sample_rate_hz());
1251 } 1248 }
1252 1249
1253 void AudioProcessingImpl::InitializeEchoCanceller() { 1250 void AudioProcessingImpl::InitializeEchoCanceller() {
1254 public_submodules_->echo_cancellation->Initialize(); 1251 public_submodules_->echo_cancellation->Initialize();
1255 } 1252 }
1256 1253
1254 void AudioProcessingImpl::InitializeEchoControlMobile() {
1255 public_submodules_->echo_control_mobile->Initialize();
1256 }
1257
1257 void AudioProcessingImpl::InitializeLevelEstimator() { 1258 void AudioProcessingImpl::InitializeLevelEstimator() {
1258 public_submodules_->level_estimator->Initialize(); 1259 public_submodules_->level_estimator->Initialize();
1259 } 1260 }
1260 1261
1261 void AudioProcessingImpl::InitializeVoiceDetection() { 1262 void AudioProcessingImpl::InitializeVoiceDetection() {
1262 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); 1263 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz());
1263 } 1264 }
1264 1265
1265 void AudioProcessingImpl::MaybeUpdateHistograms() { 1266 void AudioProcessingImpl::MaybeUpdateHistograms() {
1266 static const int kMinDiffDelayMs = 60; 1267 static const int kMinDiffDelayMs = 60;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1458 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1458 1459
1459 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1460 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1460 &debug_dump_.num_bytes_left_for_log_, 1461 &debug_dump_.num_bytes_left_for_log_,
1461 &crit_debug_, &debug_dump_.capture)); 1462 &crit_debug_, &debug_dump_.capture));
1462 return kNoError; 1463 return kNoError;
1463 } 1464 }
1464 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1465 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1465 1466
1466 } // namespace webrtc 1467 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698