Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: webrtc/modules/audio_processing/test/audioproc_float.cc

Issue 1308893002: Add a base class to Wav{Reader,Writer} to access shared parameters. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add virtual destructor. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/common_audio/wav_file.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_processing/test/audioproc_float.cc
diff --git a/webrtc/modules/audio_processing/test/audioproc_float.cc b/webrtc/modules/audio_processing/test/audioproc_float.cc
index 3cea5b933e2d0c1c084913af5026d6693a37ad5f..f4aab32acf4a3d55c8db1655f2accd37f303e3e9 100644
--- a/webrtc/modules/audio_processing/test/audioproc_float.cc
+++ b/webrtc/modules/audio_processing/test/audioproc_float.cc
@@ -63,6 +63,15 @@ const char kUsage[] =
"All components are disabled by default. If any bi-directional components\n"
"are enabled, only debug dump files are permitted.";
+// Returns a StreamConfig corresponding to wav_file if it's non-nullptr.
+// Otherwise returns a default initialized StreamConfig.
+StreamConfig MakeStreamConfig(const WavFile* wav_file) {
+ if (wav_file) {
+ return {wav_file->sample_rate(), wav_file->num_channels()};
+ }
+ return {};
+}
+
} // namespace
int main(int argc, char* argv[]) {
@@ -162,21 +171,11 @@ int main(int argc, char* argv[]) {
TickInterval accumulated_time;
int num_chunks = 0;
- const StreamConfig input_config = {
- in_file.sample_rate(), in_buf.num_channels(),
- };
- const StreamConfig output_config = {
- out_file.sample_rate(), out_buf.num_channels(),
- };
+ const auto input_config = MakeStreamConfig(&in_file);
+ const auto output_config = MakeStreamConfig(&out_file);
+ const auto reverse_input_config = MakeStreamConfig(in_rev_file.get());
+ const auto reverse_output_config = MakeStreamConfig(out_rev_file.get());
- StreamConfig reverse_input_config = {};
- StreamConfig reverse_output_config = {};
- if (process_reverse) {
- reverse_input_config = {in_rev_file->sample_rate(),
- in_rev_file->num_channels()};
- reverse_output_config = {out_rev_file->sample_rate(),
- out_rev_file->num_channels()};
- }
while (in_file.ReadSamples(in_interleaved.size(),
&in_interleaved[0]) == in_interleaved.size()) {
// Have logs display the file time rather than wallclock time.
« no previous file with comments | « webrtc/common_audio/wav_file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698