diff options
author | Max Kellermann <max@duempel.org> | 2015-01-14 21:56:28 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-01-14 21:56:28 +0100 |
commit | 1caa41a623ccadb2f019f901f98c07e01ea0c9e2 (patch) | |
tree | ed4f315900cff152f81df5ccf2e00662b1818c00 /test/run_encoder.cxx | |
parent | bf5963528045b65125fb379570f7c8a86a61ae5e (diff) |
test/run_encoder: use EncoderToOutputStream()
Diffstat (limited to 'test/run_encoder.cxx')
-rw-r--r-- | test/run_encoder.cxx | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/test/run_encoder.cxx b/test/run_encoder.cxx index 42d934dbd..8d8ec5164 100644 --- a/test/run_encoder.cxx +++ b/test/run_encoder.cxx @@ -21,29 +21,19 @@ #include "encoder/EncoderList.hxx" #include "encoder/EncoderPlugin.hxx" #include "encoder/EncoderInterface.hxx" +#include "encoder/ToOutputStream.hxx" #include "AudioFormat.hxx" #include "AudioParser.hxx" #include "config/ConfigData.hxx" +#include "fs/io/StdioOutputStream.hxx" #include "util/Error.hxx" #include "Log.hxx" -#include "stdbin.h" #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <unistd.h> -static void -encoder_to_stdout(Encoder &encoder) -{ - size_t length; - static char buffer[32768]; - - while ((length = encoder_read(&encoder, buffer, sizeof(buffer))) > 0) { - gcc_unused ssize_t ignored = write(1, buffer, length); - } -} - int main(int argc, char **argv) { const char *encoder_name; @@ -95,7 +85,12 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - encoder_to_stdout(*encoder); + StdioOutputStream os(stdout); + + if (!EncoderToOutputStream(os, *encoder, error)) { + LogError(error); + return EXIT_FAILURE; + } /* do it */ @@ -106,7 +101,10 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - encoder_to_stdout(*encoder); + if (!EncoderToOutputStream(os, *encoder, error)) { + LogError(error); + return EXIT_FAILURE; + } } if (!encoder_end(encoder, error)) { @@ -114,7 +112,10 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - encoder_to_stdout(*encoder); + if (!EncoderToOutputStream(os, *encoder, error)) { + LogError(error); + return EXIT_FAILURE; + } encoder->Close(); encoder->Dispose(); |