Add PlayoutVolumeChange RuntimeSetting.

Add a PlayoutVolumeChange RuntimeSetting. Trigger an echo path change when the playout volume is changed.

Bug: webrtc:10608
Change-Id: I1e736b93c1865d08c7d2582f6fe00216c1e1f72e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135746
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Fredrik Hernqvist <fhernqvist@webrtc.org>
Commit-Queue: Fredrik Hernqvist <fhernqvist@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27913}
This commit is contained in:
Fredrik Hernqvist
2019-05-10 15:50:02 +02:00
committed by Commit Bot
parent eb9bf411f3
commit ca362855e1
8 changed files with 113 additions and 7 deletions

View File

@ -296,6 +296,59 @@ TEST(AudioProcessingImplTest,
apm->ProcessStream(&frame);
}
TEST(AudioProcessingImplTest, EchoControllerObservesPlayoutVolumeChange) {
// Tests that the echo controller observes an echo path gain change when a
// playout volume change is reported.
auto echo_control_factory = absl::make_unique<MockEchoControlFactory>();
const auto* echo_control_factory_ptr = echo_control_factory.get();
std::unique_ptr<AudioProcessing> apm(
AudioProcessingBuilder()
.SetEchoControlFactory(std::move(echo_control_factory))
.Create());
apm->gain_control()->Enable(false); // Disable AGC.
apm->gain_control()->set_mode(GainControl::Mode::kFixedDigital);
AudioFrame frame;
constexpr int16_t kAudioLevel = 10000;
constexpr size_t kSampleRateHz = 48000;
constexpr size_t kNumChannels = 2;
InitializeAudioFrame(kSampleRateHz, kNumChannels, &frame);
FillFixedFrame(kAudioLevel, &frame);
MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext();
EXPECT_CALL(*echo_control_mock, AnalyzeCapture(NotNull())).Times(1);
EXPECT_CALL(*echo_control_mock,
ProcessCapture(NotNull(), /*echo_path_change=*/false))
.Times(1);
apm->ProcessStream(&frame);
EXPECT_CALL(*echo_control_mock, AnalyzeCapture(NotNull())).Times(1);
EXPECT_CALL(*echo_control_mock,
ProcessCapture(NotNull(), /*echo_path_change=*/false))
.Times(1);
apm->SetRuntimeSetting(
AudioProcessing::RuntimeSetting::CreatePlayoutVolumeChange(50));
apm->ProcessStream(&frame);
EXPECT_CALL(*echo_control_mock, AnalyzeCapture(NotNull())).Times(1);
EXPECT_CALL(*echo_control_mock,
ProcessCapture(NotNull(), /*echo_path_change=*/false))
.Times(1);
apm->SetRuntimeSetting(
AudioProcessing::RuntimeSetting::CreatePlayoutVolumeChange(50));
apm->ProcessStream(&frame);
EXPECT_CALL(*echo_control_mock, AnalyzeCapture(NotNull())).Times(1);
EXPECT_CALL(*echo_control_mock,
ProcessCapture(NotNull(), /*echo_path_change=*/true))
.Times(1);
apm->SetRuntimeSetting(
AudioProcessing::RuntimeSetting::CreatePlayoutVolumeChange(100));
apm->ProcessStream(&frame);
}
TEST(AudioProcessingImplTest, RenderPreProcessorBeforeEchoDetector) {
// Make sure that signal changes caused by a render pre-processing sub-module
// take place before any echo detector analysis.