Remove test code related to unused variables `input_aecdump` and `processed_capture_samples` are never used, so the code related to those variables, can be removed. Bug: none Change-Id: I4f0b7db01f1e218f62e732ab9a247dd0b9708666 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/356542 Reviewed-by: Per Ã…hgren <peah@webrtc.org> Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47105}
diff --git a/modules/audio_processing/test/aec_dump_based_simulator.cc b/modules/audio_processing/test/aec_dump_based_simulator.cc index 7af6d41..f78ab46 100644 --- a/modules/audio_processing/test/aec_dump_based_simulator.cc +++ b/modules/audio_processing/test/aec_dump_based_simulator.cc
@@ -19,7 +19,6 @@ #include <iostream> #include <memory> #include <optional> -#include <sstream> // no-presubmit-check TODO(webrtc:8982) #include <string> #include <utility> @@ -79,18 +78,6 @@ return true; } -// Selectively reads the next proto-buf message from dump-file or string input. -// Returns a bool indicating whether a new message was available. -bool ReadNextMessage(bool use_dump_file, - FILE* dump_input_file, - std::stringstream& input, - audioproc::Event& event_msg) { - if (use_dump_file) { - return ReadMessageFromFile(dump_input_file, &event_msg); - } - return ReadMessageFromString(&input, &event_msg); -} - } // namespace AecDumpBasedSimulator::AecDumpBasedSimulator( @@ -256,19 +243,12 @@ CheckedDivExact(sample_rate_hz, kChunksPerSecond), 1)); } - const bool use_dump_file = !settings_.aec_dump_input_string.has_value(); - std::stringstream input; - if (use_dump_file) { - dump_input_file_ = - OpenFile(settings_.aec_dump_input_filename->c_str(), "rb"); - } else { - input << settings_.aec_dump_input_string.value(); - } + dump_input_file_ = OpenFile(settings_.aec_dump_input_filename->c_str(), "rb"); audioproc::Event event_msg; int capture_frames_since_init = 0; int init_index = 0; - while (ReadNextMessage(use_dump_file, dump_input_file_, input, event_msg)) { + while (ReadMessageFromFile(dump_input_file_, &event_msg)) { SelectivelyToggleDataDumping(init_index, capture_frames_since_init); HandleEvent(event_msg, capture_frames_since_init, init_index); @@ -281,28 +261,19 @@ *settings_.init_to_process >= init_index); } - if (use_dump_file) { - fclose(dump_input_file_); - } + fclose(dump_input_file_); DetachAecDump(); } void AecDumpBasedSimulator::Analyze() { - const bool use_dump_file = !settings_.aec_dump_input_string.has_value(); - std::stringstream input; - if (use_dump_file) { - dump_input_file_ = - OpenFile(settings_.aec_dump_input_filename->c_str(), "rb"); - } else { - input << settings_.aec_dump_input_string.value(); - } + dump_input_file_ = OpenFile(settings_.aec_dump_input_filename->c_str(), "rb"); audioproc::Event event_msg; int num_capture_frames = 0; int num_render_frames = 0; int init_index = 0; - while (ReadNextMessage(use_dump_file, dump_input_file_, input, event_msg)) { + while (ReadMessageFromFile(dump_input_file_, &event_msg)) { if (event_msg.type() == audioproc::Event::INIT) { ++init_index; constexpr float kNumFramesPerSecond = 100.f; @@ -323,9 +294,7 @@ } } - if (use_dump_file) { - fclose(dump_input_file_); - } + fclose(dump_input_file_); } void AecDumpBasedSimulator::HandleEvent(const audioproc::Event& event_msg,
diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc index 66e2713..aa1af17 100644 --- a/modules/audio_processing/test/audio_processing_simulator.cc +++ b/modules/audio_processing/test/audio_processing_simulator.cc
@@ -222,11 +222,7 @@ applied_input_volume_ = ap_->recommended_stream_analog_level(); } - if (buffer_memory_writer_) { - RTC_CHECK(!buffer_file_writer_); - buffer_memory_writer_->Write(*out_buf_); - } else if (buffer_file_writer_) { - RTC_CHECK(!buffer_memory_writer_); + if (buffer_file_writer_) { buffer_file_writer_->Write(*out_buf_); } @@ -373,9 +369,6 @@ static_cast<size_t>(out_config_.num_channels()), settings_.wav_output_format)); buffer_file_writer_.reset(new ChannelBufferWavWriter(std::move(out_file))); - } else if (settings_.aec_dump_input_string.has_value()) { - buffer_memory_writer_ = std::make_unique<ChannelBufferVectorWriter>( - settings_.processed_capture_samples); } if (settings_.linear_aec_output_filename) {
diff --git a/modules/audio_processing/test/audio_processing_simulator.h b/modules/audio_processing/test/audio_processing_simulator.h index 3ac6023..1bf5c1b 100644 --- a/modules/audio_processing/test/audio_processing_simulator.h +++ b/modules/audio_processing/test/audio_processing_simulator.h
@@ -21,7 +21,6 @@ #include <vector> #include "absl/base/nullability.h" -#include "absl/strings/string_view.h" #include "api/audio/audio_processing.h" #include "api/scoped_refptr.h" #include "common_audio/channel_buffer.h" @@ -152,8 +151,6 @@ std::optional<std::string> call_order_input_filename; std::optional<std::string> call_order_output_filename; std::optional<std::string> aec_settings_filename; - std::optional<absl::string_view> aec_dump_input_string; - std::vector<float>* processed_capture_samples = nullptr; bool analysis_only = false; std::optional<int> dump_start_frame; std::optional<int> dump_end_frame; @@ -244,7 +241,6 @@ size_t num_reverse_process_stream_calls_ = 0; std::unique_ptr<ChannelBufferWavWriter> buffer_file_writer_; std::unique_ptr<ChannelBufferWavWriter> reverse_buffer_file_writer_; - std::unique_ptr<ChannelBufferVectorWriter> buffer_memory_writer_; std::unique_ptr<WavWriter> linear_aec_output_file_writer_; ApiCallStatistics api_call_statistics_; std::ofstream residual_echo_likelihood_graph_writer_;
diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc index a6b26f1..589fa1a 100644 --- a/modules/audio_processing/test/audioproc_float_impl.cc +++ b/modules/audio_processing/test/audioproc_float_impl.cc
@@ -565,11 +565,6 @@ "Error: The aec dump file cannot be specified " "together with input wav files!\n"); - ReportConditionalErrorAndExit( - !!settings.aec_dump_input_string, - "Error: The aec dump input string cannot be specified " - "together with input wav files!\n"); - ReportConditionalErrorAndExit(!!settings.artificial_nearend_filename, "Error: The artificial nearend cannot be " "specified together with input wav files!\n"); @@ -585,13 +580,8 @@ "must be specified if the reverse output wav filename is specified!\n"); } else { ReportConditionalErrorAndExit( - !settings.aec_dump_input_filename && !settings.aec_dump_input_string, - "Error: Either the aec dump input file, the wav " - "input file or the aec dump input string must be specified!\n"); - ReportConditionalErrorAndExit( - settings.aec_dump_input_filename && settings.aec_dump_input_string, - "Error: The aec dump input file cannot be specified together with the " - "aec dump input string!\n"); + !settings.aec_dump_input_filename, + "Error: The aec dump input file must be specified!\n"); } ReportConditionalErrorAndExit(settings.use_aec && !(*settings.use_aec) && @@ -857,7 +847,7 @@ RTC_CHECK(audio_processing); std::unique_ptr<AudioProcessingSimulator> processor; - if (settings.aec_dump_input_filename || settings.aec_dump_input_string) { + if (settings.aec_dump_input_filename) { processor = std::make_unique<AecDumpBasedSimulator>( settings, std::move(audio_processing)); } else {
diff --git a/modules/audio_processing/test/protobuf_utils.cc b/modules/audio_processing/test/protobuf_utils.cc index fb0c082..227966e 100644 --- a/modules/audio_processing/test/protobuf_utils.cc +++ b/modules/audio_processing/test/protobuf_utils.cc
@@ -14,35 +14,12 @@ #include <cstdint> #include <cstdio> #include <memory> -#include <sstream> // no-presubmit-check TODO(webrtc:8982) #include "rtc_base/protobuf_utils.h" #include "rtc_base/system/arch.h" namespace webrtc { -namespace { -// Allocates new memory in the memory owned by the unique_ptr to fit the raw -// message and returns the number of bytes read when having a string stream as -// input. -size_t ReadMessageBytesFromString(std::stringstream* input, - std::unique_ptr<uint8_t[]>* bytes) { - int32_t size = 0; - input->read(reinterpret_cast<char*>(&size), sizeof(int32_t)); - int32_t size_read = input->gcount(); - if (size_read != sizeof(int32_t)) - return 0; - if (size <= 0) - return 0; - - *bytes = std::make_unique<uint8_t[]>(size); - input->read(reinterpret_cast<char*>(bytes->get()), - size * sizeof((*bytes)[0])); - size_read = input->gcount(); - return size_read == size ? size : 0; -} -} // namespace - size_t ReadMessageBytesFromFile(FILE* file, std::unique_ptr<uint8_t[]>* bytes) { // The "wire format" for the size is little-endian. Assume we're running on // a little-endian machine. @@ -70,15 +47,4 @@ return msg->ParseFromArray(bytes.get(), size); } -// Returns true on success, false on error or end of string stream. -bool ReadMessageFromString(std::stringstream* input, MessageLite* msg) { - std::unique_ptr<uint8_t[]> bytes; - size_t size = ReadMessageBytesFromString(input, &bytes); - if (!size) - return false; - - msg->Clear(); - return msg->ParseFromArray(bytes.get(), size); -} - } // namespace webrtc
diff --git a/modules/audio_processing/test/protobuf_utils.h b/modules/audio_processing/test/protobuf_utils.h index 2685a4c..77f1491 100644 --- a/modules/audio_processing/test/protobuf_utils.h +++ b/modules/audio_processing/test/protobuf_utils.h
@@ -15,7 +15,6 @@ #include <cstdint> #include <cstdio> #include <memory> -#include <sstream> // no-presubmit-check TODO(webrtc:8982) #include "rtc_base/protobuf_utils.h" @@ -31,11 +30,6 @@ // Returns true on success, false on error or end-of-file. bool ReadMessageFromFile(FILE* file, MessageLite* msg); -// Returns true on success, false on error or end of string stream. -bool ReadMessageFromString( - std::stringstream* input, // no-presubmit-check TODO(webrtc:8982) - MessageLite* msg); - } // namespace webrtc #endif // MODULES_AUDIO_PROCESSING_TEST_PROTOBUF_UTILS_H_
diff --git a/modules/audio_processing/test/test_utils.cc b/modules/audio_processing/test/test_utils.cc index d4b221d..24cf176 100644 --- a/modules/audio_processing/test/test_utils.cc +++ b/modules/audio_processing/test/test_utils.cc
@@ -113,25 +113,6 @@ file_->WriteSamples(&interleaved_[0], interleaved_.size()); } -ChannelBufferVectorWriter::ChannelBufferVectorWriter(std::vector<float>* output) - : output_(output) { - RTC_DCHECK(output_); -} - -ChannelBufferVectorWriter::~ChannelBufferVectorWriter() = default; - -void ChannelBufferVectorWriter::Write(const ChannelBuffer<float>& buffer) { - // Account for sample rate changes throughout a simulation. - interleaved_buffer_.resize(buffer.size()); - InterleavedView<float> view(&interleaved_buffer_[0], buffer.num_frames(), - buffer.num_channels()); - Interleave(buffer.channels(), buffer.num_frames(), buffer.num_channels(), - view); - size_t old_size = output_->size(); - output_->resize(old_size + interleaved_buffer_.size()); - FloatToFloatS16(interleaved_buffer_.data(), interleaved_buffer_.size(), - output_->data() + old_size); -} FILE* OpenFile(absl::string_view filename, absl::string_view mode) { std::string filename_str(filename);
diff --git a/modules/audio_processing/test/test_utils.h b/modules/audio_processing/test/test_utils.h index e979c85..114cd13 100644 --- a/modules/audio_processing/test/test_utils.h +++ b/modules/audio_processing/test/test_utils.h
@@ -101,25 +101,6 @@ std::vector<float> interleaved_; }; -// Takes a pointer to a vector. Allows appending the samples of channel buffers -// to the given vector, by interleaving the samples and converting them to float -// S16. -class ChannelBufferVectorWriter final { - public: - explicit ChannelBufferVectorWriter(std::vector<float>* output); - ChannelBufferVectorWriter(const ChannelBufferVectorWriter&) = delete; - ChannelBufferVectorWriter& operator=(const ChannelBufferVectorWriter&) = - delete; - ~ChannelBufferVectorWriter(); - - // Creates an interleaved copy of `buffer`, converts the samples to float S16 - // and appends the result to output_. - void Write(const ChannelBuffer<float>& buffer); - - private: - std::vector<float> interleaved_buffer_; - std::vector<float>* output_; -}; // Exits on failure; do not use in unit tests. FILE* OpenFile(absl::string_view filename, absl::string_view mode);