From 3fb25d40628d7c6f84abf4b6ebc916af26b12aee Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 8 Mar 2021 16:41:46 +0100 Subject: [PATCH] test/run_convert: move code to RunConvert() --- test/run_convert.cxx | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/test/run_convert.cxx b/test/run_convert.cxx index 3cba693fd..25b0e3831 100644 --- a/test/run_convert.cxx +++ b/test/run_convert.cxx @@ -101,18 +101,9 @@ public: } }; -int -main(int argc, char **argv) -try { - const auto c = ParseCommandLine(argc, argv); - - SetLogThreshold(c.verbose ? LogLevel::DEBUG : LogLevel::INFO); - const GlobalInit init(c.config_path); - - const size_t in_frame_size = c.in_audio_format.GetFrameSize(); - - PcmConvert state(c.in_audio_format, c.out_audio_format); - +static void +RunConvert(PcmConvert &convert, size_t in_frame_size) +{ StaticFifoBuffer buffer; while (true) { @@ -136,20 +127,32 @@ try { buffer.Consume(src.size); - auto output = state.Convert({src.data, src.size}); + auto output = convert.Convert({src.data, src.size}); [[maybe_unused]] ssize_t ignored = write(1, output.data, output.size); } while (true) { - auto output = state.Flush(); + auto output = convert.Flush(); if (output.IsNull()) break; [[maybe_unused]] ssize_t ignored = write(1, output.data, output.size); } +} + +int +main(int argc, char **argv) +try { + const auto c = ParseCommandLine(argc, argv); + + SetLogThreshold(c.verbose ? LogLevel::DEBUG : LogLevel::INFO); + const GlobalInit init(c.config_path); + + PcmConvert state(c.in_audio_format, c.out_audio_format); + RunConvert(state, c.in_audio_format.GetFrameSize()); return EXIT_SUCCESS; } catch (...) {