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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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() |
84 : echo_cancellation(nullptr), | 84 : echo_cancellation(nullptr), echo_control_mobile(nullptr) {} |
the sun
2016/03/09 09:42:10
Need a rebase?
peah-webrtc
2016/03/09 12:23:39
Yes definitely, I delayed that though as that woul
| |
85 echo_control_mobile(nullptr), | |
86 gain_control(nullptr) {} | |
87 // Accessed externally of APM without any lock acquired. | 85 // Accessed externally of APM without any lock acquired. |
88 std::unique_ptr<EchoCancellationImpl> echo_cancellation; | 86 std::unique_ptr<EchoCancellationImpl> echo_cancellation; |
89 EchoControlMobileImpl* echo_control_mobile; | 87 EchoControlMobileImpl* echo_control_mobile; |
90 GainControlImpl* gain_control; | 88 std::unique_ptr<GainControlImpl> gain_control; |
91 std::unique_ptr<HighPassFilterImpl> high_pass_filter; | 89 std::unique_ptr<HighPassFilterImpl> high_pass_filter; |
92 std::unique_ptr<LevelEstimatorImpl> level_estimator; | 90 std::unique_ptr<LevelEstimatorImpl> level_estimator; |
93 std::unique_ptr<NoiseSuppressionImpl> noise_suppression; | 91 std::unique_ptr<NoiseSuppressionImpl> noise_suppression; |
94 std::unique_ptr<VoiceDetectionImpl> voice_detection; | 92 std::unique_ptr<VoiceDetectionImpl> voice_detection; |
95 std::unique_ptr<GainControlForExperimentalAgc> | 93 std::unique_ptr<GainControlForExperimentalAgc> |
96 gain_control_for_experimental_agc; | 94 gain_control_for_experimental_agc; |
97 | 95 |
98 // Accessed internally from both render and capture. | 96 // Accessed internally from both render and capture. |
99 std::unique_ptr<TransientSuppressor> transient_suppressor; | 97 std::unique_ptr<TransientSuppressor> transient_suppressor; |
100 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; | 98 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 capture_nonlocked_(config.Get<Beamforming>().enabled) | 163 capture_nonlocked_(config.Get<Beamforming>().enabled) |
166 { | 164 { |
167 { | 165 { |
168 rtc::CritScope cs_render(&crit_render_); | 166 rtc::CritScope cs_render(&crit_render_); |
169 rtc::CritScope cs_capture(&crit_capture_); | 167 rtc::CritScope cs_capture(&crit_capture_); |
170 | 168 |
171 public_submodules_->echo_cancellation.reset( | 169 public_submodules_->echo_cancellation.reset( |
172 new EchoCancellationImpl(this, &crit_render_, &crit_capture_)); | 170 new EchoCancellationImpl(this, &crit_render_, &crit_capture_)); |
173 public_submodules_->echo_control_mobile = | 171 public_submodules_->echo_control_mobile = |
174 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_); | 172 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_); |
175 public_submodules_->gain_control = | 173 public_submodules_->gain_control.reset( |
176 new GainControlImpl(this, &crit_capture_, &crit_capture_); | 174 new GainControlImpl(this, &crit_capture_, &crit_capture_)); |
177 public_submodules_->high_pass_filter.reset( | 175 public_submodules_->high_pass_filter.reset( |
178 new HighPassFilterImpl(&crit_capture_)); | 176 new HighPassFilterImpl(&crit_capture_)); |
179 public_submodules_->level_estimator.reset( | 177 public_submodules_->level_estimator.reset( |
180 new LevelEstimatorImpl(&crit_capture_)); | 178 new LevelEstimatorImpl(&crit_capture_)); |
181 public_submodules_->noise_suppression.reset( | 179 public_submodules_->noise_suppression.reset( |
182 new NoiseSuppressionImpl(&crit_capture_)); | 180 new NoiseSuppressionImpl(&crit_capture_)); |
183 public_submodules_->voice_detection.reset( | 181 public_submodules_->voice_detection.reset( |
184 new VoiceDetectionImpl(&crit_capture_)); | 182 new VoiceDetectionImpl(&crit_capture_)); |
185 public_submodules_->gain_control_for_experimental_agc.reset( | 183 public_submodules_->gain_control_for_experimental_agc.reset( |
186 new GainControlForExperimentalAgc(public_submodules_->gain_control, | 184 new GainControlForExperimentalAgc( |
187 &crit_capture_)); | 185 public_submodules_->gain_control.get(), &crit_capture_)); |
188 private_submodules_->component_list.push_back( | |
189 public_submodules_->gain_control); | |
190 } | 186 } |
191 | 187 |
192 SetExtraOptions(config); | 188 SetExtraOptions(config); |
193 } | 189 } |
194 | 190 |
195 AudioProcessingImpl::~AudioProcessingImpl() { | 191 AudioProcessingImpl::~AudioProcessingImpl() { |
196 // Depends on gain_control_ and | 192 // Depends on gain_control_ and |
197 // public_submodules_->gain_control_for_experimental_agc. | 193 // public_submodules_->gain_control_for_experimental_agc. |
198 private_submodules_->agc_manager.reset(); | 194 private_submodules_->agc_manager.reset(); |
199 // Depends on gain_control_. | 195 // Depends on gain_control_. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 formats_.api_format.output_stream().num_frames())); | 306 formats_.api_format.output_stream().num_frames())); |
311 | 307 |
312 // Initialize all components. | 308 // Initialize all components. |
313 for (auto item : private_submodules_->component_list) { | 309 for (auto item : private_submodules_->component_list) { |
314 int err = item->Initialize(); | 310 int err = item->Initialize(); |
315 if (err != kNoError) { | 311 if (err != kNoError) { |
316 return err; | 312 return err; |
317 } | 313 } |
318 } | 314 } |
319 | 315 |
316 InitializeGainController(); | |
320 InitializeEchoCanceller(); | 317 InitializeEchoCanceller(); |
321 InitializeEchoControlMobile(); | 318 InitializeEchoControlMobile(); |
322 InitializeExperimentalAgc(); | 319 InitializeExperimentalAgc(); |
323 InitializeTransient(); | 320 InitializeTransient(); |
324 InitializeBeamformer(); | 321 InitializeBeamformer(); |
325 InitializeIntelligibility(); | 322 InitializeIntelligibility(); |
326 InitializeHighPassFilter(); | 323 InitializeHighPassFilter(); |
327 InitializeNoiseSuppression(); | 324 InitializeNoiseSuppression(); |
328 InitializeLevelEstimator(); | 325 InitializeLevelEstimator(); |
329 InitializeVoiceDetection(); | 326 InitializeVoiceDetection(); |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1094 // from the returned pointer. | 1091 // from the returned pointer. |
1095 return public_submodules_->echo_control_mobile; | 1092 return public_submodules_->echo_control_mobile; |
1096 } | 1093 } |
1097 | 1094 |
1098 GainControl* AudioProcessingImpl::gain_control() const { | 1095 GainControl* AudioProcessingImpl::gain_control() const { |
1099 // 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 |
1100 // from the returned pointer. | 1097 // from the returned pointer. |
1101 if (constants_.use_experimental_agc) { | 1098 if (constants_.use_experimental_agc) { |
1102 return public_submodules_->gain_control_for_experimental_agc.get(); | 1099 return public_submodules_->gain_control_for_experimental_agc.get(); |
1103 } | 1100 } |
1104 return public_submodules_->gain_control; | 1101 return public_submodules_->gain_control.get(); |
1105 } | 1102 } |
1106 | 1103 |
1107 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { | 1104 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { |
1108 // 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 |
1109 // from the returned pointer. | 1106 // from the returned pointer. |
1110 return public_submodules_->high_pass_filter.get(); | 1107 return public_submodules_->high_pass_filter.get(); |
1111 } | 1108 } |
1112 | 1109 |
1113 LevelEstimator* AudioProcessingImpl::level_estimator() const { | 1110 LevelEstimator* AudioProcessingImpl::level_estimator() const { |
1114 // Adding a lock here has no effect as it allows any access to the submodule | 1111 // Adding a lock here has no effect as it allows any access to the submodule |
(...skipping 13 matching lines...) Expand all Loading... | |
1128 return public_submodules_->voice_detection.get(); | 1125 return public_submodules_->voice_detection.get(); |
1129 } | 1126 } |
1130 | 1127 |
1131 bool AudioProcessingImpl::is_data_processed() const { | 1128 bool AudioProcessingImpl::is_data_processed() const { |
1132 // The beamformer, noise suppressor and highpass filter | 1129 // The beamformer, noise suppressor and highpass filter |
1133 // modify the data. | 1130 // modify the data. |
1134 if (capture_nonlocked_.beamformer_enabled || | 1131 if (capture_nonlocked_.beamformer_enabled || |
1135 public_submodules_->high_pass_filter->is_enabled() || | 1132 public_submodules_->high_pass_filter->is_enabled() || |
1136 public_submodules_->noise_suppression->is_enabled() || | 1133 public_submodules_->noise_suppression->is_enabled() || |
1137 public_submodules_->echo_cancellation->is_enabled() || | 1134 public_submodules_->echo_cancellation->is_enabled() || |
1138 public_submodules_->echo_control_mobile->is_enabled()) { | 1135 public_submodules_->echo_control_mobile->is_enabled() || |
1136 public_submodules_->gain_control->is_enabled()) { | |
1139 return true; | 1137 return true; |
1140 } | 1138 } |
1141 | 1139 |
1142 // All of the private submodules modify the data. | 1140 // All of the private submodules modify the data. |
1143 for (auto item : private_submodules_->component_list) { | 1141 for (auto item : private_submodules_->component_list) { |
1144 if (item->is_component_enabled()) { | 1142 if (item->is_component_enabled()) { |
1145 return true; | 1143 return true; |
1146 } | 1144 } |
1147 } | 1145 } |
1148 | 1146 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1192 | 1190 |
1193 bool AudioProcessingImpl::rev_conversion_needed() const { | 1191 bool AudioProcessingImpl::rev_conversion_needed() const { |
1194 return (formats_.api_format.reverse_input_stream() != | 1192 return (formats_.api_format.reverse_input_stream() != |
1195 formats_.api_format.reverse_output_stream()); | 1193 formats_.api_format.reverse_output_stream()); |
1196 } | 1194 } |
1197 | 1195 |
1198 void AudioProcessingImpl::InitializeExperimentalAgc() { | 1196 void AudioProcessingImpl::InitializeExperimentalAgc() { |
1199 if (constants_.use_experimental_agc) { | 1197 if (constants_.use_experimental_agc) { |
1200 if (!private_submodules_->agc_manager.get()) { | 1198 if (!private_submodules_->agc_manager.get()) { |
1201 private_submodules_->agc_manager.reset(new AgcManagerDirect( | 1199 private_submodules_->agc_manager.reset(new AgcManagerDirect( |
1202 public_submodules_->gain_control, | 1200 public_submodules_->gain_control.get(), |
1203 public_submodules_->gain_control_for_experimental_agc.get(), | 1201 public_submodules_->gain_control_for_experimental_agc.get(), |
1204 constants_.agc_startup_min_volume)); | 1202 constants_.agc_startup_min_volume)); |
1205 } | 1203 } |
1206 private_submodules_->agc_manager->Initialize(); | 1204 private_submodules_->agc_manager->Initialize(); |
1207 private_submodules_->agc_manager->SetCaptureMuted( | 1205 private_submodules_->agc_manager->SetCaptureMuted( |
1208 capture_.output_will_be_muted); | 1206 capture_.output_will_be_muted); |
1209 } | 1207 } |
1210 } | 1208 } |
1211 | 1209 |
1212 void AudioProcessingImpl::InitializeTransient() { | 1210 void AudioProcessingImpl::InitializeTransient() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1247 | 1245 |
1248 void AudioProcessingImpl::InitializeNoiseSuppression() { | 1246 void AudioProcessingImpl::InitializeNoiseSuppression() { |
1249 public_submodules_->noise_suppression->Initialize(num_proc_channels(), | 1247 public_submodules_->noise_suppression->Initialize(num_proc_channels(), |
1250 proc_sample_rate_hz()); | 1248 proc_sample_rate_hz()); |
1251 } | 1249 } |
1252 | 1250 |
1253 void AudioProcessingImpl::InitializeEchoCanceller() { | 1251 void AudioProcessingImpl::InitializeEchoCanceller() { |
1254 public_submodules_->echo_cancellation->Initialize(); | 1252 public_submodules_->echo_cancellation->Initialize(); |
1255 } | 1253 } |
1256 | 1254 |
1255 void AudioProcessingImpl::InitializeGainController() { | |
1256 public_submodules_->gain_control->Initialize(); | |
1257 } | |
1258 | |
1257 void AudioProcessingImpl::InitializeEchoControlMobile() { | 1259 void AudioProcessingImpl::InitializeEchoControlMobile() { |
1258 public_submodules_->echo_control_mobile->Initialize(); | 1260 public_submodules_->echo_control_mobile->Initialize(); |
1259 } | 1261 } |
1260 | 1262 |
1261 void AudioProcessingImpl::InitializeLevelEstimator() { | 1263 void AudioProcessingImpl::InitializeLevelEstimator() { |
1262 public_submodules_->level_estimator->Initialize(); | 1264 public_submodules_->level_estimator->Initialize(); |
1263 } | 1265 } |
1264 | 1266 |
1265 void AudioProcessingImpl::InitializeVoiceDetection() { | 1267 void AudioProcessingImpl::InitializeVoiceDetection() { |
1266 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); | 1268 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1461 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1463 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
1462 | 1464 |
1463 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1465 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
1464 &debug_dump_.num_bytes_left_for_log_, | 1466 &debug_dump_.num_bytes_left_for_log_, |
1465 &crit_debug_, &debug_dump_.capture)); | 1467 &crit_debug_, &debug_dump_.capture)); |
1466 return kNoError; | 1468 return kNoError; |
1467 } | 1469 } |
1468 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1470 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1469 | 1471 |
1470 } // namespace webrtc | 1472 } // namespace webrtc |
OLD | NEW |