AudioProcessingImplLockTest: stop using ApplyConfig()

`AudioProcessingImpl::ApplyConfig()` is deprecated, instead this CL uses
`AudioProcessingBuilderForTesting::SetConfig()`.

Also includes code style improvements.

Bug: webrtc:5298
Change-Id: Id6790bd110f2eb87deafa851f5c83c3fd00692b9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235376
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35288}
This commit is contained in:
Alessio Bazzica
2021-11-01 09:23:38 +01:00
committed by WebRTC LUCI CQ
parent 4c039d57e1
commit 58d6bef0d4

View File

@ -24,9 +24,11 @@
#include "test/gtest.h"
namespace webrtc {
namespace {
constexpr int kMaxFrameSize = 480;
constexpr int kTestTimeOutLimit = 10 * 60 * 1000;
class AudioProcessingImplLockTest;
// Type of the render thread APM API call to use in the test.
@ -305,14 +307,14 @@ class CaptureProcessor {
rtc::Event* render_call_event,
rtc::Event* capture_call_event,
FrameCounters* shared_counters_state,
TestConfig* test_config,
const TestConfig* test_config,
AudioProcessing* apm);
void Process();
private:
static const int kMaxCallDifference = 10;
static const float kCaptureInputFloatLevel;
static const int kCaptureInputFixLevel = 1024;
static constexpr int kMaxCallDifference = 10;
static constexpr float kCaptureInputFloatLevel = 0.03125f;
static constexpr int kCaptureInputFixLevel = 1024;
void PrepareFrame();
void CallApmCaptureSide();
@ -331,13 +333,13 @@ class CaptureProcessor {
class StatsProcessor {
public:
StatsProcessor(RandomGenerator* rand_gen,
TestConfig* test_config,
const TestConfig* test_config,
AudioProcessing* apm);
void Process();
private:
RandomGenerator* rand_gen_ = nullptr;
TestConfig* test_config_ = nullptr;
const TestConfig* const test_config_ = nullptr;
AudioProcessing* apm_ = nullptr;
};
@ -349,14 +351,14 @@ class RenderProcessor {
rtc::Event* render_call_event,
rtc::Event* capture_call_event,
FrameCounters* shared_counters_state,
TestConfig* test_config,
const TestConfig* test_config,
AudioProcessing* apm);
void Process();
private:
static const int kMaxCallDifference = 10;
static const int kRenderInputFixLevel = 16384;
static const float kRenderInputFloatLevel;
static constexpr int kMaxCallDifference = 10;
static constexpr int kRenderInputFixLevel = 16384;
static constexpr float kRenderInputFloatLevel = 0.5f;
void PrepareFrame();
void CallApmRenderSide();
@ -380,10 +382,6 @@ class AudioProcessingImplLockTest
bool MaybeEndTest();
private:
static const int kTestTimeOutLimit = 10 * 60 * 1000;
static const int kMaxFrameSize = 480;
// ::testing::TestWithParam<> implementation
void SetUp() override;
void TearDown() override;
@ -428,8 +426,8 @@ class AudioProcessingImplLockTest
// Thread related variables.
mutable RandomGenerator rand_gen_;
const TestConfig test_config_;
rtc::scoped_refptr<AudioProcessing> apm_;
TestConfig test_config_;
FrameCounters frame_counters_;
RenderProcessor render_thread_state_;
CaptureProcessor capture_thread_state_;
@ -476,8 +474,24 @@ void PopulateAudioFrame(float amplitude,
}
}
AudioProcessing::Config GetApmTestConfig(AecType aec_type) {
AudioProcessing::Config apm_config;
apm_config.echo_canceller.enabled = aec_type != AecType::AecTurnedOff;
apm_config.echo_canceller.mobile_mode =
aec_type == AecType::BasicWebRtcAecSettingsWithAecMobile;
apm_config.gain_controller1.enabled = true;
apm_config.gain_controller1.mode =
AudioProcessing::Config::GainController1::kAdaptiveDigital;
apm_config.noise_suppression.enabled = true;
apm_config.voice_detection.enabled = true;
return apm_config;
}
AudioProcessingImplLockTest::AudioProcessingImplLockTest()
: apm_(AudioProcessingBuilderForTesting().Create()),
: test_config_(GetParam()),
apm_(AudioProcessingBuilderForTesting()
.SetConfig(GetApmTestConfig(test_config_.aec_type))
.Create()),
render_thread_state_(kMaxFrameSize,
&rand_gen_,
&render_call_event_,
@ -508,22 +522,7 @@ bool AudioProcessingImplLockTest::MaybeEndTest() {
return false;
}
// Setup of test and APM.
void AudioProcessingImplLockTest::SetUp() {
test_config_ = static_cast<TestConfig>(GetParam());
AudioProcessing::Config apm_config = apm_->GetConfig();
apm_config.echo_canceller.enabled =
(test_config_.aec_type != AecType::AecTurnedOff);
apm_config.echo_canceller.mobile_mode =
(test_config_.aec_type == AecType::BasicWebRtcAecSettingsWithAecMobile);
apm_config.gain_controller1.enabled = true;
apm_config.gain_controller1.mode =
AudioProcessing::Config::GainController1::kAdaptiveDigital;
apm_config.noise_suppression.enabled = true;
apm_config.voice_detection.enabled = true;
apm_->ApplyConfig(apm_config);
}
void AudioProcessingImplLockTest::SetUp() {}
void AudioProcessingImplLockTest::TearDown() {
render_call_event_.Set();
@ -531,7 +530,7 @@ void AudioProcessingImplLockTest::TearDown() {
}
StatsProcessor::StatsProcessor(RandomGenerator* rand_gen,
TestConfig* test_config,
const TestConfig* test_config,
AudioProcessing* apm)
: rand_gen_(rand_gen), test_config_(test_config), apm_(apm) {}
@ -556,14 +555,12 @@ void StatsProcessor::Process() {
apm_->GetStatistics();
}
const float CaptureProcessor::kCaptureInputFloatLevel = 0.03125f;
CaptureProcessor::CaptureProcessor(int max_frame_size,
RandomGenerator* rand_gen,
rtc::Event* render_call_event,
rtc::Event* capture_call_event,
FrameCounters* shared_counters_state,
TestConfig* test_config,
const TestConfig* test_config,
AudioProcessing* apm)
: rand_gen_(rand_gen),
render_call_event_(render_call_event),
@ -787,14 +784,12 @@ void CaptureProcessor::ApplyRuntimeSettingScheme() {
frame_data_.input_number_of_channels);
}
const float RenderProcessor::kRenderInputFloatLevel = 0.5f;
RenderProcessor::RenderProcessor(int max_frame_size,
RandomGenerator* rand_gen,
rtc::Event* render_call_event,
rtc::Event* capture_call_event,
FrameCounters* shared_counters_state,
TestConfig* test_config,
const TestConfig* test_config,
AudioProcessing* apm)
: rand_gen_(rand_gen),
render_call_event_(render_call_event),
@ -1003,7 +998,7 @@ void RenderProcessor::ApplyRuntimeSettingScheme() {
frame_data_.input_number_of_channels);
}
} // anonymous namespace
} // namespace
TEST_P(AudioProcessingImplLockTest, LockTest) {
// Run test and verify that it did not time out.