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

Unified Diff: webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc

Issue 2834643002: audioproc_f with simulated mic analog gain (Closed)
Patch Set: FakeRecordingDevice interface simplified, UTs fixes, logs verbosity-- Created 3 years, 7 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
Index: webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc
diff --git a/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc b/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc
index d1cd48424a1cfcb3708c170f2a1a91d866f35887..237fb79d57097663eeb3486c9cafdf18b9ce7c1b 100644
--- a/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc
+++ b/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc
@@ -8,11 +8,14 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include <algorithm>
#include <iostream>
+#include <utility>
#include "webrtc/modules/audio_processing/test/aec_dump_based_simulator.h"
#include "webrtc/base/checks.h"
+#include "webrtc/base/logging.h"
#include "webrtc/modules/audio_processing/test/protobuf_utils.h"
#include "webrtc/test/testsupport/trace_to_stderr.h"
@@ -63,13 +66,16 @@ bool VerifyFloatBitExactness(const webrtc::audioproc::Stream& msg,
} // namespace
AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings)
- : AudioProcessingSimulator(settings) {}
+ : AudioProcessingSimulator(settings) {
+ if (settings_.simulate_mic_gain) {
+ LOG(LS_VERBOSE) << "Setting mic gain undo level from AEC dump";
peah-webrtc 2017/05/05 20:25:21 I think that the log line is a bit unclear. What
AleBzk 2017/05/16 08:53:02 I see your point, it comes out of the blue as it i
+ }
+}
AecDumpBasedSimulator::~AecDumpBasedSimulator() = default;
void AecDumpBasedSimulator::PrepareProcessStreamCall(
- const webrtc::audioproc::Stream& msg,
- bool* set_stream_analog_level_called) {
+ const webrtc::audioproc::Stream& msg) {
if (msg.has_input_data()) {
// Fixed interface processing.
// Verify interface invariance.
@@ -156,14 +162,21 @@ void AecDumpBasedSimulator::PrepareProcessStreamCall(
ap_->set_stream_key_pressed(*settings_.use_ts);
}
- // TODO(peah): Add support for controlling the analog level via the
- // command-line.
- if (msg.has_level()) {
- RTC_CHECK_EQ(AudioProcessing::kNoError,
- ap_->gain_control()->set_stream_analog_level(msg.level()));
- *set_stream_analog_level_called = true;
+ // Level is always logged in AEC dumps.
+ RTC_CHECK(msg.has_level());
+
+ if (settings_.simulate_mic_gain) {
+ // When the analog gain is simulated, set the undo level to |msg.level()| to
+ // virtually restore the unmodified microphone signal level.
+ real_recording_device_level_ = msg.level();
} else {
- *set_stream_analog_level_called = false;
+ // When the analog gain is not simulated, the AEC dump level has to be used
+ // in AudioProcessingSimulator::ProcessStream().
+ if (last_specified_microphone_level_ != msg.level()) {
+ LOG(LS_VERBOSE) << "AEC dump overriding AGC suggested level to "
peah-webrtc 2017/05/05 20:25:21 (last_specified_microphone_level_ != msg.level())
AleBzk 2017/05/16 08:53:03 At that point of code, there's no simulation of th
+ << msg.level();
+ }
+ last_specified_microphone_level_ = msg.level();
}
}
@@ -562,14 +575,8 @@ void AecDumpBasedSimulator::HandleMessage(const webrtc::audioproc::Init& msg) {
void AecDumpBasedSimulator::HandleMessage(
const webrtc::audioproc::Stream& msg) {
- bool set_stream_analog_level_called = false;
- PrepareProcessStreamCall(msg, &set_stream_analog_level_called);
+ PrepareProcessStreamCall(msg);
ProcessStream(interface_used_ == InterfaceType::kFixedInterface);
- if (set_stream_analog_level_called) {
- // Call stream analog level to ensure that any side-effects are triggered.
- (void)ap_->gain_control()->stream_analog_level();
- }
-
VerifyProcessStreamBitExactness(msg);
}

Powered by Google App Engine
This is Rietveld 408576698