summaryrefslogtreecommitdiff
path: root/test/read_mixer.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-09-09 12:52:51 +0200
committerMax Kellermann <max@musicpd.org>2016-09-09 14:44:15 +0200
commite7d327226a6383ae93970ff20c878d6a873c735f (patch)
tree9e019763d469f31e866dce0d5481239118f91d9a /test/read_mixer.cxx
parentae1eb9ccdeb16183ad3faaf8dbf548b1934889db (diff)
mixer: migrate to C++ exceptions
Diffstat (limited to 'test/read_mixer.cxx')
-rw-r--r--test/read_mixer.cxx25
1 files changed, 8 insertions, 17 deletions
diff --git a/test/read_mixer.cxx b/test/read_mixer.cxx
index 44e3f6b0d..ce45e863f 100644
--- a/test/read_mixer.cxx
+++ b/test/read_mixer.cxx
@@ -41,7 +41,7 @@ filter_plugin_by_name(gcc_unused const char *name)
}
int main(int argc, gcc_unused char **argv)
-{
+try {
int volume;
if (argc != 2) {
@@ -51,36 +51,27 @@ int main(int argc, gcc_unused char **argv)
EventLoop event_loop;
- Error error;
Mixer *mixer = mixer_new(event_loop, alsa_mixer_plugin,
*(AudioOutput *)nullptr,
*(MixerListener *)nullptr,
- ConfigBlock(), error);
- if (mixer == NULL) {
- LogError(error, "mixer_new() failed");
- return EXIT_FAILURE;
- }
+ ConfigBlock());
- if (!mixer_open(mixer, error)) {
- mixer_free(mixer);
- LogError(error, "failed to open the mixer");
- return EXIT_FAILURE;
- }
+ mixer_open(mixer);
- volume = mixer_get_volume(mixer, error);
+ volume = mixer_get_volume(mixer);
mixer_close(mixer);
mixer_free(mixer);
assert(volume >= -1 && volume <= 100);
if (volume < 0) {
- if (error.IsDefined()) {
- LogError(error, "failed to read volume");
- } else
- fprintf(stderr, "failed to read volume\n");
+ fprintf(stderr, "failed to read volume\n");
return EXIT_FAILURE;
}
printf("%d\n", volume);
return 0;
+} catch (const std::exception &e) {
+ LogError(e);
+ return EXIT_FAILURE;
}