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

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

Issue 1764293002: Revert of Removed the inheritance from ProcessingComponent for EchoCancellerImpl. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()
84 : echo_cancellation(nullptr), 84 : echo_cancellation(nullptr),
85 echo_control_mobile(nullptr), 85 echo_control_mobile(nullptr),
86 gain_control(nullptr) {} 86 gain_control(nullptr) {}
87 // Accessed externally of APM without any lock acquired. 87 // Accessed externally of APM without any lock acquired.
88 std::unique_ptr<EchoCancellationImpl> echo_cancellation; 88 EchoCancellationImpl* echo_cancellation;
89 EchoControlMobileImpl* echo_control_mobile; 89 EchoControlMobileImpl* echo_control_mobile;
90 GainControlImpl* gain_control; 90 GainControlImpl* gain_control;
91 std::unique_ptr<HighPassFilterImpl> high_pass_filter; 91 std::unique_ptr<HighPassFilterImpl> high_pass_filter;
92 std::unique_ptr<LevelEstimatorImpl> level_estimator; 92 std::unique_ptr<LevelEstimatorImpl> level_estimator;
93 std::unique_ptr<NoiseSuppressionImpl> noise_suppression; 93 std::unique_ptr<NoiseSuppressionImpl> noise_suppression;
94 std::unique_ptr<VoiceDetectionImpl> voice_detection; 94 std::unique_ptr<VoiceDetectionImpl> voice_detection;
95 std::unique_ptr<GainControlForExperimentalAgc> 95 std::unique_ptr<GainControlForExperimentalAgc>
96 gain_control_for_experimental_agc; 96 gain_control_for_experimental_agc;
97 97
98 // Accessed internally from both render and capture. 98 // Accessed internally from both render and capture.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 capture_(config.Get<ExperimentalNs>().enabled, 161 capture_(config.Get<ExperimentalNs>().enabled,
162 #endif 162 #endif
163 config.Get<Beamforming>().array_geometry, 163 config.Get<Beamforming>().array_geometry,
164 config.Get<Beamforming>().target_direction), 164 config.Get<Beamforming>().target_direction),
165 capture_nonlocked_(config.Get<Beamforming>().enabled) 165 capture_nonlocked_(config.Get<Beamforming>().enabled)
166 { 166 {
167 { 167 {
168 rtc::CritScope cs_render(&crit_render_); 168 rtc::CritScope cs_render(&crit_render_);
169 rtc::CritScope cs_capture(&crit_capture_); 169 rtc::CritScope cs_capture(&crit_capture_);
170 170
171 public_submodules_->echo_cancellation.reset( 171 public_submodules_->echo_cancellation =
172 new EchoCancellationImpl(this, &crit_render_, &crit_capture_)); 172 new EchoCancellationImpl(this, &crit_render_, &crit_capture_);
173 public_submodules_->echo_control_mobile = 173 public_submodules_->echo_control_mobile =
174 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_); 174 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_);
175 public_submodules_->gain_control = 175 public_submodules_->gain_control =
176 new GainControlImpl(this, &crit_capture_, &crit_capture_); 176 new GainControlImpl(this, &crit_capture_, &crit_capture_);
177 public_submodules_->high_pass_filter.reset( 177 public_submodules_->high_pass_filter.reset(
178 new HighPassFilterImpl(&crit_capture_)); 178 new HighPassFilterImpl(&crit_capture_));
179 public_submodules_->level_estimator.reset( 179 public_submodules_->level_estimator.reset(
180 new LevelEstimatorImpl(&crit_capture_)); 180 new LevelEstimatorImpl(&crit_capture_));
181 public_submodules_->noise_suppression.reset( 181 public_submodules_->noise_suppression.reset(
182 new NoiseSuppressionImpl(&crit_capture_)); 182 new NoiseSuppressionImpl(&crit_capture_));
183 public_submodules_->voice_detection.reset( 183 public_submodules_->voice_detection.reset(
184 new VoiceDetectionImpl(&crit_capture_)); 184 new VoiceDetectionImpl(&crit_capture_));
185 public_submodules_->gain_control_for_experimental_agc.reset( 185 public_submodules_->gain_control_for_experimental_agc.reset(
186 new GainControlForExperimentalAgc(public_submodules_->gain_control, 186 new GainControlForExperimentalAgc(public_submodules_->gain_control,
187 &crit_capture_)); 187 &crit_capture_));
188
189 private_submodules_->component_list.push_back(
190 public_submodules_->echo_cancellation);
188 private_submodules_->component_list.push_back( 191 private_submodules_->component_list.push_back(
189 public_submodules_->echo_control_mobile); 192 public_submodules_->echo_control_mobile);
190 private_submodules_->component_list.push_back( 193 private_submodules_->component_list.push_back(
191 public_submodules_->gain_control); 194 public_submodules_->gain_control);
192 } 195 }
193 196
194 SetExtraOptions(config); 197 SetExtraOptions(config);
195 } 198 }
196 199
197 AudioProcessingImpl::~AudioProcessingImpl() { 200 AudioProcessingImpl::~AudioProcessingImpl() {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 formats_.api_format.output_stream().num_frames())); 315 formats_.api_format.output_stream().num_frames()));
313 316
314 // Initialize all components. 317 // Initialize all components.
315 for (auto item : private_submodules_->component_list) { 318 for (auto item : private_submodules_->component_list) {
316 int err = item->Initialize(); 319 int err = item->Initialize();
317 if (err != kNoError) { 320 if (err != kNoError) {
318 return err; 321 return err;
319 } 322 }
320 } 323 }
321 324
322 InitializeEchoCanceller();
323 InitializeExperimentalAgc(); 325 InitializeExperimentalAgc();
324 InitializeTransient(); 326 InitializeTransient();
325 InitializeBeamformer(); 327 InitializeBeamformer();
326 InitializeIntelligibility(); 328 InitializeIntelligibility();
327 InitializeHighPassFilter(); 329 InitializeHighPassFilter();
328 InitializeNoiseSuppression(); 330 InitializeNoiseSuppression();
329 InitializeLevelEstimator(); 331 InitializeLevelEstimator();
330 InitializeVoiceDetection(); 332 InitializeVoiceDetection();
331 333
332 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 334 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 416 }
415 417
416 void AudioProcessingImpl::SetExtraOptions(const Config& config) { 418 void AudioProcessingImpl::SetExtraOptions(const Config& config) {
417 // Run in a single-threaded manner when setting the extra options. 419 // Run in a single-threaded manner when setting the extra options.
418 rtc::CritScope cs_render(&crit_render_); 420 rtc::CritScope cs_render(&crit_render_);
419 rtc::CritScope cs_capture(&crit_capture_); 421 rtc::CritScope cs_capture(&crit_capture_);
420 for (auto item : private_submodules_->component_list) { 422 for (auto item : private_submodules_->component_list) {
421 item->SetExtraOptions(config); 423 item->SetExtraOptions(config);
422 } 424 }
423 425
424 public_submodules_->echo_cancellation->SetExtraOptions(config);
425
426 if (capture_.transient_suppressor_enabled != 426 if (capture_.transient_suppressor_enabled !=
427 config.Get<ExperimentalNs>().enabled) { 427 config.Get<ExperimentalNs>().enabled) {
428 capture_.transient_suppressor_enabled = 428 capture_.transient_suppressor_enabled =
429 config.Get<ExperimentalNs>().enabled; 429 config.Get<ExperimentalNs>().enabled;
430 InitializeTransient(); 430 InitializeTransient();
431 } 431 }
432 432
433 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 433 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
434 if (capture_nonlocked_.beamformer_enabled != 434 if (capture_nonlocked_.beamformer_enabled !=
435 config.Get<Beamforming>().enabled) { 435 config.Get<Beamforming>().enabled) {
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 } 1080 }
1081 return kNoError; 1081 return kNoError;
1082 #else 1082 #else
1083 return kUnsupportedFunctionError; 1083 return kUnsupportedFunctionError;
1084 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1084 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1085 } 1085 }
1086 1086
1087 EchoCancellation* AudioProcessingImpl::echo_cancellation() const { 1087 EchoCancellation* AudioProcessingImpl::echo_cancellation() const {
1088 // Adding a lock here has no effect as it allows any access to the submodule 1088 // Adding a lock here has no effect as it allows any access to the submodule
1089 // from the returned pointer. 1089 // from the returned pointer.
1090 return public_submodules_->echo_cancellation.get(); 1090 return public_submodules_->echo_cancellation;
1091 } 1091 }
1092 1092
1093 EchoControlMobile* AudioProcessingImpl::echo_control_mobile() const { 1093 EchoControlMobile* AudioProcessingImpl::echo_control_mobile() const {
1094 // Adding a lock here has no effect as it allows any access to the submodule 1094 // Adding a lock here has no effect as it allows any access to the submodule
1095 // from the returned pointer. 1095 // from the returned pointer.
1096 return public_submodules_->echo_control_mobile; 1096 return public_submodules_->echo_control_mobile;
1097 } 1097 }
1098 1098
1099 GainControl* AudioProcessingImpl::gain_control() const { 1099 GainControl* AudioProcessingImpl::gain_control() const {
1100 // Adding a lock here has no effect as it allows any access to the submodule 1100 // Adding a lock here has no effect as it allows any access to the submodule
(...skipping 26 matching lines...) Expand all
1127 // Adding a lock here has no effect as it allows any access to the submodule 1127 // Adding a lock here has no effect as it allows any access to the submodule
1128 // from the returned pointer. 1128 // from the returned pointer.
1129 return public_submodules_->voice_detection.get(); 1129 return public_submodules_->voice_detection.get();
1130 } 1130 }
1131 1131
1132 bool AudioProcessingImpl::is_data_processed() const { 1132 bool AudioProcessingImpl::is_data_processed() const {
1133 // The beamformer, noise suppressor and highpass filter 1133 // The beamformer, noise suppressor and highpass filter
1134 // modify the data. 1134 // modify the data.
1135 if (capture_nonlocked_.beamformer_enabled || 1135 if (capture_nonlocked_.beamformer_enabled ||
1136 public_submodules_->high_pass_filter->is_enabled() || 1136 public_submodules_->high_pass_filter->is_enabled() ||
1137 public_submodules_->noise_suppression->is_enabled() || 1137 public_submodules_->noise_suppression->is_enabled()) {
1138 public_submodules_->echo_cancellation->is_enabled()) {
1139 return true; 1138 return true;
1140 } 1139 }
1141 1140
1142 // All of the private submodules modify the data. 1141 // All of the private submodules modify the data.
1143 for (auto item : private_submodules_->component_list) { 1142 for (auto item : private_submodules_->component_list) {
1144 if (item->is_component_enabled()) { 1143 if (item->is_component_enabled()) {
1145 return true; 1144 return true;
1146 } 1145 }
1147 } 1146 }
1148 1147
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 void AudioProcessingImpl::InitializeHighPassFilter() { 1242 void AudioProcessingImpl::InitializeHighPassFilter() {
1244 public_submodules_->high_pass_filter->Initialize(num_proc_channels(), 1243 public_submodules_->high_pass_filter->Initialize(num_proc_channels(),
1245 proc_sample_rate_hz()); 1244 proc_sample_rate_hz());
1246 } 1245 }
1247 1246
1248 void AudioProcessingImpl::InitializeNoiseSuppression() { 1247 void AudioProcessingImpl::InitializeNoiseSuppression() {
1249 public_submodules_->noise_suppression->Initialize(num_proc_channels(), 1248 public_submodules_->noise_suppression->Initialize(num_proc_channels(),
1250 proc_sample_rate_hz()); 1249 proc_sample_rate_hz());
1251 } 1250 }
1252 1251
1253 void AudioProcessingImpl::InitializeEchoCanceller() {
1254 public_submodules_->echo_cancellation->Initialize();
1255 }
1256
1257 void AudioProcessingImpl::InitializeLevelEstimator() { 1252 void AudioProcessingImpl::InitializeLevelEstimator() {
1258 public_submodules_->level_estimator->Initialize(); 1253 public_submodules_->level_estimator->Initialize();
1259 } 1254 }
1260 1255
1261 void AudioProcessingImpl::InitializeVoiceDetection() { 1256 void AudioProcessingImpl::InitializeVoiceDetection() {
1262 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); 1257 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz());
1263 } 1258 }
1264 1259
1265 void AudioProcessingImpl::MaybeUpdateHistograms() { 1260 void AudioProcessingImpl::MaybeUpdateHistograms() {
1266 static const int kMinDiffDelayMs = 60; 1261 static const int kMinDiffDelayMs = 60;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1450 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1456 1451
1457 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1452 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1458 &debug_dump_.num_bytes_left_for_log_, 1453 &debug_dump_.num_bytes_left_for_log_,
1459 &crit_debug_, &debug_dump_.capture)); 1454 &crit_debug_, &debug_dump_.capture));
1460 return kNoError; 1455 return kNoError;
1461 } 1456 }
1462 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1457 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1463 1458
1464 } // namespace webrtc 1459 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.h ('k') | webrtc/modules/audio_processing/echo_cancellation_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698