aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/osx_plugin.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/osx_plugin.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 'src/output/osx_plugin.c')
-rw-r--r--src/output/osx_plugin.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/src/output/osx_plugin.c b/src/output/osx_plugin.c
index fc3025ca1..7aa7659a8 100644
--- a/src/output/osx_plugin.c
+++ b/src/output/osx_plugin.c
@@ -34,6 +34,15 @@ struct osx_output {
size_t len;
};
+/**
+ * The quark used for GError.domain.
+ */
+static inline GQuark
+osx_output_quark(void)
+{
+ return g_quark_from_static_string("osx_output");
+}
+
static bool
osx_output_test_default_device(void)
{
@@ -44,7 +53,8 @@ osx_output_test_default_device(void)
static void *
osx_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
- G_GNUC_UNUSED const struct config_param *param)
+ G_GNUC_UNUSED const struct config_param *param,
+ G_GNUC_UNUSED GError **error)
{
struct osx_output *oo = g_new(struct osx_output, 1);
@@ -143,7 +153,7 @@ osx_render(void *vdata,
}
static bool
-osx_output_open(void *data, struct audio_format *audio_format)
+osx_output_open(void *data, struct audio_format *audio_format, GError **error)
{
struct osx_output *od = data;
ComponentDescription desc;
@@ -164,22 +174,25 @@ osx_output_open(void *data, struct audio_format *audio_format)
comp = FindNextComponent(NULL, &desc);
if (comp == 0) {
- g_warning("Error finding OS X component\n");
+ g_set_error(error, osx_output_quark(), 0,
+ "Error finding OS X component");
return false;
}
status = OpenAComponent(comp, &od->au);
if (status != noErr) {
- g_warning("Unable to open OS X component: %s",
- GetMacOSStatusCommentString(status));
+ g_set_error(error, osx_output_quark(), 0,
+ "Unable to open OS X component: %s",
+ GetMacOSStatusCommentString(status));
return false;
}
status = AudioUnitInitialize(od->au);
if (status != noErr) {
CloseComponent(od->au);
- g_warning("Unable to initialize OS X audio unit: %s",
- GetMacOSStatusCommentString(status));
+ g_set_error(error, osx_output_quark(), 0,
+ "Unable to initialize OS X audio unit: %s",
+ GetMacOSStatusCommentString(status));
return false;
}
@@ -193,7 +206,8 @@ osx_output_open(void *data, struct audio_format *audio_format)
if (result != noErr) {
AudioUnitUninitialize(od->au);
CloseComponent(od->au);
- g_warning("unable to set callback for OS X audio unit\n");
+ g_set_error(error, osx_output_quark(), 0,
+ "unable to set callback for OS X audio unit");
return false;
}
@@ -218,7 +232,8 @@ osx_output_open(void *data, struct audio_format *audio_format)
if (result != noErr) {
AudioUnitUninitialize(od->au);
CloseComponent(od->au);
- g_warning("Unable to set format on OS X device\n");
+ g_set_error(error, osx_output_quark(), 0,
+ "Unable to set format on OS X device");
return false;
}
@@ -232,8 +247,9 @@ osx_output_open(void *data, struct audio_format *audio_format)
status = AudioOutputUnitStart(od->au);
if (status != 0) {
- g_warning("unable to start audio output: %s",
- GetMacOSStatusCommentString(status));
+ g_set_error(error, osx_output_quark(), 0,
+ "unable to start audio output: %s",
+ GetMacOSStatusCommentString(status));
return false;
}
@@ -241,7 +257,8 @@ osx_output_open(void *data, struct audio_format *audio_format)
}
static size_t
-osx_output_play(void *data, const void *chunk, size_t size)
+osx_output_play(void *data, const void *chunk, size_t size,
+ G_GNUC_UNUSED GError **error)
{
struct osx_output *od = data;
size_t start, nbytes;