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

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: Removed the validation method and added logging of the config settings and revertion to default val… 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 struct AudioProcessingImpl::ApmPrivateSubmodules { 142 struct AudioProcessingImpl::ApmPrivateSubmodules {
143 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) 143 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer)
144 : beamformer(beamformer) {} 144 : beamformer(beamformer) {}
145 // Accessed internally from capture or during initialization 145 // Accessed internally from capture or during initialization
146 std::unique_ptr<NonlinearBeamformer> beamformer; 146 std::unique_ptr<NonlinearBeamformer> beamformer;
147 std::unique_ptr<AgcManagerDirect> agc_manager; 147 std::unique_ptr<AgcManagerDirect> agc_manager;
148 std::unique_ptr<LevelController> level_controller; 148 std::unique_ptr<LevelController> level_controller;
149 }; 149 };
150 150
151 AudioProcessing* AudioProcessing::Create() { 151 AudioProcessing* AudioProcessing::Create() {
152 Config config; 152 webrtc::Config config;
153 return Create(config, nullptr); 153 return Create(config, nullptr);
154 } 154 }
155 155
156 AudioProcessing* AudioProcessing::Create(const Config& config) { 156 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config) {
157 return Create(config, nullptr); 157 return Create(config, nullptr);
158 } 158 }
159 159
160 AudioProcessing* AudioProcessing::Create(const Config& config, 160 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config,
161 NonlinearBeamformer* beamformer) { 161 NonlinearBeamformer* beamformer) {
162 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); 162 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer);
163 if (apm->Initialize() != kNoError) { 163 if (apm->Initialize() != kNoError) {
164 delete apm; 164 delete apm;
165 apm = nullptr; 165 apm = nullptr;
166 } 166 }
167 167
168 return apm; 168 return apm;
169 } 169 }
170 170
171 AudioProcessingImpl::AudioProcessingImpl(const Config& config) 171 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config)
172 : AudioProcessingImpl(config, nullptr) {} 172 : AudioProcessingImpl(config, nullptr) {}
173 173
174 AudioProcessingImpl::AudioProcessingImpl(const Config& config, 174 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config,
175 NonlinearBeamformer* beamformer) 175 NonlinearBeamformer* beamformer)
176 : public_submodules_(new ApmPublicSubmodules()), 176 : public_submodules_(new ApmPublicSubmodules()),
177 private_submodules_(new ApmPrivateSubmodules(beamformer)), 177 private_submodules_(new ApmPrivateSubmodules(beamformer)),
178 constants_(config.Get<ExperimentalAgc>().startup_min_volume, 178 constants_(config.Get<ExperimentalAgc>().startup_min_volume,
179 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 179 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
180 false), 180 false),
181 #else 181 #else
182 config.Get<ExperimentalAgc>().enabled), 182 config.Get<ExperimentalAgc>().enabled),
183 #endif 183 #endif
184 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 184 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
185 capture_(false, 185 capture_(false,
186 #else 186 #else
187 capture_(config.Get<ExperimentalNs>().enabled, 187 capture_(config.Get<ExperimentalNs>().enabled,
188 #endif 188 #endif
189 config.Get<Beamforming>().array_geometry, 189 config.Get<Beamforming>().array_geometry,
190 config.Get<Beamforming>().target_direction), 190 config.Get<Beamforming>().target_direction),
191 capture_nonlocked_(config.Get<Beamforming>().enabled, 191 capture_nonlocked_(config.Get<Beamforming>().enabled,
192 config.Get<Intelligibility>().enabled, 192 config.Get<Intelligibility>().enabled) {
193 config.Get<LevelControl>().enabled) {
194 { 193 {
195 rtc::CritScope cs_render(&crit_render_); 194 rtc::CritScope cs_render(&crit_render_);
196 rtc::CritScope cs_capture(&crit_capture_); 195 rtc::CritScope cs_capture(&crit_capture_);
197 196
198 public_submodules_->echo_cancellation.reset( 197 public_submodules_->echo_cancellation.reset(
199 new EchoCancellationImpl(&crit_render_, &crit_capture_)); 198 new EchoCancellationImpl(&crit_render_, &crit_capture_));
200 public_submodules_->echo_control_mobile.reset( 199 public_submodules_->echo_control_mobile.reset(
201 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); 200 new EchoControlMobileImpl(&crit_render_, &crit_capture_));
202 public_submodules_->gain_control.reset( 201 public_submodules_->gain_control.reset(
203 new GainControlImpl(&crit_capture_, &crit_capture_)); 202 new GainControlImpl(&crit_capture_, &crit_capture_));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) { 405 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) {
407 capture_nonlocked_.split_rate = kSampleRate16kHz; 406 capture_nonlocked_.split_rate = kSampleRate16kHz;
408 } else { 407 } else {
409 capture_nonlocked_.split_rate = 408 capture_nonlocked_.split_rate =
410 capture_nonlocked_.fwd_proc_format.sample_rate_hz(); 409 capture_nonlocked_.fwd_proc_format.sample_rate_hz();
411 } 410 }
412 411
413 return InitializeLocked(); 412 return InitializeLocked();
414 } 413 }
415 414
416 void AudioProcessingImpl::SetExtraOptions(const Config& config) { 415 void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
416 AudioProcessing::Config config_to_use = config;
417
418 bool config_ok = LevelController::Validate(config_to_use.level_controller);
the sun 2016/09/07 15:49:39 I really like this; nice and clear.
hlundin-webrtc 2016/09/07 21:13:05 Agree. But wouldn't it be nice if ApplyConfig retu
peah-webrtc 2016/09/08 09:13:48 I agree but my concern with that is that we would
peah-webrtc 2016/09/08 09:13:48 Acknowledged.
419 if (!config_ok) {
420 LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl
421 << LevelController::ToString(config_to_use.level_controller)
422 << std::endl
423 << "Reverting to default parameter set";
424 config_to_use.level_controller = LevelController::DefaultConfig();
hlundin-webrtc 2016/09/07 21:13:05 I don't think you need the DefaultConfig() functio
peah-webrtc 2016/09/08 09:13:48 The Config is a struct that is defined inside audi
the sun 2016/09/08 09:45:55 Going forward, I'd like to see the Config definiti
peah-webrtc 2016/09/08 19:34:24 That makes sense. Done.
425 }
426
427 // Run in a single-threaded manner when applying the settings.
428 rtc::CritScope cs_render(&crit_render_);
the sun 2016/09/07 15:49:39 Nice that you're making the locked section as smal
peah-webrtc 2016/09/08 09:13:48 :-)
429 rtc::CritScope cs_capture(&crit_capture_);
430
431 if (config.level_controller.enabled !=
432 capture_nonlocked_.level_controller_enabled) {
433 InitializeLevelController();
434 LOG(LS_INFO) << "Level controller activated: "
435 << capture_nonlocked_.level_controller_enabled;
436 capture_nonlocked_.level_controller_enabled =
437 config.level_controller.enabled;
438 }
439 }
440
441 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) {
417 // Run in a single-threaded manner when setting the extra options. 442 // Run in a single-threaded manner when setting the extra options.
418 rtc::CritScope cs_render(&crit_render_); 443 rtc::CritScope cs_render(&crit_render_);
419 rtc::CritScope cs_capture(&crit_capture_); 444 rtc::CritScope cs_capture(&crit_capture_);
420 445
421 public_submodules_->echo_cancellation->SetExtraOptions(config); 446 public_submodules_->echo_cancellation->SetExtraOptions(config);
422 447
423 if (capture_.transient_suppressor_enabled != 448 if (capture_.transient_suppressor_enabled !=
424 config.Get<ExperimentalNs>().enabled) { 449 config.Get<ExperimentalNs>().enabled) {
425 capture_.transient_suppressor_enabled = 450 capture_.transient_suppressor_enabled =
426 config.Get<ExperimentalNs>().enabled; 451 config.Get<ExperimentalNs>().enabled;
427 InitializeTransient(); 452 InitializeTransient();
428 } 453 }
429 454
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 455 #if WEBRTC_INTELLIGIBILITY_ENHANCER
441 if(capture_nonlocked_.intelligibility_enabled != 456 if(capture_nonlocked_.intelligibility_enabled !=
442 config.Get<Intelligibility>().enabled) { 457 config.Get<Intelligibility>().enabled) {
443 capture_nonlocked_.intelligibility_enabled = 458 capture_nonlocked_.intelligibility_enabled =
444 config.Get<Intelligibility>().enabled; 459 config.Get<Intelligibility>().enabled;
445 InitializeIntelligibility(); 460 InitializeIntelligibility();
446 } 461 }
447 #endif 462 #endif
448 463
449 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 464 #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); 1533 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1519 1534
1520 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1535 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1521 &debug_dump_.num_bytes_left_for_log_, 1536 &debug_dump_.num_bytes_left_for_log_,
1522 &crit_debug_, &debug_dump_.capture)); 1537 &crit_debug_, &debug_dump_.capture));
1523 return kNoError; 1538 return kNoError;
1524 } 1539 }
1525 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1540 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1526 1541
1527 } // namespace webrtc 1542 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698