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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 capture_nonlocked_.split_rate = kSampleRate16kHz; | 538 capture_nonlocked_.split_rate = kSampleRate16kHz; |
537 } else { | 539 } else { |
538 capture_nonlocked_.split_rate = | 540 capture_nonlocked_.split_rate = |
539 capture_nonlocked_.capture_processing_format.sample_rate_hz(); | 541 capture_nonlocked_.capture_processing_format.sample_rate_hz(); |
540 } | 542 } |
541 | 543 |
542 return InitializeLocked(); | 544 return InitializeLocked(); |
543 } | 545 } |
544 | 546 |
545 void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) { | 547 void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) { |
546 AudioProcessing::Config config_to_use = config; | 548 config_ = config; |
547 | 549 |
548 bool config_ok = LevelController::Validate(config_to_use.level_controller); | 550 bool config_ok = LevelController::Validate(config_.level_controller); |
549 if (!config_ok) { | 551 if (!config_ok) { |
550 LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl | 552 LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl |
551 << "level_controller: " | 553 << "level_controller: " |
552 << LevelController::ToString(config_to_use.level_controller) | 554 << LevelController::ToString(config_.level_controller) |
553 << std::endl | 555 << std::endl |
554 << "Reverting to default parameter set"; | 556 << "Reverting to default parameter set"; |
555 config_to_use.level_controller = AudioProcessing::Config::LevelController(); | 557 config_.level_controller = AudioProcessing::Config::LevelController(); |
556 } | 558 } |
557 | 559 |
558 // Run in a single-threaded manner when applying the settings. | 560 // Run in a single-threaded manner when applying the settings. |
559 rtc::CritScope cs_render(&crit_render_); | 561 rtc::CritScope cs_render(&crit_render_); |
560 rtc::CritScope cs_capture(&crit_capture_); | 562 rtc::CritScope cs_capture(&crit_capture_); |
561 | 563 |
562 if (config.level_controller.enabled != | 564 // TODO(peah): Replace the use of capture_nonlocked_.level_controller_enabled |
563 capture_nonlocked_.level_controller_enabled) { | 565 // with the value in config_ everywhere in the code. |
| 566 if (capture_nonlocked_.level_controller_enabled != |
| 567 config_.level_controller.enabled) { |
| 568 capture_nonlocked_.level_controller_enabled = |
| 569 config_.level_controller.enabled; |
| 570 // TODO(peah): Remove the conditional initialization to always initialize |
| 571 // the level controller regardless of whether it is enabled or not. |
564 InitializeLevelController(); | 572 InitializeLevelController(); |
565 LOG(LS_INFO) << "Level controller activated: " | |
566 << capture_nonlocked_.level_controller_enabled; | |
567 capture_nonlocked_.level_controller_enabled = | |
568 config.level_controller.enabled; | |
569 } | 573 } |
| 574 LOG(LS_INFO) << "Level controller activated: " |
| 575 << capture_nonlocked_.level_controller_enabled; |
| 576 |
| 577 private_submodules_->level_controller->ApplyConfig(config_.level_controller); |
570 } | 578 } |
571 | 579 |
572 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { | 580 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { |
573 // Run in a single-threaded manner when setting the extra options. | 581 // Run in a single-threaded manner when setting the extra options. |
574 rtc::CritScope cs_render(&crit_render_); | 582 rtc::CritScope cs_render(&crit_render_); |
575 rtc::CritScope cs_capture(&crit_capture_); | 583 rtc::CritScope cs_capture(&crit_capture_); |
576 | 584 |
577 public_submodules_->echo_cancellation->SetExtraOptions(config); | 585 public_submodules_->echo_cancellation->SetExtraOptions(config); |
578 | 586 |
579 if (capture_.transient_suppressor_enabled != | 587 if (capture_.transient_suppressor_enabled != |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 capture_processing_format(kSampleRate16kHz), | 1590 capture_processing_format(kSampleRate16kHz), |
1583 split_rate(kSampleRate16kHz) {} | 1591 split_rate(kSampleRate16kHz) {} |
1584 | 1592 |
1585 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; | 1593 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; |
1586 | 1594 |
1587 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; | 1595 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; |
1588 | 1596 |
1589 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; | 1597 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; |
1590 | 1598 |
1591 } // namespace webrtc | 1599 } // namespace webrtc |
OLD | NEW |