aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-26 22:04:59 +0100
committerMax Kellermann <max@duempel.org>2009-02-26 22:04:59 +0100
commitec926539a3a7a09b310e74a4fc84902e0971b29d (patch)
tree9ce6a1c94f45bc740648b3b4995375844a02ccf0 /src/output_thread.c
parent353ae5e558c2dbdc7f9e148a14d8ffa0431e88de (diff)
downloadmpd-ec926539a3a7a09b310e74a4fc84902e0971b29d.tar.gz
mpd-ec926539a3a7a09b310e74a4fc84902e0971b29d.tar.xz
mpd-ec926539a3a7a09b310e74a4fc84902e0971b29d.zip
output_plugin: report errors with GError
Use GLib's GError library for reporting output device failures. Note that some init() methods don't clean up properly after a failure, but that's ok for now, because the MPD core will abort anyway.
Diffstat (limited to '')
-rw-r--r--src/output_thread.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/output_thread.c b/src/output_thread.c
index 91fd8d406..b5a4c6117 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -56,6 +56,7 @@ static void ao_play(struct audio_output *ao)
{
const char *data = ao->args.play.data;
size_t size = ao->args.play.size;
+ GError *error = NULL;
assert(size > 0);
assert(size % audio_format_frame_size(&ao->in_audio_format) == 0);
@@ -76,9 +77,14 @@ static void ao_play(struct audio_output *ao)
while (size > 0) {
size_t nbytes;
- nbytes = ao_plugin_play(ao->plugin, ao->data, data, size);
+ nbytes = ao_plugin_play(ao->plugin, ao->data, data, size,
+ &error);
if (nbytes == 0) {
/* play()==0 means failure */
+ g_warning("\"%s\" [%s] failed to play: %s",
+ ao->name, ao->plugin->name, error->message);
+ g_error_free(error);
+
ao_plugin_cancel(ao->plugin, ao->data);
ao_close(ao);
break;
@@ -114,6 +120,7 @@ static gpointer audio_output_task(gpointer arg)
{
struct audio_output *ao = arg;
bool ret;
+ GError *error;
while (1) {
switch (ao->command) {
@@ -123,15 +130,23 @@ static gpointer audio_output_task(gpointer arg)
case AO_COMMAND_OPEN:
assert(!ao->open);
+ error = NULL;
ret = ao_plugin_open(ao->plugin, ao->data,
- &ao->out_audio_format);
+ &ao->out_audio_format,
+ &error);
assert(!ao->open);
if (ret) {
pcm_convert_init(&ao->convert_state);
ao->open = true;
- } else
+ } else {
+ g_warning("Failed to open \"%s\" [%s]: %s",
+ ao->name, ao->plugin->name,
+ error->message);
+ g_error_free(error);
+
ao->reopen_after = time(NULL) + REOPEN_AFTER;
+ }
ao_command_finished(ao);
break;