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

Unified Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 1494593004: Make VoiceDetection not a ProcessingComponent. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase+comment Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/audio_processing_impl.cc
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index 67ad266d508ed62da32e6e689308cbb031628de2..2143fe18785d8cd1f0b313b2879780e8f29c9b42 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -149,8 +149,7 @@ struct AudioProcessingImpl::ApmPublicSubmodules {
ApmPublicSubmodules()
: echo_cancellation(nullptr),
echo_control_mobile(nullptr),
- gain_control(nullptr),
- voice_detection(nullptr) {}
+ gain_control(nullptr) {}
// Accessed externally of APM without any lock acquired.
EchoCancellationImpl* echo_cancellation;
EchoControlMobileImpl* echo_control_mobile;
@@ -158,7 +157,7 @@ struct AudioProcessingImpl::ApmPublicSubmodules {
rtc::scoped_ptr<HighPassFilterImpl> high_pass_filter;
rtc::scoped_ptr<LevelEstimatorImpl> level_estimator;
rtc::scoped_ptr<NoiseSuppressionImpl> noise_suppression;
- VoiceDetectionImpl* voice_detection;
+ rtc::scoped_ptr<VoiceDetectionImpl> voice_detection;
rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc;
// Accessed internally from both render and capture.
@@ -246,8 +245,8 @@ AudioProcessingImpl::AudioProcessingImpl(const Config& config,
new LevelEstimatorImpl(&crit_capture_));
public_submodules_->noise_suppression.reset(
new NoiseSuppressionImpl(&crit_capture_));
- public_submodules_->voice_detection =
- new VoiceDetectionImpl(this, &crit_capture_);
+ public_submodules_->voice_detection.reset(
+ new VoiceDetectionImpl(&crit_capture_));
public_submodules_->gain_control_for_new_agc.reset(
new GainControlForNewAgc(public_submodules_->gain_control));
@@ -257,8 +256,6 @@ AudioProcessingImpl::AudioProcessingImpl(const Config& config,
public_submodules_->echo_control_mobile);
private_submodules_->component_list.push_back(
public_submodules_->gain_control);
- private_submodules_->component_list.push_back(
- public_submodules_->voice_detection);
}
SetExtraOptions(config);
@@ -396,6 +393,7 @@ int AudioProcessingImpl::InitializeLocked() {
InitializeHighPassFilter();
InitializeNoiseSuppression();
InitializeLevelEstimator();
+ InitializeVoiceDetection();
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
if (debug_dump_.debug_file->Open()) {
@@ -776,7 +774,7 @@ int AudioProcessingImpl::ProcessStreamLocked() {
public_submodules_->noise_suppression->ProcessCaptureAudio(ca);
RETURN_ON_ERR(
public_submodules_->echo_control_mobile->ProcessCaptureAudio(ca));
- RETURN_ON_ERR(public_submodules_->voice_detection->ProcessCaptureAudio(ca));
+ public_submodules_->voice_detection->ProcessCaptureAudio(ca);
if (constants_.use_new_agc &&
public_submodules_->gain_control->is_enabled() &&
@@ -1162,7 +1160,7 @@ NoiseSuppression* AudioProcessingImpl::noise_suppression() const {
VoiceDetection* AudioProcessingImpl::voice_detection() const {
// Adding a lock here has no effect as it allows any access to the submodule
// from the returned pointer.
- return public_submodules_->voice_detection;
+ return public_submodules_->voice_detection.get();
}
bool AudioProcessingImpl::is_data_processed() const {
@@ -1185,6 +1183,9 @@ bool AudioProcessingImpl::is_data_processed() const {
if (public_submodules_->level_estimator->is_enabled()) {
enabled_count++;
}
+ if (public_submodules_->voice_detection->is_enabled()) {
+ enabled_count++;
+ }
// Data is unchanged if no components are enabled, or if only
// public_submodules_->level_estimator
@@ -1313,6 +1314,10 @@ void AudioProcessingImpl::InitializeLevelEstimator() {
public_submodules_->level_estimator->Initialize();
}
+void AudioProcessingImpl::InitializeVoiceDetection() {
+ public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz());
+}
+
void AudioProcessingImpl::MaybeUpdateHistograms() {
static const int kMinDiffDelayMs = 60;
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.h ('k') | webrtc/modules/audio_processing/voice_detection_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698