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

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: API simplified, UTs adapted 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..45e32f097402d23f19466ceb92adf9117eb1be9d 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,15 @@
* 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/fake_recording_device.h"
#include "webrtc/modules/audio_processing/test/protobuf_utils.h"
#include "webrtc/test/testsupport/trace_to_stderr.h"
@@ -63,13 +67,17 @@ 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) << "Simulating analog mic gain using AEC dump as input "
+ << "(the unmodified mic gain level will be virtually restored)";
+ }
+}
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 +164,20 @@ 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());
+
+ RTC_DCHECK(fake_recording_device_);
+ 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.
+ fake_recording_device_->set_undo_mic_level(rtc::Optional<int>(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() - i.e., overriding any value
+ // set from a gain controller once the previous audio frame has been
+ // analyzed.
+ fake_recording_device_->set_mic_level(msg.level());
AleBzk 2017/05/23 13:56:41 @Per: you asked to move this to the parent class a
peah-webrtc 2017/05/23 22:13:20 What I don't like with this approach is that it gi
AleBzk 2017/06/22 10:16:00 Done.
}
}
@@ -562,14 +576,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