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.
This commit is contained in:
Max Kellermann
2009-02-26 22:04:59 +01:00
parent 353ae5e558
commit ec926539a3
13 changed files with 443 additions and 255 deletions

View File

@@ -48,6 +48,7 @@ audio_output_init(struct audio_output *ao, const struct config_param *param)
char *format = NULL;
struct block_param *bp = NULL;
const struct audio_output_plugin *plugin = NULL;
GError *error = NULL;
if (param) {
const char *type = NULL;
@@ -97,7 +98,6 @@ audio_output_init(struct audio_output *ao, const struct config_param *param)
pcm_convert_init(&ao->convert_state);
if (format) {
GError *error = NULL;
bool ret;
ret = audio_format_parse(&ao->config_audio_format, format,
@@ -114,9 +114,14 @@ audio_output_init(struct audio_output *ao, const struct config_param *param)
ao->data = ao_plugin_init(plugin,
format ? &ao->config_audio_format : NULL,
param);
if (ao->data == NULL)
param, &error);
if (ao->data == NULL) {
g_warning("Failed to initialize \"%s\" [%s]: %s",
ao->name, ao->plugin->name,
error->message);
g_error_free(error);
return false;
}
return true;
}