aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_vorbis_encoder.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-01-14 21:56:28 +0100
committerMax Kellermann <max@duempel.org>2015-01-14 21:56:28 +0100
commit1caa41a623ccadb2f019f901f98c07e01ea0c9e2 (patch)
treeed4f315900cff152f81df5ccf2e00662b1818c00 /test/test_vorbis_encoder.cxx
parentbf5963528045b65125fb379570f7c8a86a61ae5e (diff)
downloadmpd-1caa41a623ccadb2f019f901f98c07e01ea0c9e2.tar.gz
mpd-1caa41a623ccadb2f019f901f98c07e01ea0c9e2.tar.xz
mpd-1caa41a623ccadb2f019f901f98c07e01ea0c9e2.zip
test/run_encoder: use EncoderToOutputStream()
Diffstat (limited to 'test/test_vorbis_encoder.cxx')
-rw-r--r--test/test_vorbis_encoder.cxx43
1 files changed, 26 insertions, 17 deletions
diff --git a/test/test_vorbis_encoder.cxx b/test/test_vorbis_encoder.cxx
index 8e6b62739..ae1b2fdf2 100644
--- a/test/test_vorbis_encoder.cxx
+++ b/test/test_vorbis_encoder.cxx
@@ -21,29 +21,20 @@
#include "encoder/EncoderList.hxx"
#include "encoder/EncoderPlugin.hxx"
#include "encoder/EncoderInterface.hxx"
+#include "encoder/ToOutputStream.hxx"
#include "AudioFormat.hxx"
#include "config/ConfigData.hxx"
-#include "stdbin.h"
+#include "fs/io/StdioOutputStream.hxx"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
#include "util/Error.hxx"
+#include "Log.hxx"
#include <stddef.h>
#include <unistd.h>
static uint8_t zero[256];
-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(gcc_unused int argc, gcc_unused char **argv)
{
@@ -66,21 +57,33 @@ main(gcc_unused int argc, gcc_unused char **argv)
success = encoder->Open(audio_format, IgnoreError());
assert(success);
- encoder_to_stdout(*encoder);
+ StdioOutputStream os(stdout);
+
+ Error error;
+ if (!EncoderToOutputStream(os, *encoder, error)) {
+ LogError(error);
+ return EXIT_FAILURE;
+ }
/* write a block of data */
success = encoder_write(encoder, zero, sizeof(zero), IgnoreError());
assert(success);
- encoder_to_stdout(*encoder);
+ if (!EncoderToOutputStream(os, *encoder, error)) {
+ LogError(error);
+ return EXIT_FAILURE;
+ }
/* write a tag */
success = encoder_pre_tag(encoder, IgnoreError());
assert(success);
- encoder_to_stdout(*encoder);
+ if (!EncoderToOutputStream(os, *encoder, error)) {
+ LogError(error);
+ return EXIT_FAILURE;
+ }
Tag tag;
@@ -94,7 +97,10 @@ main(gcc_unused int argc, gcc_unused char **argv)
success = encoder_tag(encoder, tag, IgnoreError());
assert(success);
- encoder_to_stdout(*encoder);
+ if (!EncoderToOutputStream(os, *encoder, error)) {
+ LogError(error);
+ return EXIT_FAILURE;
+ }
/* write another block of data */
@@ -106,7 +112,10 @@ main(gcc_unused int argc, gcc_unused char **argv)
success = encoder_end(encoder, IgnoreError());
assert(success);
- encoder_to_stdout(*encoder);
+ if (!EncoderToOutputStream(os, *encoder, error)) {
+ LogError(error);
+ return EXIT_FAILURE;
+ }
encoder->Close();
encoder->Dispose();