diff options
author | Max Kellermann <max@duempel.org> | 2009-10-20 22:10:56 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-10-20 22:10:56 +0200 |
commit | 4e2fb3fb89b8b80d5366466f391f21386120019e (patch) | |
tree | b483ed23c73afbbefcba86c1ce0d2b8c4afa824b /test | |
parent | 9cd2129eeb22280836e87bfa12389adf4ddb2488 (diff) | |
download | mpd-4e2fb3fb89b8b80d5366466f391f21386120019e.tar.gz mpd-4e2fb3fb89b8b80d5366466f391f21386120019e.tar.xz mpd-4e2fb3fb89b8b80d5366466f391f21386120019e.zip |
mixer_plugin: use GError for error handling
Diffstat (limited to '')
-rw-r--r-- | test/read_mixer.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/test/read_mixer.c b/test/read_mixer.c index 0e814f4ba..89ea55356 100644 --- a/test/read_mixer.c +++ b/test/read_mixer.c @@ -46,6 +46,7 @@ pcm_volume(G_GNUC_UNUSED void *buffer, G_GNUC_UNUSED int length, int main(int argc, G_GNUC_UNUSED char **argv) { + GError *error = NULL; struct mixer *mixer; bool success; int volume; @@ -57,27 +58,34 @@ int main(int argc, G_GNUC_UNUSED char **argv) g_thread_init(NULL); - mixer = mixer_new(&alsa_mixer_plugin, NULL); + mixer = mixer_new(&alsa_mixer_plugin, NULL, &error); if (mixer == NULL) { - g_printerr("mixer_new() failed\n"); + g_printerr("mixer_new() failed: %s\n", error->message); + g_error_free(error); return 2; } - success = mixer_open(mixer); + success = mixer_open(mixer, &error); if (!success) { mixer_free(mixer); - g_printerr("failed to open the mixer\n"); + g_printerr("failed to open the mixer: %s\n", error->message); + g_error_free(error); return 2; } - volume = mixer_get_volume(mixer); + volume = mixer_get_volume(mixer, &error); mixer_close(mixer); mixer_free(mixer); assert(volume >= -1 && volume <= 100); if (volume < 0) { - g_printerr("failed to read volume\n"); + if (error != NULL) { + g_printerr("failed to read volume: %s\n", + error->message); + g_error_free(error); + } else + g_printerr("failed to read volume\n"); return 2; } |