diff options
author | Max Kellermann <max@musicpd.org> | 2016-10-28 21:46:20 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-10-28 22:36:04 +0200 |
commit | 13001c018c49931e258104c3e8fffa97fb3bb374 (patch) | |
tree | 0c12e356b016553c99739bb6cdffb9bbc9e50e58 /test/run_normalize.cxx | |
parent | 1b39efb694fa1ff9924ef52e93c19b39a54e293f (diff) |
AudioParser: throw exception on error
Diffstat (limited to 'test/run_normalize.cxx')
-rw-r--r-- | test/run_normalize.cxx | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/test/run_normalize.cxx b/test/run_normalize.cxx index 71e015a2d..4631fab8d 100644 --- a/test/run_normalize.cxx +++ b/test/run_normalize.cxx @@ -27,15 +27,18 @@ #include "AudioCompress/compress.h" #include "AudioParser.hxx" #include "AudioFormat.hxx" -#include "util/Error.hxx" +#include "Log.hxx" + +#include <stdexcept> #include <stddef.h> #include <stdio.h> +#include <stdlib.h> #include <unistd.h> #include <string.h> int main(int argc, char **argv) -{ +try { struct Compressor *compressor; static char buffer[4096]; ssize_t nbytes; @@ -46,14 +49,8 @@ int main(int argc, char **argv) } AudioFormat audio_format(48000, SampleFormat::S16, 2); - if (argc > 1) { - Error error; - if (!audio_format_parse(audio_format, argv[1], false, error)) { - fprintf(stderr, "Failed to parse audio format: %s\n", - error.GetMessage()); - return 1; - } - } + if (argc > 1) + audio_format = ParseAudioFormat(argv[1], false); compressor = Compressor_new(0); @@ -65,4 +62,8 @@ int main(int argc, char **argv) } Compressor_delete(compressor); + return EXIT_SUCCESS; +} catch (const std::exception &e) { + LogError(e); + return EXIT_FAILURE; } |