summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2021-03-08 16:41:46 +0100
committerMax Kellermann <max@musicpd.org>2021-03-08 16:46:21 +0100
commit3fb25d40628d7c6f84abf4b6ebc916af26b12aee (patch)
tree4a7bab5281edd0b4a3a8fb226bb8ddc3c9523ecc /test
parente227596c2052f28956d1767c5562d2c5a133049d (diff)
test/run_convert: move code to RunConvert()
Diffstat (limited to 'test')
-rw-r--r--test/run_convert.cxx31
1 files 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<uint8_t, 4096> 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 (...) {