| 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 4ef4e6da6a307e6533e8ac9ddf39e888c2c52713..9d0632649f49c9b99cfe9897271e271a809ea9bf 100644
|
| --- a/webrtc/modules/audio_processing/audio_processing_impl.cc
|
| +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
|
| @@ -42,15 +42,6 @@ extern "C" {
|
| #include "webrtc/system_wrappers/interface/logging.h"
|
| #include "webrtc/system_wrappers/interface/metrics.h"
|
|
|
| -#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
| -// Files generated at build-time by the protobuf compiler.
|
| -#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
|
| -#include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
|
| -#else
|
| -#include "webrtc/audio_processing/debug.pb.h"
|
| -#endif
|
| -#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
|
| -
|
| #define RETURN_ON_ERR(expr) \
|
| do { \
|
| int err = (expr); \
|
| @@ -59,6 +50,15 @@ extern "C" {
|
| } \
|
| } while (0)
|
|
|
| +#define UPDATE_CONFIG(field_name, new_value) \
|
| + { \
|
| + const auto value = new_value; \
|
| + if (!config_->has_##field_name() || config_->field_name() != value) { \
|
| + config_->set_##field_name(value); \
|
| + changed = true; \
|
| + } \
|
| + }
|
| +
|
| namespace webrtc {
|
| namespace {
|
|
|
| @@ -194,6 +194,7 @@ AudioProcessingImpl::AudioProcessingImpl(const Config& config,
|
| #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
| debug_file_(FileWrapper::Create()),
|
| event_msg_(new audioproc::Event()),
|
| + config_(new audioproc::Config()),
|
| #endif
|
| api_format_({{{kSampleRate16kHz, 1, false},
|
| {kSampleRate16kHz, 1, false},
|
| @@ -250,6 +251,10 @@ 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() {
|
| @@ -560,6 +565,12 @@ 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());
|
| + }
|
| +#endif
|
| +
|
| +#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
| if (debug_file_->Open()) {
|
| event_msg_->set_type(audioproc::Event::STREAM);
|
| audioproc::Stream* msg = event_msg_->mutable_stream();
|
| @@ -946,7 +957,13 @@ int AudioProcessingImpl::StartDebugRecording(
|
| return kFileError;
|
| }
|
|
|
| - int err = WriteInitMessage();
|
| + UpdateCurrentConfig();
|
| + int err = WriteConfigMessage();
|
| + if (err != kNoError) {
|
| + return err;
|
| + }
|
| +
|
| + err = WriteInitMessage();
|
| if (err != kNoError) {
|
| return err;
|
| }
|
| @@ -975,7 +992,13 @@ int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
|
| return kFileError;
|
| }
|
|
|
| - int err = WriteInitMessage();
|
| + UpdateCurrentConfig();
|
| + int err = WriteConfigMessage();
|
| + if (err != kNoError) {
|
| + return err;
|
| + }
|
| +
|
| + err = WriteInitMessage();
|
| if (err != kNoError) {
|
| return err;
|
| }
|
| @@ -1255,6 +1278,52 @@ int AudioProcessingImpl::WriteInitMessage() {
|
|
|
| return kNoError;
|
| }
|
| +
|
| +bool AudioProcessingImpl::UpdateCurrentConfig() {
|
| + bool changed = false;
|
| +
|
| + // Acoustic echo canceler.
|
| + UPDATE_CONFIG(aec_enabled, echo_cancellation_->is_enabled());
|
| + UPDATE_CONFIG(aec_delay_agnostic,
|
| + echo_cancellation_->is_delay_agnostic_enabled());
|
| + UPDATE_CONFIG(aec_drift_compensation,
|
| + echo_cancellation_->is_drift_compensation_enabled());
|
| + UPDATE_CONFIG(aec_extended_filter,
|
| + echo_cancellation_->is_extended_filter_enabled());
|
| + UPDATE_CONFIG(aec_suppression_level,
|
| + static_cast<int>(echo_cancellation_->suppression_level()));
|
| + // Mobile AEC.
|
| + UPDATE_CONFIG(aecm_enabled, echo_control_mobile_->is_enabled());
|
| + UPDATE_CONFIG(aecm_comfort_noise,
|
| + echo_control_mobile_->is_comfort_noise_enabled());
|
| + UPDATE_CONFIG(aecm_routing_mode,
|
| + static_cast<int>(echo_control_mobile_->routing_mode()));
|
| + // Automatic gain controller.
|
| + UPDATE_CONFIG(agc_enabled, gain_control_->is_enabled());
|
| + UPDATE_CONFIG(agc_experiment, use_new_agc_);
|
| + UPDATE_CONFIG(agc_mode, static_cast<int>(gain_control_->mode()));
|
| + UPDATE_CONFIG(agc_limiter, gain_control_->is_limiter_enabled());
|
| + // High pass filter.
|
| + UPDATE_CONFIG(hpf_enabled, high_pass_filter_->is_enabled());
|
| + // Noise suppression.
|
| + UPDATE_CONFIG(ns_enabled, noise_suppression_->is_enabled());
|
| + UPDATE_CONFIG(ns_experiment, transient_suppressor_enabled_);
|
| + UPDATE_CONFIG(ns_level, static_cast<int>(noise_suppression_->level()));
|
| +
|
| + return changed;
|
| +}
|
| +
|
| +int AudioProcessingImpl::WriteConfigMessage() {
|
| + event_msg_->set_type(audioproc::Event::CONFIG);
|
| + event_msg_->mutable_config()->CopyFrom(*config_);
|
| +
|
| + int err = WriteMessageToDebugFile();
|
| + if (err != kNoError) {
|
| + return err;
|
| + }
|
| +
|
| + return kNoError;
|
| +}
|
| #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
|
|
|
| } // namespace webrtc
|
|
|