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

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

Issue 1384653002: Compare serialized Configs. Base URL: https://chromium.googlesource.com/external/webrtc.git@apmconfig
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f6811d62de8f08c54fc677e976d3f1ab7aad86ac..9f4b3247bd08723b8a19c59df08459b680314b45 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -242,10 +242,6 @@ AudioProcessingImpl::AudioProcessingImpl(const Config& config,
gain_control_for_new_agc_.reset(new GainControlForNewAgc(gain_control_));
SetExtraOptions(config);
-
-#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
- UpdateCurrentConfig();
-#endif
}
AudioProcessingImpl::~AudioProcessingImpl() {
@@ -556,11 +552,9 @@ int AudioProcessingImpl::ProcessStream(const float* const* src,
api_format_.input_stream().num_frames());
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
- if (debug_file_->Open() && UpdateCurrentConfig()) {
- RETURN_ON_ERR(WriteConfigMessage());
- }
-
if (debug_file_->Open()) {
+ RETURN_ON_ERR(WriteConfigMessageIfChanged());
+
event_msg_->set_type(audioproc::Event::STREAM);
audioproc::Stream* msg = event_msg_->mutable_stream();
const size_t channel_size =
@@ -946,16 +940,8 @@ int AudioProcessingImpl::StartDebugRecording(
return kFileError;
}
- UpdateCurrentConfig();
- int err = WriteConfigMessage();
- if (err != kNoError) {
- return err;
- }
-
- err = WriteInitMessage();
- if (err != kNoError) {
- return err;
- }
+ RETURN_ON_ERR(WriteConfigMessageIfChanged());
+ RETURN_ON_ERR(WriteInitMessage());
return kNoError;
#else
return kUnsupportedFunctionError;
@@ -981,16 +967,8 @@ int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
return kFileError;
}
- UpdateCurrentConfig();
- int err = WriteConfigMessage();
- if (err != kNoError) {
- return err;
- }
-
- err = WriteInitMessage();
- if (err != kNoError) {
- return err;
- }
+ RETURN_ON_ERR(WriteConfigMessageIfChanged());
+ RETURN_ON_ERR(WriteInitMessage());
return kNoError;
#else
return kUnsupportedFunctionError;
@@ -1268,147 +1246,22 @@ int AudioProcessingImpl::WriteInitMessage() {
return kNoError;
}
-bool AudioProcessingImpl::UpdateCurrentConfig() {
- bool changed = false;
-
- // Acoustic echo canceler.
- {
- const bool value = echo_cancellation_->is_enabled();
- if (!config_->has_aec_enabled() || value != config_->aec_enabled()) {
- config_->set_aec_enabled(value);
- changed = true;
- }
- }
- {
- const bool value = echo_cancellation_->is_delay_agnostic_enabled();
- if (!config_->has_aec_delay_agnostic() ||
- value != config_->aec_delay_agnostic()) {
- config_->set_aec_delay_agnostic(value);
- changed = true;
- }
- }
- {
- const bool value = echo_cancellation_->is_drift_compensation_enabled();
- if (!config_->has_aec_drift_compensation() ||
- value != config_->aec_drift_compensation()) {
- config_->set_aec_drift_compensation(value);
- changed = true;
- }
- }
- {
- const bool value = echo_cancellation_->is_extended_filter_enabled();
- if (!config_->has_aec_extended_filter() ||
- value != config_->aec_extended_filter()) {
- config_->set_aec_extended_filter(value);
- changed = true;
- }
- }
- {
- const int value = static_cast<int>(echo_cancellation_->suppression_level());
- if (!config_->has_aec_suppression_level() ||
- value != config_->aec_suppression_level()) {
- config_->set_aec_suppression_level(value);
- changed = true;
- }
- }
-
- // Mobile AEC.
- {
- const bool value = echo_control_mobile_->is_enabled();
- if (!config_->has_aecm_enabled() || value != config_->aecm_enabled()) {
- config_->set_aecm_enabled(value);
- changed = true;
- }
- }
- {
- const bool value = echo_control_mobile_->is_comfort_noise_enabled();
- if (!config_->has_aecm_comfort_noise() ||
- value != config_->aecm_comfort_noise()) {
- config_->set_aecm_comfort_noise(value);
- changed = true;
- }
- }
- {
- const int value = static_cast<int>(echo_control_mobile_->routing_mode());
- if (!config_->has_aecm_routing_mode() ||
- value != config_->aecm_routing_mode()) {
- config_->set_aecm_routing_mode(value);
- changed = true;
- }
- }
-
- // Automatic gain controller.
- {
- const bool value = gain_control_->is_enabled();
- if (!config_->has_agc_enabled() || value != config_->agc_enabled()) {
- config_->set_agc_enabled(value);
- changed = true;
- }
- }
- {
- const bool value = use_new_agc_;
- if (!config_->has_agc_experiment() || value != config_->agc_experiment()) {
- config_->set_agc_experiment(value);
- changed = true;
- }
- }
- {
- const int value = static_cast<int>(gain_control_->mode());
- if (!config_->has_agc_mode() || value != config_->agc_mode()) {
- config_->set_agc_mode(value);
- changed = true;
- }
- }
- {
- const bool value = gain_control_->is_limiter_enabled();
- if (!config_->has_agc_limiter() || value != config_->agc_limiter()) {
- config_->set_agc_limiter(value);
- changed = true;
- }
- }
+int AudioProcessingImpl::WriteConfigMessageIfChanged() {
+ audioproc::Config config;
+ config.set_aec_enabled(echo_cancellation_->is_enabled());
+ config.set_aec_delay_agnostic(
+ echo_cancellation_->is_delay_agnostic_enabled());
+ config.set_agc_enabled(gain_control_->is_enabled());
+ // More fields...
- // High pass filter.
- {
- const bool value = high_pass_filter_->is_enabled();
- if (!config_->has_hpf_enabled() || value != config_->hpf_enabled()) {
- config_->set_hpf_enabled(value);
- changed = true;
- }
- }
+ std::string serialized_config = config.SerializeAsString();
+ if (serialized_config != last_serialized_config_) {
+ last_serialized_config_ = serialized_config;
- // Noise suppression.
- {
- const bool value = noise_suppression_->is_enabled();
- if (!config_->has_ns_enabled() || value != config_->ns_enabled()) {
- config_->set_ns_enabled(value);
- changed = true;
- }
- }
- {
- const bool value = transient_suppressor_enabled_;
- if (!config_->has_ns_experiment() || value != config_->ns_experiment()) {
- config_->set_ns_experiment(value);
- changed = true;
- }
- }
- {
- const int value = static_cast<int>(noise_suppression_->level());
- if (!config_->has_ns_level() || value != config_->ns_level()) {
- config_->set_ns_level(value);
- changed = true;
- }
- }
-
- return changed;
-}
-
-int AudioProcessingImpl::WriteConfigMessage() {
- event_msg_->set_type(audioproc::Event::CONFIG);
- event_msg_->mutable_config()->CopyFrom(*config_);
+ event_msg_->set_type(audioproc::Event::CONFIG);
+ event_msg_->mutable_config()->CopyFrom(config);
- int err = WriteMessageToDebugFile();
- if (err != kNoError) {
- return err;
+ RETURN_ON_ERR(WriteMessageToDebugFile());
}
return kNoError;
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698