aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/osx_output_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-09-16 23:31:48 +0200
committerMax Kellermann <max@duempel.org>2011-09-19 09:41:21 +0200
commit74617389c88ccf630b8cce4b54d9e2fa5afb2259 (patch)
tree3d05faad2c2b3b2e9e885f2c391a35fe8f06553a /src/output/osx_output_plugin.c
parentb4a8b8c0d4bf82fc56572c3f8e79108d22d78132 (diff)
downloadmpd-74617389c88ccf630b8cce4b54d9e2fa5afb2259.tar.gz
mpd-74617389c88ccf630b8cce4b54d9e2fa5afb2259.tar.xz
mpd-74617389c88ccf630b8cce4b54d9e2fa5afb2259.zip
output_plugin: the plugin allocates the audio_output object
Pass audio_output objects around instead of void pointers. This will give some more control to the plugin, and prepares for non-blocking audio outputs.
Diffstat (limited to 'src/output/osx_output_plugin.c')
-rw-r--r--src/output/osx_output_plugin.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/output/osx_output_plugin.c b/src/output/osx_output_plugin.c
index f33148c25..f07aedc08 100644
--- a/src/output/osx_output_plugin.c
+++ b/src/output/osx_output_plugin.c
@@ -29,6 +29,8 @@
#define G_LOG_DOMAIN "osx"
struct osx_output {
+ struct audio_output base;
+
/* configuration settings */
OSType component_subtype;
/* only applicable with kAudioUnitSubType_HALOutput */
@@ -80,12 +82,14 @@ osx_output_configure(struct osx_output *oo, const struct config_param *param)
}
}
-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 GError **error)
+static struct audio_output *
+osx_output_init(const struct config_param *param, GError **error_r)
{
struct osx_output *oo = g_new(struct osx_output, 1);
+ if (!ao_base_init(&oo->base, &osx_output_plugin, param, error_r)) {
+ g_free(oo);
+ return NULL;
+ }
osx_output_configure(oo, param);
oo->mutex = g_mutex_new();
@@ -96,12 +100,13 @@ osx_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
oo->buffer = NULL;
oo->buffer_size = 0;
- return oo;
+ return &oo->base;
}
-static void osx_output_finish(void *data)
+static void
+osx_output_finish(struct audio_output *ao)
{
- struct osx_output *od = data;
+ struct osx_output *od = (struct osx_output *)ao;
g_free(od->buffer);
g_mutex_free(od->mutex);
@@ -109,18 +114,20 @@ static void osx_output_finish(void *data)
g_free(od);
}
-static void osx_output_cancel(void *data)
+static void
+osx_output_cancel(struct audio_output *ao)
{
- struct osx_output *od = data;
+ struct osx_output *od = (struct osx_output *)ao;
g_mutex_lock(od->mutex);
od->len = 0;
g_mutex_unlock(od->mutex);
}
-static void osx_output_close(void *data)
+static void
+osx_output_close(struct audio_output *ao)
{
- struct osx_output *od = data;
+ struct osx_output *od = (struct osx_output *)ao;
AudioOutputUnitStop(od->au);
AudioUnitUninitialize(od->au);
@@ -266,9 +273,9 @@ done:
}
static bool
-osx_output_open(void *data, struct audio_format *audio_format, GError **error)
+osx_output_open(struct audio_output *ao, struct audio_format *audio_format, GError **error)
{
- struct osx_output *od = data;
+ struct osx_output *od = (struct osx_output *)ao;
ComponentDescription desc;
Component comp;
AURenderCallbackStruct callback;
@@ -385,10 +392,10 @@ osx_output_open(void *data, struct audio_format *audio_format, GError **error)
}
static size_t
-osx_output_play(void *data, const void *chunk, size_t size,
+osx_output_play(struct audio_output *ao, const void *chunk, size_t size,
G_GNUC_UNUSED GError **error)
{
- struct osx_output *od = data;
+ struct osx_output *od = (struct osx_output *)ao;
size_t start, nbytes;
g_mutex_lock(od->mutex);