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 |
Andrew MacDonald
2015/10/01 06:33:28
Why was this removed?
minyue-webrtc
2015/10/01 20:18:26
This is moved to .h since audioproc::Config is nee
|
-// 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 |
Andrew MacDonald
2015/10/01 06:33:28
Combine these #ifdef blocks.
minyue-webrtc
2015/10/01 20:18:26
Done.
|
+ |
+#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() { |
Andrew MacDonald
2015/10/01 06:33:28
I wonder if rather than checking every individual
minyue-webrtc
2015/10/01 20:18:26
I did a similar trial (not a string compare, but a
Andrew MacDonald
2015/10/02 02:15:19
I wouldn't worry about that, as it would only be u
minyue-webrtc
2015/10/02 05:29:01
I still have some questions on this. Do you mean
Andrew MacDonald
2015/10/02 06:07:39
To be clear, I mean this:
https://codereview.webrt
|
+ bool changed = false; |
+ |
+ // Acoustic echo canceler. |
+ UPDATE_CONFIG(aec_enabled, echo_cancellation_->is_enabled()); |
peah-webrtc
2015/09/30 13:13:54
Sorry, missed to send this before, had a draft tha
minyue-webrtc
2015/09/30 18:44:52
I would like to use function but it does not seem
peah-webrtc
2015/10/01 05:31:31
I'd use a function instead with more parameters.
Andrew MacDonald
2015/10/01 06:33:28
Agree with Per, I probably would not use a macro f
kwiberg-webrtc
2015/10/01 08:26:22
A good compromise might be to implement almost all
minyue-webrtc
2015/10/01 20:18:26
It is rather complicated to use inline function, s
|
+ 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 |