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

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: Rebase with latest master 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 config.Get<Beamforming>().array_geometry, 164 config.Get<Beamforming>().array_geometry,
168 config.Get<Beamforming>().target_direction), 165 config.Get<Beamforming>().target_direction),
169 capture_nonlocked_(config.Get<Beamforming>().enabled) 166 capture_nonlocked_(config.Get<Beamforming>().enabled)
170 { 167 {
171 { 168 {
172 rtc::CritScope cs_render(&crit_render_); 169 rtc::CritScope cs_render(&crit_render_);
173 rtc::CritScope cs_capture(&crit_capture_); 170 rtc::CritScope cs_capture(&crit_capture_);
174 171
175 public_submodules_->echo_cancellation.reset( 172 public_submodules_->echo_cancellation.reset(
176 new EchoCancellationImpl(this, &crit_render_, &crit_capture_)); 173 new EchoCancellationImpl(this, &crit_render_, &crit_capture_));
177 public_submodules_->echo_control_mobile = 174 public_submodules_->echo_control_mobile.reset(
178 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_); 175 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_));
179 public_submodules_->gain_control = 176 public_submodules_->gain_control =
180 new GainControlImpl(this, &crit_capture_, &crit_capture_); 177 new GainControlImpl(this, &crit_capture_, &crit_capture_);
181 public_submodules_->high_pass_filter.reset( 178 public_submodules_->high_pass_filter.reset(
182 new HighPassFilterImpl(&crit_capture_)); 179 new HighPassFilterImpl(&crit_capture_));
183 public_submodules_->level_estimator.reset( 180 public_submodules_->level_estimator.reset(
184 new LevelEstimatorImpl(&crit_capture_)); 181 new LevelEstimatorImpl(&crit_capture_));
185 public_submodules_->noise_suppression.reset( 182 public_submodules_->noise_suppression.reset(
186 new NoiseSuppressionImpl(&crit_capture_)); 183 new NoiseSuppressionImpl(&crit_capture_));
187 public_submodules_->voice_detection.reset( 184 public_submodules_->voice_detection.reset(
188 new VoiceDetectionImpl(&crit_capture_)); 185 new VoiceDetectionImpl(&crit_capture_));
189 public_submodules_->gain_control_for_experimental_agc.reset( 186 public_submodules_->gain_control_for_experimental_agc.reset(
190 new GainControlForExperimentalAgc(public_submodules_->gain_control, 187 new GainControlForExperimentalAgc(public_submodules_->gain_control,
191 &crit_capture_)); 188 &crit_capture_));
192 private_submodules_->component_list.push_back( 189 private_submodules_->component_list.push_back(
193 public_submodules_->echo_control_mobile);
194 private_submodules_->component_list.push_back(
195 public_submodules_->gain_control); 190 public_submodules_->gain_control);
196 } 191 }
197 192
198 SetExtraOptions(config); 193 SetExtraOptions(config);
199 } 194 }
200 195
201 AudioProcessingImpl::~AudioProcessingImpl() { 196 AudioProcessingImpl::~AudioProcessingImpl() {
202 // Depends on gain_control_ and 197 // Depends on gain_control_ and
203 // public_submodules_->gain_control_for_experimental_agc. 198 // public_submodules_->gain_control_for_experimental_agc.
204 private_submodules_->agc_manager.reset(); 199 private_submodules_->agc_manager.reset();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 312
318 // Initialize all components. 313 // Initialize all components.
319 for (auto item : private_submodules_->component_list) { 314 for (auto item : private_submodules_->component_list) {
320 int err = item->Initialize(); 315 int err = item->Initialize();
321 if (err != kNoError) { 316 if (err != kNoError) {
322 return err; 317 return err;
323 } 318 }
324 } 319 }
325 320
326 InitializeEchoCanceller(); 321 InitializeEchoCanceller();
322 InitializeEchoControlMobile();
327 InitializeExperimentalAgc(); 323 InitializeExperimentalAgc();
328 InitializeTransient(); 324 InitializeTransient();
329 InitializeBeamformer(); 325 InitializeBeamformer();
330 InitializeIntelligibility(); 326 InitializeIntelligibility();
331 InitializeHighPassFilter(); 327 InitializeHighPassFilter();
332 InitializeNoiseSuppression(); 328 InitializeNoiseSuppression();
333 InitializeLevelEstimator(); 329 InitializeLevelEstimator();
334 InitializeVoiceDetection(); 330 InitializeVoiceDetection();
335 331
336 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 332 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 1077
1082 EchoCancellation* AudioProcessingImpl::echo_cancellation() const { 1078 EchoCancellation* AudioProcessingImpl::echo_cancellation() const {
1083 // Adding a lock here has no effect as it allows any access to the submodule 1079 // Adding a lock here has no effect as it allows any access to the submodule
1084 // from the returned pointer. 1080 // from the returned pointer.
1085 return public_submodules_->echo_cancellation.get(); 1081 return public_submodules_->echo_cancellation.get();
1086 } 1082 }
1087 1083
1088 EchoControlMobile* AudioProcessingImpl::echo_control_mobile() const { 1084 EchoControlMobile* AudioProcessingImpl::echo_control_mobile() const {
1089 // Adding a lock here has no effect as it allows any access to the submodule 1085 // Adding a lock here has no effect as it allows any access to the submodule
1090 // from the returned pointer. 1086 // from the returned pointer.
1091 return public_submodules_->echo_control_mobile; 1087 return public_submodules_->echo_control_mobile.get();
1092 } 1088 }
1093 1089
1094 GainControl* AudioProcessingImpl::gain_control() const { 1090 GainControl* AudioProcessingImpl::gain_control() const {
1095 // Adding a lock here has no effect as it allows any access to the submodule 1091 // Adding a lock here has no effect as it allows any access to the submodule
1096 // from the returned pointer. 1092 // from the returned pointer.
1097 if (constants_.use_experimental_agc) { 1093 if (constants_.use_experimental_agc) {
1098 return public_submodules_->gain_control_for_experimental_agc.get(); 1094 return public_submodules_->gain_control_for_experimental_agc.get();
1099 } 1095 }
1100 return public_submodules_->gain_control; 1096 return public_submodules_->gain_control;
1101 } 1097 }
(...skipping 21 matching lines...) Expand all
1123 // from the returned pointer. 1119 // from the returned pointer.
1124 return public_submodules_->voice_detection.get(); 1120 return public_submodules_->voice_detection.get();
1125 } 1121 }
1126 1122
1127 bool AudioProcessingImpl::is_data_processed() const { 1123 bool AudioProcessingImpl::is_data_processed() const {
1128 // The beamformer, noise suppressor and highpass filter 1124 // The beamformer, noise suppressor and highpass filter
1129 // modify the data. 1125 // modify the data.
1130 if (capture_nonlocked_.beamformer_enabled || 1126 if (capture_nonlocked_.beamformer_enabled ||
1131 public_submodules_->high_pass_filter->is_enabled() || 1127 public_submodules_->high_pass_filter->is_enabled() ||
1132 public_submodules_->noise_suppression->is_enabled() || 1128 public_submodules_->noise_suppression->is_enabled() ||
1133 public_submodules_->echo_cancellation->is_enabled()) { 1129 public_submodules_->echo_cancellation->is_enabled() ||
1130 public_submodules_->echo_control_mobile->is_enabled()) {
1134 return true; 1131 return true;
1135 } 1132 }
1136 1133
1137 // All of the private submodules modify the data. 1134 // All of the private submodules modify the data.
1138 for (auto item : private_submodules_->component_list) { 1135 for (auto item : private_submodules_->component_list) {
1139 if (item->is_component_enabled()) { 1136 if (item->is_component_enabled()) {
1140 return true; 1137 return true;
1141 } 1138 }
1142 } 1139 }
1143 1140
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 1240
1244 void AudioProcessingImpl::InitializeNoiseSuppression() { 1241 void AudioProcessingImpl::InitializeNoiseSuppression() {
1245 public_submodules_->noise_suppression->Initialize(num_proc_channels(), 1242 public_submodules_->noise_suppression->Initialize(num_proc_channels(),
1246 proc_sample_rate_hz()); 1243 proc_sample_rate_hz());
1247 } 1244 }
1248 1245
1249 void AudioProcessingImpl::InitializeEchoCanceller() { 1246 void AudioProcessingImpl::InitializeEchoCanceller() {
1250 public_submodules_->echo_cancellation->Initialize(); 1247 public_submodules_->echo_cancellation->Initialize();
1251 } 1248 }
1252 1249
1250 void AudioProcessingImpl::InitializeEchoControlMobile() {
1251 public_submodules_->echo_control_mobile->Initialize();
1252 }
1253
1253 void AudioProcessingImpl::InitializeLevelEstimator() { 1254 void AudioProcessingImpl::InitializeLevelEstimator() {
1254 public_submodules_->level_estimator->Initialize(); 1255 public_submodules_->level_estimator->Initialize();
1255 } 1256 }
1256 1257
1257 void AudioProcessingImpl::InitializeVoiceDetection() { 1258 void AudioProcessingImpl::InitializeVoiceDetection() {
1258 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); 1259 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz());
1259 } 1260 }
1260 1261
1261 void AudioProcessingImpl::MaybeUpdateHistograms() { 1262 void AudioProcessingImpl::MaybeUpdateHistograms() {
1262 static const int kMinDiffDelayMs = 60; 1263 static const int kMinDiffDelayMs = 60;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1453 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1453 1454
1454 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1455 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1455 &debug_dump_.num_bytes_left_for_log_, 1456 &debug_dump_.num_bytes_left_for_log_,
1456 &crit_debug_, &debug_dump_.capture)); 1457 &crit_debug_, &debug_dump_.capture));
1457 return kNoError; 1458 return kNoError;
1458 } 1459 }
1459 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1460 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1460 1461
1461 } // namespace webrtc 1462 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.h ('k') | webrtc/modules/audio_processing/echo_control_mobile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698