aboutsummaryrefslogtreecommitdiffstats
path: root/test/run_encoder.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/run_encoder.cxx50
1 files changed, 25 insertions, 25 deletions
diff --git a/test/run_encoder.cxx b/test/run_encoder.cxx
index 838ee708e..f16d8cb0a 100644
--- a/test/run_encoder.cxx
+++ b/test/run_encoder.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2013 The Music Player Daemon Project
+ * Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,16 +18,17 @@
*/
#include "config.h"
-#include "EncoderList.hxx"
-#include "EncoderPlugin.hxx"
+#include "encoder/EncoderList.hxx"
+#include "encoder/EncoderPlugin.hxx"
#include "AudioFormat.hxx"
#include "AudioParser.hxx"
-#include "ConfigData.hxx"
+#include "config/ConfigData.hxx"
#include "util/Error.hxx"
+#include "Log.hxx"
#include "stdbin.h"
-#include <glib.h>
-
+#include <stdio.h>
+#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
@@ -50,8 +51,9 @@ int main(int argc, char **argv)
/* parse command line */
if (argc > 3) {
- g_printerr("Usage: run_encoder [ENCODER] [FORMAT] <IN >OUT\n");
- return 1;
+ fprintf(stderr,
+ "Usage: run_encoder [ENCODER] [FORMAT] <IN >OUT\n");
+ return EXIT_FAILURE;
}
if (argc > 1)
@@ -63,8 +65,8 @@ int main(int argc, char **argv)
const auto plugin = encoder_plugin_get(encoder_name);
if (plugin == NULL) {
- g_printerr("No such encoder: %s\n", encoder_name);
- return 1;
+ fprintf(stderr, "No such encoder: %s\n", encoder_name);
+ return EXIT_FAILURE;
}
config_param param;
@@ -73,9 +75,8 @@ int main(int argc, char **argv)
Error error;
const auto encoder = encoder_init(*plugin, param, error);
if (encoder == NULL) {
- g_printerr("Failed to initialize encoder: %s\n",
- error.GetMessage());
- return 1;
+ LogError(error, "Failed to initialize encoder");
+ return EXIT_FAILURE;
}
/* open the encoder */
@@ -83,16 +84,14 @@ int main(int argc, char **argv)
AudioFormat audio_format(44100, SampleFormat::S16, 2);
if (argc > 2) {
if (!audio_format_parse(audio_format, argv[2], false, error)) {
- g_printerr("Failed to parse audio format: %s\n",
- error.GetMessage());
- return 1;
+ LogError(error, "Failed to parse audio format");
+ return EXIT_FAILURE;
}
}
if (!encoder_open(encoder, audio_format, error)) {
- g_printerr("Failed to open encoder: %s\n",
- error.GetMessage());
- return 1;
+ LogError(error, "Failed to open encoder");
+ return EXIT_FAILURE;
}
encoder_to_stdout(*encoder);
@@ -102,19 +101,20 @@ int main(int argc, char **argv)
ssize_t nbytes;
while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
if (!encoder_write(encoder, buffer, nbytes, error)) {
- g_printerr("encoder_write() failed: %s\n",
- error.GetMessage());
- return 1;
+ LogError(error, "encoder_write() failed");
+ return EXIT_FAILURE;
}
encoder_to_stdout(*encoder);
}
if (!encoder_end(encoder, error)) {
- g_printerr("encoder_flush() failed: %s\n",
- error.GetMessage());
- return 1;
+ LogError(error, "encoder_flush() failed");
+ return EXIT_FAILURE;
}
encoder_to_stdout(*encoder);
+
+ encoder_close(encoder);
+ encoder_finish(encoder);
}