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

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

Issue 2834643002: audioproc_f with simulated mic analog gain (Closed)
Patch Set: comments addressed Created 3 years, 8 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..9e7aad0420b79347f25d96f95747ab990206a8c7 100644
--- a/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc
+++ b/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc
@@ -8,7 +8,9 @@
* 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"
@@ -68,8 +70,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,13 +159,15 @@ void AecDumpBasedSimulator::PrepareProcessStreamCall(
// 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;
- } else {
- *set_stream_analog_level_called = false;
- }
+ RTC_CHECK(msg.has_level()); // Level is always logged in AEC dumps.
peah-webrtc 2017/05/02 21:27:32 It is probably fine, but I haven't checked the pro
+ // When the analog gain is simulated, use the gain suggested by AGC instead of
+ // that stored in the AEC dump.
+ RTC_CHECK_EQ(AudioProcessing::kNoError,
+ ap_->gain_control()->set_stream_analog_level(
peah-webrtc 2017/05/02 21:27:32 What about putting the set_stream_analog_level cal
+ settings_.simulate_mic_gain ?
+ last_specified_microphone_level_ : msg.level()));
+ // TODO(aleloi): If settings_.simulate_mic_gain, set undo level to
peah-webrtc 2017/05/02 21:27:33 It would be good to have FakeRecordingDevice as pa
+ // |msg.level()| via FakeRecordingDevice::NotifyAudioDeviceLevel().
}
void AecDumpBasedSimulator::VerifyProcessStreamBitExactness(
@@ -562,14 +565,19 @@ 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) {
+ if (settings_.simulate_mic_gain) {
+ // Store analog level for the next analyzed frame.
+ last_specified_microphone_level_ =
+ ap_->gain_control()->stream_analog_level();
peah-webrtc 2017/05/02 21:27:32 What about putting the stream_analog_level call in
+ // TODO(aleloi): Set the returned value into a FakeRecordingDevice instance
+ // via FakeRecordingDevice::set_analog_level() instead of using
+ // last_specified_microphone_level_.
+ } else {
// 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