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}
diff --git a/modules/audio_processing/audio_processing_impl_unittest.cc b/modules/audio_processing/audio_processing_impl_unittest.cc
index 7359f6b..d688db0 100644
--- a/modules/audio_processing/audio_processing_impl_unittest.cc
+++ b/modules/audio_processing/audio_processing_impl_unittest.cc
@@ -296,6 +296,59 @@
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.