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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() : gain_control(nullptr) {} | 83 ApmPublicSubmodules() {} |
84 // Accessed externally of APM without any lock acquired. | 84 // Accessed externally of APM without any lock acquired. |
85 std::unique_ptr<EchoCancellationImpl> echo_cancellation; | 85 std::unique_ptr<EchoCancellationImpl> echo_cancellation; |
86 std::unique_ptr<EchoControlMobileImpl> echo_control_mobile; | 86 std::unique_ptr<EchoControlMobileImpl> echo_control_mobile; |
87 GainControlImpl* gain_control; | 87 std::unique_ptr<GainControlImpl> gain_control; |
88 std::unique_ptr<HighPassFilterImpl> high_pass_filter; | 88 std::unique_ptr<HighPassFilterImpl> high_pass_filter; |
89 std::unique_ptr<LevelEstimatorImpl> level_estimator; | 89 std::unique_ptr<LevelEstimatorImpl> level_estimator; |
90 std::unique_ptr<NoiseSuppressionImpl> noise_suppression; | 90 std::unique_ptr<NoiseSuppressionImpl> noise_suppression; |
91 std::unique_ptr<VoiceDetectionImpl> voice_detection; | 91 std::unique_ptr<VoiceDetectionImpl> voice_detection; |
92 std::unique_ptr<GainControlForExperimentalAgc> | 92 std::unique_ptr<GainControlForExperimentalAgc> |
93 gain_control_for_experimental_agc; | 93 gain_control_for_experimental_agc; |
94 | 94 |
95 // Accessed internally from both render and capture. | 95 // Accessed internally from both render and capture. |
96 std::unique_ptr<TransientSuppressor> transient_suppressor; | 96 std::unique_ptr<TransientSuppressor> transient_suppressor; |
97 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; | 97 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 capture_nonlocked_(config.Get<Beamforming>().enabled) | 166 capture_nonlocked_(config.Get<Beamforming>().enabled) |
167 { | 167 { |
168 { | 168 { |
169 rtc::CritScope cs_render(&crit_render_); | 169 rtc::CritScope cs_render(&crit_render_); |
170 rtc::CritScope cs_capture(&crit_capture_); | 170 rtc::CritScope cs_capture(&crit_capture_); |
171 | 171 |
172 public_submodules_->echo_cancellation.reset( | 172 public_submodules_->echo_cancellation.reset( |
173 new EchoCancellationImpl(this, &crit_render_, &crit_capture_)); | 173 new EchoCancellationImpl(this, &crit_render_, &crit_capture_)); |
174 public_submodules_->echo_control_mobile.reset( | 174 public_submodules_->echo_control_mobile.reset( |
175 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_)); | 175 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_)); |
176 public_submodules_->gain_control = | 176 public_submodules_->gain_control.reset( |
177 new GainControlImpl(this, &crit_capture_, &crit_capture_); | 177 new GainControlImpl(this, &crit_capture_, &crit_capture_)); |
178 public_submodules_->high_pass_filter.reset( | 178 public_submodules_->high_pass_filter.reset( |
179 new HighPassFilterImpl(&crit_capture_)); | 179 new HighPassFilterImpl(&crit_capture_)); |
180 public_submodules_->level_estimator.reset( | 180 public_submodules_->level_estimator.reset( |
181 new LevelEstimatorImpl(&crit_capture_)); | 181 new LevelEstimatorImpl(&crit_capture_)); |
182 public_submodules_->noise_suppression.reset( | 182 public_submodules_->noise_suppression.reset( |
183 new NoiseSuppressionImpl(&crit_capture_)); | 183 new NoiseSuppressionImpl(&crit_capture_)); |
184 public_submodules_->voice_detection.reset( | 184 public_submodules_->voice_detection.reset( |
185 new VoiceDetectionImpl(&crit_capture_)); | 185 new VoiceDetectionImpl(&crit_capture_)); |
186 public_submodules_->gain_control_for_experimental_agc.reset( | 186 public_submodules_->gain_control_for_experimental_agc.reset( |
187 new GainControlForExperimentalAgc(public_submodules_->gain_control, | 187 new GainControlForExperimentalAgc( |
188 &crit_capture_)); | 188 public_submodules_->gain_control.get(), &crit_capture_)); |
189 private_submodules_->component_list.push_back( | |
190 public_submodules_->gain_control); | |
191 } | 189 } |
192 | 190 |
193 SetExtraOptions(config); | 191 SetExtraOptions(config); |
194 } | 192 } |
195 | 193 |
196 AudioProcessingImpl::~AudioProcessingImpl() { | 194 AudioProcessingImpl::~AudioProcessingImpl() { |
197 // Depends on gain_control_ and | 195 // Depends on gain_control_ and |
198 // public_submodules_->gain_control_for_experimental_agc. | 196 // public_submodules_->gain_control_for_experimental_agc. |
199 private_submodules_->agc_manager.reset(); | 197 private_submodules_->agc_manager.reset(); |
200 // Depends on gain_control_. | 198 // Depends on gain_control_. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 formats_.api_format.output_stream().num_frames())); | 309 formats_.api_format.output_stream().num_frames())); |
312 | 310 |
313 // Initialize all components. | 311 // Initialize all components. |
314 for (auto item : private_submodules_->component_list) { | 312 for (auto item : private_submodules_->component_list) { |
315 int err = item->Initialize(); | 313 int err = item->Initialize(); |
316 if (err != kNoError) { | 314 if (err != kNoError) { |
317 return err; | 315 return err; |
318 } | 316 } |
319 } | 317 } |
320 | 318 |
| 319 InitializeGainController(); |
321 InitializeEchoCanceller(); | 320 InitializeEchoCanceller(); |
322 InitializeEchoControlMobile(); | 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(); |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 // from the returned pointer. | 1085 // from the returned pointer. |
1087 return public_submodules_->echo_control_mobile.get(); | 1086 return public_submodules_->echo_control_mobile.get(); |
1088 } | 1087 } |
1089 | 1088 |
1090 GainControl* AudioProcessingImpl::gain_control() const { | 1089 GainControl* AudioProcessingImpl::gain_control() const { |
1091 // 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 |
1092 // from the returned pointer. | 1091 // from the returned pointer. |
1093 if (constants_.use_experimental_agc) { | 1092 if (constants_.use_experimental_agc) { |
1094 return public_submodules_->gain_control_for_experimental_agc.get(); | 1093 return public_submodules_->gain_control_for_experimental_agc.get(); |
1095 } | 1094 } |
1096 return public_submodules_->gain_control; | 1095 return public_submodules_->gain_control.get(); |
1097 } | 1096 } |
1098 | 1097 |
1099 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { | 1098 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { |
1100 // Adding a lock here has no effect as it allows any access to the submodule | 1099 // Adding a lock here has no effect as it allows any access to the submodule |
1101 // from the returned pointer. | 1100 // from the returned pointer. |
1102 return public_submodules_->high_pass_filter.get(); | 1101 return public_submodules_->high_pass_filter.get(); |
1103 } | 1102 } |
1104 | 1103 |
1105 LevelEstimator* AudioProcessingImpl::level_estimator() const { | 1104 LevelEstimator* AudioProcessingImpl::level_estimator() const { |
1106 // Adding a lock here has no effect as it allows any access to the submodule | 1105 // Adding a lock here has no effect as it allows any access to the submodule |
(...skipping 13 matching lines...) Expand all Loading... |
1120 return public_submodules_->voice_detection.get(); | 1119 return public_submodules_->voice_detection.get(); |
1121 } | 1120 } |
1122 | 1121 |
1123 bool AudioProcessingImpl::is_data_processed() const { | 1122 bool AudioProcessingImpl::is_data_processed() const { |
1124 // The beamformer, noise suppressor and highpass filter | 1123 // The beamformer, noise suppressor and highpass filter |
1125 // modify the data. | 1124 // modify the data. |
1126 if (capture_nonlocked_.beamformer_enabled || | 1125 if (capture_nonlocked_.beamformer_enabled || |
1127 public_submodules_->high_pass_filter->is_enabled() || | 1126 public_submodules_->high_pass_filter->is_enabled() || |
1128 public_submodules_->noise_suppression->is_enabled() || | 1127 public_submodules_->noise_suppression->is_enabled() || |
1129 public_submodules_->echo_cancellation->is_enabled() || | 1128 public_submodules_->echo_cancellation->is_enabled() || |
1130 public_submodules_->echo_control_mobile->is_enabled()) { | 1129 public_submodules_->echo_control_mobile->is_enabled() || |
| 1130 public_submodules_->gain_control->is_enabled()) { |
1131 return true; | 1131 return true; |
1132 } | 1132 } |
1133 | 1133 |
1134 // All of the private submodules modify the data. | 1134 // All of the private submodules modify the data. |
1135 for (auto item : private_submodules_->component_list) { | 1135 for (auto item : private_submodules_->component_list) { |
1136 if (item->is_component_enabled()) { | 1136 if (item->is_component_enabled()) { |
1137 return true; | 1137 return true; |
1138 } | 1138 } |
1139 } | 1139 } |
1140 | 1140 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 | 1184 |
1185 bool AudioProcessingImpl::rev_conversion_needed() const { | 1185 bool AudioProcessingImpl::rev_conversion_needed() const { |
1186 return (formats_.api_format.reverse_input_stream() != | 1186 return (formats_.api_format.reverse_input_stream() != |
1187 formats_.api_format.reverse_output_stream()); | 1187 formats_.api_format.reverse_output_stream()); |
1188 } | 1188 } |
1189 | 1189 |
1190 void AudioProcessingImpl::InitializeExperimentalAgc() { | 1190 void AudioProcessingImpl::InitializeExperimentalAgc() { |
1191 if (constants_.use_experimental_agc) { | 1191 if (constants_.use_experimental_agc) { |
1192 if (!private_submodules_->agc_manager.get()) { | 1192 if (!private_submodules_->agc_manager.get()) { |
1193 private_submodules_->agc_manager.reset(new AgcManagerDirect( | 1193 private_submodules_->agc_manager.reset(new AgcManagerDirect( |
1194 public_submodules_->gain_control, | 1194 public_submodules_->gain_control.get(), |
1195 public_submodules_->gain_control_for_experimental_agc.get(), | 1195 public_submodules_->gain_control_for_experimental_agc.get(), |
1196 constants_.agc_startup_min_volume)); | 1196 constants_.agc_startup_min_volume)); |
1197 } | 1197 } |
1198 private_submodules_->agc_manager->Initialize(); | 1198 private_submodules_->agc_manager->Initialize(); |
1199 private_submodules_->agc_manager->SetCaptureMuted( | 1199 private_submodules_->agc_manager->SetCaptureMuted( |
1200 capture_.output_will_be_muted); | 1200 capture_.output_will_be_muted); |
1201 } | 1201 } |
1202 } | 1202 } |
1203 | 1203 |
1204 void AudioProcessingImpl::InitializeTransient() { | 1204 void AudioProcessingImpl::InitializeTransient() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 | 1240 |
1241 void AudioProcessingImpl::InitializeNoiseSuppression() { | 1241 void AudioProcessingImpl::InitializeNoiseSuppression() { |
1242 public_submodules_->noise_suppression->Initialize(num_proc_channels(), | 1242 public_submodules_->noise_suppression->Initialize(num_proc_channels(), |
1243 proc_sample_rate_hz()); | 1243 proc_sample_rate_hz()); |
1244 } | 1244 } |
1245 | 1245 |
1246 void AudioProcessingImpl::InitializeEchoCanceller() { | 1246 void AudioProcessingImpl::InitializeEchoCanceller() { |
1247 public_submodules_->echo_cancellation->Initialize(); | 1247 public_submodules_->echo_cancellation->Initialize(); |
1248 } | 1248 } |
1249 | 1249 |
| 1250 void AudioProcessingImpl::InitializeGainController() { |
| 1251 public_submodules_->gain_control->Initialize(); |
| 1252 } |
| 1253 |
1250 void AudioProcessingImpl::InitializeEchoControlMobile() { | 1254 void AudioProcessingImpl::InitializeEchoControlMobile() { |
1251 public_submodules_->echo_control_mobile->Initialize(); | 1255 public_submodules_->echo_control_mobile->Initialize(); |
1252 } | 1256 } |
1253 | 1257 |
1254 void AudioProcessingImpl::InitializeLevelEstimator() { | 1258 void AudioProcessingImpl::InitializeLevelEstimator() { |
1255 public_submodules_->level_estimator->Initialize(); | 1259 public_submodules_->level_estimator->Initialize(); |
1256 } | 1260 } |
1257 | 1261 |
1258 void AudioProcessingImpl::InitializeVoiceDetection() { | 1262 void AudioProcessingImpl::InitializeVoiceDetection() { |
1259 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); | 1263 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1457 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
1454 | 1458 |
1455 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1459 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
1456 &debug_dump_.num_bytes_left_for_log_, | 1460 &debug_dump_.num_bytes_left_for_log_, |
1457 &crit_debug_, &debug_dump_.capture)); | 1461 &crit_debug_, &debug_dump_.capture)); |
1458 return kNoError; | 1462 return kNoError; |
1459 } | 1463 } |
1460 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1464 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1461 | 1465 |
1462 } // namespace webrtc | 1466 } // namespace webrtc |
OLD | NEW |