From 170a7b52fe80b2526e86727742613816b905c5df Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Mon, 4 Nov 2024 13:52:16 +0100 Subject: [PATCH] Delete deprecated overloads of the AudioprocFloat test helper Bug: webrtc:369904700 Change-Id: I731114914f7a3e995b207d8e342d499762f75ca9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/367441 Reviewed-by: Sam Zackrisson Commit-Queue: Danil Chapovalov Reviewed-by: Artem Titov Cr-Commit-Position: refs/heads/main@{#43355} --- api/test/audioproc_float.cc | 15 +-- api/test/audioproc_float.h | 37 ------ .../test/audioproc_float_impl.cc | 111 +++++------------- .../test/audioproc_float_impl.h | 11 -- 4 files changed, 30 insertions(+), 144 deletions(-) diff --git a/api/test/audioproc_float.cc b/api/test/audioproc_float.cc index b52d78e503..6572a50450 100644 --- a/api/test/audioproc_float.cc +++ b/api/test/audioproc_float.cc @@ -13,25 +13,14 @@ #include #include +#include "absl/base/nullability.h" #include "api/audio/audio_processing.h" -#include "api/scoped_refptr.h" +#include "api/audio/builtin_audio_processing_builder.h" #include "modules/audio_processing/test/audioproc_float_impl.h" namespace webrtc { namespace test { -int AudioprocFloat(rtc::scoped_refptr audio_processing, - int argc, - char* argv[]) { - return AudioprocFloatImpl(std::move(audio_processing), argc, argv); -} - -int AudioprocFloat(std::unique_ptr ap_builder, - int argc, - char* argv[]) { - return AudioprocFloatImpl(std::move(ap_builder), argc, argv); -} - int AudioprocFloat(int argc, char* argv[]) { return AudioprocFloatImpl(std::make_unique(), argc, argv); diff --git a/api/test/audioproc_float.h b/api/test/audioproc_float.h index 98f35faf14..572834d60f 100644 --- a/api/test/audioproc_float.h +++ b/api/test/audioproc_float.h @@ -16,7 +16,6 @@ #include "absl/base/nullability.h" #include "api/audio/audio_processing.h" #include "api/audio/builtin_audio_processing_builder.h" -#include "api/scoped_refptr.h" namespace webrtc { namespace test { @@ -45,42 +44,6 @@ int AudioprocFloat( int argc, char* argv[]); -// This is an interface for the audio processing simulation utility. This -// utility can be used to simulate the audioprocessing module using a recording -// (either an AEC dump or wav files), and generate the output as a wav file. -// Any audio_processing object specified in the input is used for the -// simulation. The optional `audio_processing` object provides the -// AudioProcessing instance that is used during the simulation. Note that when -// the audio_processing object is specified all functionality that relies on -// using the AudioProcessingBuilder is deactivated, since the AudioProcessing -// object is already created and the builder is not used in the simulation. It -// is needed to pass the command line flags as `argc` and `argv`, so these can -// be interpreted properly by the utility. To see a list of all supported -// command line flags, run the executable with the '--help' flag. -[[deprecated]] int AudioprocFloat( - rtc::scoped_refptr audio_processing, - int argc, - char* argv[]); - -// This is an interface for the audio processing simulation utility. This -// utility can be used to simulate the audioprocessing module using a recording -// (either an AEC dump or wav files), and generate the output as a wav file. -// The `ap_builder` object will be used to create the AudioProcessing instance -// that is used during the simulation. The `ap_builder` supports setting of -// injectable components, which will be passed on to the created AudioProcessing -// instance. It is needed to pass the command line flags as `argc` and `argv`, -// so these can be interpreted properly by the utility. -// To get a fully-working audioproc_f utility, all that is needed is to write a -// main function, create an AudioProcessingBuilder, optionally set custom -// processing components on it, and pass the builder together with the command -// line arguments into this function. -// To see a list of all supported command line flags, run the executable with -// the '--help' flag. -[[deprecated]] int AudioprocFloat( - std::unique_ptr ap_builder, - int argc, - char* argv[]); - } // namespace test } // namespace webrtc diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc index 5814544999..8740ac02f3 100644 --- a/modules/audio_processing/test/audioproc_float_impl.cc +++ b/modules/audio_processing/test/audioproc_float_impl.cc @@ -26,6 +26,7 @@ #include "absl/flags/parse.h" #include "absl/strings/string_view.h" #include "api/audio/audio_processing.h" +#include "api/audio/builtin_audio_processing_builder.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_canceller3_factory.h" #include "api/audio/echo_detector_creator.h" @@ -544,8 +545,7 @@ void ReportConditionalErrorAndExit(bool condition, absl::string_view message) { } } -void PerformBasicParameterSanityChecks(const SimulationSettings& settings, - bool pre_constructed_ap_provided) { +void PerformBasicParameterSanityChecks(const SimulationSettings& settings) { if (settings.input_filename || settings.reverse_input_filename) { ReportConditionalErrorAndExit( !!settings.aec_dump_input_filename, @@ -730,18 +730,21 @@ void PerformBasicParameterSanityChecks(const SimulationSettings& settings, settings.pre_amplifier_gain_factor.has_value(), "Error: --pre_amplifier_gain_factor needs --pre_amplifier to be " "specified and set.\n"); +} +void CheckSettingsForBuiltinBuilderAreUnused( + const SimulationSettings& settings) { ReportConditionalErrorAndExit( - settings.aec_settings_filename && pre_constructed_ap_provided, + settings.aec_settings_filename.has_value(), "Error: The aec_settings_filename cannot be specified when a " "pre-constructed audio processing object is provided.\n"); ReportConditionalErrorAndExit( - settings.print_aec_parameter_values && pre_constructed_ap_provided, + settings.print_aec_parameter_values, "Error: The print_aec_parameter_values cannot be set when a " "pre-constructed audio processing object is provided.\n"); - if (settings.linear_aec_output_filename && pre_constructed_ap_provided) { + if (settings.linear_aec_output_filename) { std::cout << "Warning: For the linear AEC output to be stored, this must " "be configured in the AEC that is part of the provided " "AudioProcessing object." @@ -775,12 +778,8 @@ EchoCanceller3Config ReadAec3ConfigFromJsonFile(absl::string_view filename) { return cfg; } -// `Builder` is either AudioProcessingBuilder or BuiltinAudioProcessingBuilder -// TODO: bugs.webrtc.org/369904700 - inline this function when usages of -// the AudioProcessingBuilder are removed, and thus two version of this function -// are no longer needed. -template -void SetDependencies(const SimulationSettings& settings, Builder& builder) { +void SetDependencies(const SimulationSettings& settings, + BuiltinAudioProcessingBuilder& builder) { // Create and set an EchoCanceller3Factory if needed. if (settings.use_aec && *settings.use_aec) { EchoCanceller3Config cfg; @@ -810,60 +809,11 @@ void SetDependencies(const SimulationSettings& settings, Builder& builder) { } } -absl::Nonnull> Provide( - const Environment& env, - const SimulationSettings& settings, - absl::Nonnull> ap_builder) { - PerformBasicParameterSanityChecks(settings, - /*pre_constructed_ap_provided=*/false); - SetDependencies(settings, *ap_builder); - scoped_refptr ap = ap_builder->Build(env); - RTC_CHECK(ap); - return ap; -} - -absl::Nonnull> Provide( - const Environment& env, - const SimulationSettings& settings, - absl::Nonnull> - ap_builder) { - PerformBasicParameterSanityChecks(settings, - /*pre_constructed_ap_provided=*/true); - scoped_refptr ap = ap_builder->Build(env); - RTC_CHECK(ap); - return ap; -} - -absl::Nonnull> Provide( - const Environment& /*env*/, - const SimulationSettings& settings, - absl::Nullable> ap_builder) { - PerformBasicParameterSanityChecks(settings, - /*pre_constructed_ap_provided=*/false); - if (ap_builder == nullptr) { - ap_builder = std::make_unique(); - } - SetDependencies(settings, *ap_builder); - scoped_refptr ap = ap_builder->Create(); - RTC_CHECK(ap); - return ap; -} - -absl::Nonnull> Provide( - const Environment& env, - const SimulationSettings& settings, - absl::Nullable> ap_provider) { - if (ap_provider == nullptr) { - return Provide(env, settings, std::make_unique()); - } - - PerformBasicParameterSanityChecks(settings, - /*pre_constructed_ap_provided=*/true); - return ap_provider; -} - -template -int RunSimulation(AudioProcessingProvider ap_provider, int argc, char* argv[]) { +int RunSimulation( + absl::Nonnull> ap_builder, + bool builtin_builder_provided, + int argc, + char* argv[]) { std::vector args = absl::ParseCommandLine(argc, argv); if (args.size() != 1) { printf("%s", kUsageDescription); @@ -873,8 +823,15 @@ int RunSimulation(AudioProcessingProvider ap_provider, int argc, char* argv[]) { const Environment env = CreateEnvironment(&field_trials); SimulationSettings settings = CreateSettings(); - absl::Nonnull> audio_processing = - Provide(env, settings, std::move(ap_provider)); + PerformBasicParameterSanityChecks(settings); + if (builtin_builder_provided) { + SetDependencies(settings, + static_cast(*ap_builder)); + } else { + CheckSettingsForBuiltinBuilderAreUnused(settings); + } + scoped_refptr audio_processing = ap_builder->Build(env); + RTC_CHECK(audio_processing); std::unique_ptr processor; if (settings.aec_dump_input_filename || settings.aec_dump_input_string) { @@ -911,32 +868,20 @@ int RunSimulation(AudioProcessingProvider ap_provider, int argc, char* argv[]) { } // namespace -int AudioprocFloatImpl( - absl::Nullable> audio_processing, - int argc, - char* argv[]) { - return RunSimulation(std::move(audio_processing), argc, argv); -} - -int AudioprocFloatImpl( - absl::Nullable> ap_builder, - int argc, - char* argv[]) { - return RunSimulation(std::move(ap_builder), argc, argv); -} - int AudioprocFloatImpl( absl::Nonnull> ap_builder, int argc, char* argv[]) { - return RunSimulation(std::move(ap_builder), argc, argv); + return RunSimulation(std::move(ap_builder), /*builtin_builder_provided=*/true, + argc, argv); } int AudioprocFloatImpl( absl::Nonnull> ap_builder, int argc, char* argv[]) { - return RunSimulation(std::move(ap_builder), argc, argv); + return RunSimulation(std::move(ap_builder), + /*builtin_builder_provided=*/false, argc, argv); } } // namespace test diff --git a/modules/audio_processing/test/audioproc_float_impl.h b/modules/audio_processing/test/audioproc_float_impl.h index 1406287d67..bcb64d0478 100644 --- a/modules/audio_processing/test/audioproc_float_impl.h +++ b/modules/audio_processing/test/audioproc_float_impl.h @@ -16,21 +16,10 @@ #include "absl/base/nullability.h" #include "api/audio/audio_processing.h" #include "api/audio/builtin_audio_processing_builder.h" -#include "api/scoped_refptr.h" namespace webrtc { namespace test { -int AudioprocFloatImpl( - absl::Nullable> audio_processing, - int argc, - char* argv[]); - -int AudioprocFloatImpl( - absl::Nullable> ap_builder, - int argc, - char* argv[]); - int AudioprocFloatImpl( absl::Nonnull> ap_builder, int argc,