aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/solaris_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/solaris_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/solaris_output_plugin.c')
-rw-r--r--src/output/solaris_output_plugin.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/output/solaris_output_plugin.c b/src/output/solaris_output_plugin.c
index efa7a4e32..796c7806d 100644
--- a/src/output/solaris_output_plugin.c
+++ b/src/output/solaris_output_plugin.c
@@ -36,6 +36,8 @@
#define G_LOG_DOMAIN "solaris_output"
struct solaris_output {
+ struct audio_output base;
+
/* configuration */
const char *device;
@@ -60,31 +62,35 @@ solaris_output_test_default_device(void)
access("/dev/audio", W_OK) == 0;
}
-static void *
-solaris_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
- const struct config_param *param,
- G_GNUC_UNUSED GError **error)
+static struct audio_output *
+solaris_output_init(const struct config_param *param, GError **error_r)
{
struct solaris_output *so = g_new(struct solaris_output, 1);
+ if (!ao_base_init(&so->base, &solaris_output_plugin, param, error_r)) {
+ g_free(so);
+ return NULL;
+ }
+
so->device = config_get_block_string(param, "device", "/dev/audio");
- return so;
+ return &so->base;
}
static void
-solaris_output_finish(void *data)
+solaris_output_finish(struct audio_output *ao)
{
- struct solaris_output *so = data;
+ struct solaris_output *so = (struct solaris_output *)ao;
+ ao_base_finish(&so->base);
g_free(so);
}
static bool
-solaris_output_open(void *data, struct audio_format *audio_format,
+solaris_output_open(struct audio_output *ao, struct audio_format *audio_format,
GError **error)
{
- struct solaris_output *so = data;
+ struct solaris_output *so = (struct solaris_output *)ao;
struct audio_info info;
int ret, flags;
@@ -135,17 +141,18 @@ solaris_output_open(void *data, struct audio_format *audio_format,
}
static void
-solaris_output_close(void *data)
+solaris_output_close(struct audio_output *ao)
{
- struct solaris_output *so = data;
+ struct solaris_output *so = (struct solaris_output *)ao;
close(so->fd);
}
static size_t
-solaris_output_play(void *data, const void *chunk, size_t size, GError **error)
+solaris_output_play(struct audio_output *ao, const void *chunk, size_t size,
+ GError **error)
{
- struct solaris_output *so = data;
+ struct solaris_output *so = (struct solaris_output *)ao;
ssize_t nbytes;
nbytes = write(so->fd, chunk, size);
@@ -159,9 +166,9 @@ solaris_output_play(void *data, const void *chunk, size_t size, GError **error)
}
static void
-solaris_output_cancel(void *data)
+solaris_output_cancel(struct audio_output *ao)
{
- struct solaris_output *so = data;
+ struct solaris_output *so = (struct solaris_output *)ao;
ioctl(so->fd, I_FLUSH);
}