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

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

Issue 2834643002: audioproc_f with simulated mic analog gain (Closed)
Patch Set: AGC simulated gain 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..e7be0fa7a5c80417c315abd0c1253c819b84b575 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"
@@ -68,8 +71,7 @@ AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings)
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.
@@ -158,12 +160,24 @@ void AecDumpBasedSimulator::PrepareProcessStreamCall(
// TODO(peah): Add support for controlling the analog level via the
peah-webrtc 2017/05/05 06:28:41 You can remove this TODO in this CL :-)
AleBzk 2017/05/05 12:20:17 Done.
// 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;
- } else {
- *set_stream_analog_level_called = false;
+
+ // Level is always logged in AEC dumps.
+ RTC_CHECK(msg.has_level());
+
+ // When the analog gain is simulated, set the undo level to |msg.level()| to
+ // virtually restore the unmodified microphone signal level.
+ if (settings_.simulate_mic_gain) {
+ fake_recording_device_.NotifyAudioDeviceLevel(msg.level());
peah-webrtc 2017/05/05 06:28:41 I'd prefer all the handling of the fake_recording_
AleBzk 2017/05/05 12:20:17 Right. I made fake_recording_device_ private inste
+ LOG(LS_VERBOSE) << "setting mic gain undo level from AEC dump to "
peah-webrtc 2017/05/05 06:28:41 setting->Setting?
AleBzk 2017/05/05 12:20:17 Done.
+ << msg.level();
aleloi 2017/05/04 12:47:13 This would get logged once for every audio frame.
peah-webrtc 2017/05/05 06:28:41 Yes, I agree. The logging here is only in test cod
AleBzk 2017/05/05 12:20:17 I moved this in the ctor so it's shown once.
+ }
+
+ // When the analog gain is not simulated, the AEC dump level has to be used in
+ // AudioProcessingSimulator::ProcessStream().
+ if (!settings_.simulate_mic_gain) {
aleloi 2017/05/04 12:47:13 Suggest merge into the if statement above as an el
AleBzk 2017/05/05 12:20:17 Done.
AleBzk 2017/05/05 12:20:17 Done.
+ fake_recording_device_.set_analog_level(msg.level());
+ LOG(LS_VERBOSE) << "AEC dump overriding AGC suggested level to "
+ << msg.level();
}
}
@@ -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