summaryrefslogtreecommitdiff
path: root/test/run_convert.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-09-05 12:19:20 +0200
committerMax Kellermann <max@musicpd.org>2016-09-09 14:44:13 +0200
commitae1eb9ccdeb16183ad3faaf8dbf548b1934889db (patch)
tree17456fa28a7a030cbba445512def9c0bb9f8e306 /test/run_convert.cxx
parent860064c8128fd12b2ae6a32d399f01fe6390a223 (diff)
pcm/Convert: migrate from class Error to C++ exceptions
Diffstat (limited to 'test/run_convert.cxx')
-rw-r--r--test/run_convert.cxx20
1 files changed, 8 insertions, 12 deletions
diff --git a/test/run_convert.cxx b/test/run_convert.cxx
index 8b89831a5..a07e71f47 100644
--- a/test/run_convert.cxx
+++ b/test/run_convert.cxx
@@ -38,8 +38,9 @@
#include <stdio.h>
#include <unistd.h>
-int main(int argc, char **argv)
-{
+int
+main(int argc, char **argv)
+try {
AudioFormat in_audio_format, out_audio_format;
if (argc != 3) {
@@ -68,10 +69,7 @@ int main(int argc, char **argv)
const size_t in_frame_size = in_audio_format.GetFrameSize();
PcmConvert state;
- if (!state.Open(in_audio_format, out_audio_format_mask, error)) {
- LogError(error, "Failed to open PcmConvert");
- return EXIT_FAILURE;
- }
+ state.Open(in_audio_format, out_audio_format_mask);
StaticFifoBuffer<uint8_t, 4096> buffer;
@@ -96,12 +94,7 @@ int main(int argc, char **argv)
buffer.Consume(src.size);
- auto output = state.Convert({src.data, src.size}, error);
- if (output.IsNull()) {
- state.Close();
- LogError(error, "Failed to convert");
- return EXIT_FAILURE;
- }
+ auto output = state.Convert({src.data, src.size});
gcc_unused ssize_t ignored = write(1, output.data,
output.size);
@@ -110,4 +103,7 @@ int main(int argc, char **argv)
state.Close();
return EXIT_SUCCESS;
+} catch (const std::exception &e) {
+ LogError(e);
+ return EXIT_FAILURE;
}