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

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

Issue 2337083002: Reland of added functionality for specifying the initial signal level to use for the gain estimation (Closed)
Patch Set: Changed parameter name from initial_level to the more correct initial_peak_level 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 public_submodules_->level_estimator.reset( 291 public_submodules_->level_estimator.reset(
292 new LevelEstimatorImpl(&crit_capture_)); 292 new LevelEstimatorImpl(&crit_capture_));
293 public_submodules_->noise_suppression.reset( 293 public_submodules_->noise_suppression.reset(
294 new NoiseSuppressionImpl(&crit_capture_)); 294 new NoiseSuppressionImpl(&crit_capture_));
295 public_submodules_->voice_detection.reset( 295 public_submodules_->voice_detection.reset(
296 new VoiceDetectionImpl(&crit_capture_)); 296 new VoiceDetectionImpl(&crit_capture_));
297 public_submodules_->gain_control_for_experimental_agc.reset( 297 public_submodules_->gain_control_for_experimental_agc.reset(
298 new GainControlForExperimentalAgc( 298 new GainControlForExperimentalAgc(
299 public_submodules_->gain_control.get(), &crit_capture_)); 299 public_submodules_->gain_control.get(), &crit_capture_));
300 300
301 // TODO(peah): Move this creation to happen only when the level controller
302 // is enabled.
301 private_submodules_->level_controller.reset(new LevelController()); 303 private_submodules_->level_controller.reset(new LevelController());
302 } 304 }
303 305
304 SetExtraOptions(config); 306 SetExtraOptions(config);
305 } 307 }
306 308
307 AudioProcessingImpl::~AudioProcessingImpl() { 309 AudioProcessingImpl::~AudioProcessingImpl() {
308 // Depends on gain_control_ and 310 // Depends on gain_control_ and
309 // public_submodules_->gain_control_for_experimental_agc. 311 // public_submodules_->gain_control_for_experimental_agc.
310 private_submodules_->agc_manager.reset(); 312 private_submodules_->agc_manager.reset();
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 capture_nonlocked_.split_rate = kSampleRate16kHz; 519 capture_nonlocked_.split_rate = kSampleRate16kHz;
518 } else { 520 } else {
519 capture_nonlocked_.split_rate = 521 capture_nonlocked_.split_rate =
520 capture_nonlocked_.fwd_proc_format.sample_rate_hz(); 522 capture_nonlocked_.fwd_proc_format.sample_rate_hz();
521 } 523 }
522 524
523 return InitializeLocked(); 525 return InitializeLocked();
524 } 526 }
525 527
526 void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) { 528 void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
527 AudioProcessing::Config config_to_use = config; 529 config_ = config;
528 530
529 bool config_ok = LevelController::Validate(config_to_use.level_controller); 531 bool config_ok = LevelController::Validate(config_.level_controller);
530 if (!config_ok) { 532 if (!config_ok) {
531 LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl 533 LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl
532 << "level_controller: " 534 << "level_controller: "
533 << LevelController::ToString(config_to_use.level_controller) 535 << LevelController::ToString(config.level_controller)
534 << std::endl 536 << std::endl
535 << "Reverting to default parameter set"; 537 << "Reverting to default parameter set";
536 config_to_use.level_controller = AudioProcessing::Config::LevelController(); 538 AudioProcessing::Config::LevelController default_config;
539 config_.level_controller = default_config;
the sun 2016/09/16 12:40:24 nit: Do this in one line. No need to name temporar
peah-webrtc 2016/09/19 16:37:10 Done.
537 } 540 }
538 541
539 // Run in a single-threaded manner when applying the settings. 542 // Run in a single-threaded manner when applying the settings.
540 rtc::CritScope cs_render(&crit_render_); 543 rtc::CritScope cs_render(&crit_render_);
541 rtc::CritScope cs_capture(&crit_capture_); 544 rtc::CritScope cs_capture(&crit_capture_);
542 545
543 if (config.level_controller.enabled != 546 // TODO(peah): Replace the use of capture_nonlocked_.level_controller_enabled
547 // with the value in config_ everywhere in the code.
548 if (config_.level_controller.enabled !=
544 capture_nonlocked_.level_controller_enabled) { 549 capture_nonlocked_.level_controller_enabled) {
550 capture_nonlocked_.level_controller_enabled =
551 config.level_controller.enabled;
the sun 2016/09/16 12:40:24 config_ where is the test case? nit: it is nice i
peah-webrtc 2016/09/19 16:37:10 The test case is in audio_processing_unittests.cc.
the sun 2016/09/19 18:53:56 Ah, the problem with the test is it checks the fla
peah-webrtc 2016/09/22 06:00:06 I fully agree. We should definitely have that. For
552 // TODO(peah): Remove the conditional initialization to always initialize
553 // the level controller regardless of whether it is enabled or not.
545 InitializeLevelController(); 554 InitializeLevelController();
555 // TODO(peah): Add logline regardless of whether this is enabled or not.
546 LOG(LS_INFO) << "Level controller activated: " 556 LOG(LS_INFO) << "Level controller activated: "
547 << capture_nonlocked_.level_controller_enabled; 557 << capture_nonlocked_.level_controller_enabled;
548 capture_nonlocked_.level_controller_enabled =
549 config.level_controller.enabled;
550 } 558 }
the sun 2016/09/16 12:40:24 Did you forget lc->ApplyConfig()?
peah-webrtc 2016/09/19 16:37:10 Oh no! Great find! I for sure did miss that. I'm
the sun 2016/09/19 18:53:56 Let's discuss offline.
peah-webrtc 2016/09/22 06:00:06 Acknowledged.
551 } 559 }
552 560
553 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { 561 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) {
554 // Run in a single-threaded manner when setting the extra options. 562 // Run in a single-threaded manner when setting the extra options.
555 rtc::CritScope cs_render(&crit_render_); 563 rtc::CritScope cs_render(&crit_render_);
556 rtc::CritScope cs_capture(&crit_capture_); 564 rtc::CritScope cs_capture(&crit_capture_);
557 565
558 public_submodules_->echo_cancellation->SetExtraOptions(config); 566 public_submodules_->echo_cancellation->SetExtraOptions(config);
559 567
560 if (capture_.transient_suppressor_enabled != 568 if (capture_.transient_suppressor_enabled !=
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 fwd_proc_format(kSampleRate16kHz), 1616 fwd_proc_format(kSampleRate16kHz),
1609 split_rate(kSampleRate16kHz) {} 1617 split_rate(kSampleRate16kHz) {}
1610 1618
1611 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; 1619 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default;
1612 1620
1613 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; 1621 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default;
1614 1622
1615 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; 1623 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default;
1616 1624
1617 } // namespace webrtc 1625 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698