aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/roar_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/roar_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 '')
-rw-r--r--src/output/roar_output_plugin.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/output/roar_output_plugin.c b/src/output/roar_output_plugin.c
index c6f3e99f5..d15569fd5 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;