diff options
Diffstat (limited to 'test/run_encoder.cxx')
-rw-r--r-- | test/run_encoder.cxx | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/test/run_encoder.cxx b/test/run_encoder.cxx index 838ee708e..a71b815f5 100644 --- a/test/run_encoder.cxx +++ b/test/run_encoder.cxx @@ -24,10 +24,11 @@ #include "AudioParser.hxx" #include "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); } |