From 74617389c88ccf630b8cce4b54d9e2fa5afb2259 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Sep 2011 23:31:48 +0200 Subject: 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. --- src/output/roar_output_plugin.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/output/roar_output_plugin.c') diff --git a/src/output/roar_output_plugin.c b/src/output/roar_output_plugin.c index c6f3e99f..d15569fd 100644 --- a/src/output/roar_output_plugin.c +++ b/src/output/roar_output_plugin.c @@ -38,6 +38,8 @@ typedef struct roar { + struct audio_output base; + roar_vs_t * vss; int err; char *host; @@ -114,34 +116,39 @@ roar_configure(struct roar * self, const struct config_param *param) : ROAR_ROLE_MUSIC; } -static void * -roar_init(G_GNUC_UNUSED const struct audio_format *audio_format, - const struct config_param *param, - G_GNUC_UNUSED GError **error) +static struct audio_output * +roar_init(const struct config_param *param, GError **error_r) { struct roar *self = g_new0(struct roar, 1); + + if (!ao_base_init(&self->base, &roar_output_plugin, param, error_r)) { + g_free(self); + return NULL; + } + self->lock = g_mutex_new(); self->err = ROAR_ERROR_NONE; roar_configure(self, param); - return self; + return &self->base; } static void -roar_finish(void *data) +roar_finish(struct audio_output *ao) { - roar_t * self = data; + struct roar *self = (struct roar *)ao; g_free(self->host); g_free(self->name); g_mutex_free(self->lock); + ao_base_finish(&self->base); g_free(self); } static bool -roar_open(void *data, struct audio_format *audio_format, GError **error) +roar_open(struct audio_output *ao, struct audio_format *audio_format, GError **error) { - roar_t * self = data; + struct roar *self = (struct roar *)ao; g_mutex_lock(self->lock); if (roar_simple_connect(&(self->con), self->host, self->name) < 0) @@ -205,9 +212,9 @@ roar_open(void *data, struct audio_format *audio_format, GError **error) } static void -roar_close(void *data) +roar_close(struct audio_output *ao) { - roar_t * self = data; + struct roar *self = (struct roar *)ao; g_mutex_lock(self->lock); self->alive = false; @@ -246,9 +253,9 @@ roar_cancel_locked(struct roar *self) } static void -roar_cancel(void *data) +roar_cancel(struct audio_output *ao) { - roar_t * self = data; + struct roar *self = (struct roar *)ao; g_mutex_lock(self->lock); roar_cancel_locked(self); @@ -256,9 +263,9 @@ roar_cancel(void *data) } static size_t -roar_play(void *data, const void *chunk, size_t size, GError **error) +roar_play(struct audio_output *ao, const void *chunk, size_t size, GError **error) { - struct roar * self = data; + struct roar *self = (struct roar *)ao; ssize_t rc; if (self->vss == NULL) @@ -323,9 +330,9 @@ roar_tag_convert(enum tag_type type, bool *is_uuid) } static void -roar_send_tag(void *data, const struct tag *meta) +roar_send_tag(struct audio_output *ao, const struct tag *meta) { - struct roar * self = data; + struct roar *self = (struct roar *)ao; if (self->vss == NULL) return; -- cgit v1.2.3