OLD | NEW |
---|---|
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 std::unique_ptr<EchoCancellationImpl> echo_cancellation; |
89 EchoControlMobileImpl* echo_control_mobile; | 89 EchoControlMobileImpl* echo_control_mobile; |
the sun
2016/03/07 14:57:43
Sir, I think we have a leak.
peah-webrtc
2016/03/08 07:53:31
Good find! :-)
Done.
| |
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. |
99 std::unique_ptr<TransientSuppressor> transient_suppressor; | 99 std::unique_ptr<TransientSuppressor> transient_suppressor; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 private_submodules_->component_list.push_back( | 188 private_submodules_->component_list.push_back( |
189 public_submodules_->echo_control_mobile); | |
190 private_submodules_->component_list.push_back( | |
191 public_submodules_->gain_control); | 189 public_submodules_->gain_control); |
192 } | 190 } |
193 | 191 |
194 SetExtraOptions(config); | 192 SetExtraOptions(config); |
195 } | 193 } |
196 | 194 |
197 AudioProcessingImpl::~AudioProcessingImpl() { | 195 AudioProcessingImpl::~AudioProcessingImpl() { |
198 // Depends on gain_control_ and | 196 // Depends on gain_control_ and |
199 // public_submodules_->gain_control_for_experimental_agc. | 197 // public_submodules_->gain_control_for_experimental_agc. |
200 private_submodules_->agc_manager.reset(); | 198 private_submodules_->agc_manager.reset(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 | 311 |
314 // Initialize all components. | 312 // Initialize all components. |
315 for (auto item : private_submodules_->component_list) { | 313 for (auto item : private_submodules_->component_list) { |
316 int err = item->Initialize(); | 314 int err = item->Initialize(); |
317 if (err != kNoError) { | 315 if (err != kNoError) { |
318 return err; | 316 return err; |
319 } | 317 } |
320 } | 318 } |
321 | 319 |
322 InitializeEchoCanceller(); | 320 InitializeEchoCanceller(); |
321 InitializeEchoControlMobile(); | |
323 InitializeExperimentalAgc(); | 322 InitializeExperimentalAgc(); |
324 InitializeTransient(); | 323 InitializeTransient(); |
325 InitializeBeamformer(); | 324 InitializeBeamformer(); |
326 InitializeIntelligibility(); | 325 InitializeIntelligibility(); |
327 InitializeHighPassFilter(); | 326 InitializeHighPassFilter(); |
328 InitializeNoiseSuppression(); | 327 InitializeNoiseSuppression(); |
329 InitializeLevelEstimator(); | 328 InitializeLevelEstimator(); |
330 InitializeVoiceDetection(); | 329 InitializeVoiceDetection(); |
331 | 330 |
332 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 331 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1128 // from the returned pointer. | 1127 // from the returned pointer. |
1129 return public_submodules_->voice_detection.get(); | 1128 return public_submodules_->voice_detection.get(); |
1130 } | 1129 } |
1131 | 1130 |
1132 bool AudioProcessingImpl::is_data_processed() const { | 1131 bool AudioProcessingImpl::is_data_processed() const { |
1133 // The beamformer, noise suppressor and highpass filter | 1132 // The beamformer, noise suppressor and highpass filter |
1134 // modify the data. | 1133 // modify the data. |
1135 if (capture_nonlocked_.beamformer_enabled || | 1134 if (capture_nonlocked_.beamformer_enabled || |
1136 public_submodules_->high_pass_filter->is_enabled() || | 1135 public_submodules_->high_pass_filter->is_enabled() || |
1137 public_submodules_->noise_suppression->is_enabled() || | 1136 public_submodules_->noise_suppression->is_enabled() || |
1138 public_submodules_->echo_cancellation->is_enabled()) { | 1137 public_submodules_->echo_cancellation->is_enabled() || |
1138 public_submodules_->echo_control_mobile->is_enabled()) { | |
1139 return true; | 1139 return true; |
1140 } | 1140 } |
1141 | 1141 |
1142 // All of the private submodules modify the data. | 1142 // All of the private submodules modify the data. |
1143 for (auto item : private_submodules_->component_list) { | 1143 for (auto item : private_submodules_->component_list) { |
1144 if (item->is_component_enabled()) { | 1144 if (item->is_component_enabled()) { |
1145 return true; | 1145 return true; |
1146 } | 1146 } |
1147 } | 1147 } |
1148 | 1148 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1247 | 1247 |
1248 void AudioProcessingImpl::InitializeNoiseSuppression() { | 1248 void AudioProcessingImpl::InitializeNoiseSuppression() { |
1249 public_submodules_->noise_suppression->Initialize(num_proc_channels(), | 1249 public_submodules_->noise_suppression->Initialize(num_proc_channels(), |
1250 proc_sample_rate_hz()); | 1250 proc_sample_rate_hz()); |
1251 } | 1251 } |
1252 | 1252 |
1253 void AudioProcessingImpl::InitializeEchoCanceller() { | 1253 void AudioProcessingImpl::InitializeEchoCanceller() { |
1254 public_submodules_->echo_cancellation->Initialize(); | 1254 public_submodules_->echo_cancellation->Initialize(); |
1255 } | 1255 } |
1256 | 1256 |
1257 void AudioProcessingImpl::InitializeEchoControlMobile() { | |
the sun
2016/03/07 14:43:12
In a future CL, consider removing these methods si
peah-webrtc
2016/03/08 07:53:31
Good point! I've had that in mind! Will do :-)
| |
1258 public_submodules_->echo_control_mobile->Initialize(); | |
1259 } | |
1260 | |
1257 void AudioProcessingImpl::InitializeLevelEstimator() { | 1261 void AudioProcessingImpl::InitializeLevelEstimator() { |
1258 public_submodules_->level_estimator->Initialize(); | 1262 public_submodules_->level_estimator->Initialize(); |
1259 } | 1263 } |
1260 | 1264 |
1261 void AudioProcessingImpl::InitializeVoiceDetection() { | 1265 void AudioProcessingImpl::InitializeVoiceDetection() { |
1262 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); | 1266 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); |
1263 } | 1267 } |
1264 | 1268 |
1265 void AudioProcessingImpl::MaybeUpdateHistograms() { | 1269 void AudioProcessingImpl::MaybeUpdateHistograms() { |
1266 static const int kMinDiffDelayMs = 60; | 1270 static const int kMinDiffDelayMs = 60; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1457 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1461 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
1458 | 1462 |
1459 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1463 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
1460 &debug_dump_.num_bytes_left_for_log_, | 1464 &debug_dump_.num_bytes_left_for_log_, |
1461 &crit_debug_, &debug_dump_.capture)); | 1465 &crit_debug_, &debug_dump_.capture)); |
1462 return kNoError; | 1466 return kNoError; |
1463 } | 1467 } |
1464 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1468 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1465 | 1469 |
1466 } // namespace webrtc | 1470 } // namespace webrtc |
OLD | NEW |