diff options
author | Max Kellermann <max@musicpd.org> | 2021-03-08 16:50:32 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2021-03-08 16:51:57 +0100 |
commit | e777fb4edb94090955a292b1aa8ac039aef66905 (patch) | |
tree | 452a5dc226c2bf4b5ebc3d719700d91e3e9a8425 /test/run_convert.cxx | |
parent | 3fb25d40628d7c6f84abf4b6ebc916af26b12aee (diff) |
test/run_convert: pass FileDescriptor to RunConvert()
Diffstat (limited to 'test/run_convert.cxx')
-rw-r--r-- | test/run_convert.cxx | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/test/run_convert.cxx b/test/run_convert.cxx index 25b0e3831..7d20ea2f9 100644 --- a/test/run_convert.cxx +++ b/test/run_convert.cxx @@ -29,6 +29,7 @@ #include "pcm/Convert.hxx" #include "fs/Path.hxx" #include "fs/NarrowPath.hxx" +#include "io/FileDescriptor.hxx" #include "util/ConstBuffer.hxx" #include "util/StaticFifoBuffer.hxx" #include "util/OptionDef.hxx" @@ -102,7 +103,8 @@ public: }; static void -RunConvert(PcmConvert &convert, size_t in_frame_size) +RunConvert(PcmConvert &convert, size_t in_frame_size, + FileDescriptor in_fd, FileDescriptor out_fd) { StaticFifoBuffer<uint8_t, 4096> buffer; @@ -111,7 +113,7 @@ RunConvert(PcmConvert &convert, size_t in_frame_size) const auto dest = buffer.Write(); assert(!dest.empty()); - ssize_t nbytes = read(0, dest.data, dest.size); + ssize_t nbytes = in_fd.Read(dest.data, dest.size); if (nbytes <= 0) break; @@ -128,9 +130,7 @@ RunConvert(PcmConvert &convert, size_t in_frame_size) buffer.Consume(src.size); auto output = convert.Convert({src.data, src.size}); - - [[maybe_unused]] ssize_t ignored = write(1, output.data, - output.size); + out_fd.FullWrite(output.data, output.size); } while (true) { @@ -138,8 +138,7 @@ RunConvert(PcmConvert &convert, size_t in_frame_size) if (output.IsNull()) break; - [[maybe_unused]] ssize_t ignored = write(1, output.data, - output.size); + out_fd.FullWrite(output.data, output.size); } } @@ -152,7 +151,9 @@ try { const GlobalInit init(c.config_path); PcmConvert state(c.in_audio_format, c.out_audio_format); - RunConvert(state, c.in_audio_format.GetFrameSize()); + RunConvert(state, c.in_audio_format.GetFrameSize(), + FileDescriptor(STDIN_FILENO), + FileDescriptor(STDOUT_FILENO)); return EXIT_SUCCESS; } catch (...) { |