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

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

Issue 2292863002: Introduced new scheme for controlling the functionality inside the audio processing module (Closed)
Patch Set: Created 4 years, 3 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 for (int rate : AudioProcessing::kNativeSampleRatesHz) { 109 for (int rate : AudioProcessing::kNativeSampleRatesHz) {
110 if (rate >= min_proc_rate) { 110 if (rate >= min_proc_rate) {
111 return rate; 111 return rate;
112 } 112 }
113 } 113 }
114 return AudioProcessing::kMaxNativeSampleRateHz; 114 return AudioProcessing::kMaxNativeSampleRateHz;
115 } 115 }
116 116
117 } // namespace 117 } // namespace
118 118
119 bool ApmSettings::LevelControllerSettings::IsOk() const {
the sun 2016/08/30 10:32:38 I don't think this is the right place for this kno
peah-webrtc 2016/08/30 17:05:57 That makes sense. I've rewritten this. PTAL.
120 return true;
121 }
122
123 bool ApmSettings::IsOk() const {
124 return level_controller.IsOk();
125 }
126
119 // Throughout webrtc, it's assumed that success is represented by zero. 127 // Throughout webrtc, it's assumed that success is represented by zero.
120 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero"); 128 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero");
121 129
122 struct AudioProcessingImpl::ApmPublicSubmodules { 130 struct AudioProcessingImpl::ApmPublicSubmodules {
123 ApmPublicSubmodules() {} 131 ApmPublicSubmodules() {}
124 // Accessed externally of APM without any lock acquired. 132 // Accessed externally of APM without any lock acquired.
125 std::unique_ptr<EchoCancellationImpl> echo_cancellation; 133 std::unique_ptr<EchoCancellationImpl> echo_cancellation;
126 std::unique_ptr<EchoControlMobileImpl> echo_control_mobile; 134 std::unique_ptr<EchoControlMobileImpl> echo_control_mobile;
127 std::unique_ptr<GainControlImpl> gain_control; 135 std::unique_ptr<GainControlImpl> gain_control;
128 std::unique_ptr<HighPassFilterImpl> high_pass_filter; 136 std::unique_ptr<HighPassFilterImpl> high_pass_filter;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 config.Get<ExperimentalAgc>().enabled), 190 config.Get<ExperimentalAgc>().enabled),
183 #endif 191 #endif
184 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 192 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
185 capture_(false, 193 capture_(false,
186 #else 194 #else
187 capture_(config.Get<ExperimentalNs>().enabled, 195 capture_(config.Get<ExperimentalNs>().enabled,
188 #endif 196 #endif
189 config.Get<Beamforming>().array_geometry, 197 config.Get<Beamforming>().array_geometry,
190 config.Get<Beamforming>().target_direction), 198 config.Get<Beamforming>().target_direction),
191 capture_nonlocked_(config.Get<Beamforming>().enabled, 199 capture_nonlocked_(config.Get<Beamforming>().enabled,
192 config.Get<Intelligibility>().enabled, 200 config.Get<Intelligibility>().enabled) {
193 config.Get<LevelControl>().enabled) {
194 { 201 {
195 rtc::CritScope cs_render(&crit_render_); 202 rtc::CritScope cs_render(&crit_render_);
196 rtc::CritScope cs_capture(&crit_capture_); 203 rtc::CritScope cs_capture(&crit_capture_);
197 204
198 public_submodules_->echo_cancellation.reset( 205 public_submodules_->echo_cancellation.reset(
199 new EchoCancellationImpl(&crit_render_, &crit_capture_)); 206 new EchoCancellationImpl(&crit_render_, &crit_capture_));
200 public_submodules_->echo_control_mobile.reset( 207 public_submodules_->echo_control_mobile.reset(
201 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); 208 new EchoControlMobileImpl(&crit_render_, &crit_capture_));
202 public_submodules_->gain_control.reset( 209 public_submodules_->gain_control.reset(
203 new GainControlImpl(&crit_capture_, &crit_capture_)); 210 new GainControlImpl(&crit_capture_, &crit_capture_));
(...skipping 27 matching lines...) Expand all
231 #endif 238 #endif
232 } 239 }
233 240
234 int AudioProcessingImpl::Initialize() { 241 int AudioProcessingImpl::Initialize() {
235 // Run in a single-threaded manner during initialization. 242 // Run in a single-threaded manner during initialization.
236 rtc::CritScope cs_render(&crit_render_); 243 rtc::CritScope cs_render(&crit_render_);
237 rtc::CritScope cs_capture(&crit_capture_); 244 rtc::CritScope cs_capture(&crit_capture_);
238 return InitializeLocked(); 245 return InitializeLocked();
239 } 246 }
240 247
248 int AudioProcessingImpl::ApplySettings(const ApmSettings& settings) {
249 bool settings_ok = settings.IsOk();
250 RTC_DCHECK(settings_ok);
251
252 if (!settings_ok) {
hlundin-webrtc 2016/08/30 11:26:26 I think you can be more aggressive, and simply RTC
peah-webrtc 2016/08/30 17:05:57 I think it is not absolutely necessary to CHECK he
253 return -1;
254 }
255
256 // Run in a single-threaded manner when applying the settings.
257 rtc::CritScope cs_render(&crit_render_);
258 rtc::CritScope cs_capture(&crit_capture_);
259
260 capture_nonlocked_.level_controller_enabled =
261 settings.level_controller.enabled;
262 if (capture_nonlocked_.level_controller_enabled) {
263 InitializeLevelController();
264 }
265 LOG(LS_INFO) << "Level controller activated: "
266 << capture_nonlocked_.level_controller_enabled;
267
268 return settings_ok ? 0 : -1;
269 }
270
241 int AudioProcessingImpl::Initialize(int input_sample_rate_hz, 271 int AudioProcessingImpl::Initialize(int input_sample_rate_hz,
242 int output_sample_rate_hz, 272 int output_sample_rate_hz,
243 int reverse_sample_rate_hz, 273 int reverse_sample_rate_hz,
244 ChannelLayout input_layout, 274 ChannelLayout input_layout,
245 ChannelLayout output_layout, 275 ChannelLayout output_layout,
246 ChannelLayout reverse_layout) { 276 ChannelLayout reverse_layout) {
247 const ProcessingConfig processing_config = { 277 const ProcessingConfig processing_config = {
248 {{input_sample_rate_hz, 278 {{input_sample_rate_hz,
249 ChannelsFromLayout(input_layout), 279 ChannelsFromLayout(input_layout),
250 LayoutHasKeyboard(input_layout)}, 280 LayoutHasKeyboard(input_layout)},
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 450
421 public_submodules_->echo_cancellation->SetExtraOptions(config); 451 public_submodules_->echo_cancellation->SetExtraOptions(config);
422 452
423 if (capture_.transient_suppressor_enabled != 453 if (capture_.transient_suppressor_enabled !=
424 config.Get<ExperimentalNs>().enabled) { 454 config.Get<ExperimentalNs>().enabled) {
425 capture_.transient_suppressor_enabled = 455 capture_.transient_suppressor_enabled =
426 config.Get<ExperimentalNs>().enabled; 456 config.Get<ExperimentalNs>().enabled;
427 InitializeTransient(); 457 InitializeTransient();
428 } 458 }
429 459
430 if (capture_nonlocked_.level_controller_enabled !=
431 config.Get<LevelControl>().enabled) {
432 capture_nonlocked_.level_controller_enabled =
433 config.Get<LevelControl>().enabled;
434 LOG(LS_INFO) << "Level controller activated: "
435 << config.Get<LevelControl>().enabled;
436
437 InitializeLevelController();
438 }
439
440 #if WEBRTC_INTELLIGIBILITY_ENHANCER 460 #if WEBRTC_INTELLIGIBILITY_ENHANCER
441 if(capture_nonlocked_.intelligibility_enabled != 461 if(capture_nonlocked_.intelligibility_enabled !=
442 config.Get<Intelligibility>().enabled) { 462 config.Get<Intelligibility>().enabled) {
443 capture_nonlocked_.intelligibility_enabled = 463 capture_nonlocked_.intelligibility_enabled =
444 config.Get<Intelligibility>().enabled; 464 config.Get<Intelligibility>().enabled;
445 InitializeIntelligibility(); 465 InitializeIntelligibility();
446 } 466 }
447 #endif 467 #endif
448 468
449 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 469 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1538 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1519 1539
1520 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1540 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1521 &debug_dump_.num_bytes_left_for_log_, 1541 &debug_dump_.num_bytes_left_for_log_,
1522 &crit_debug_, &debug_dump_.capture)); 1542 &crit_debug_, &debug_dump_.capture));
1523 return kNoError; 1543 return kNoError;
1524 } 1544 }
1525 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1545 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1526 1546
1527 } // namespace webrtc 1547 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698