aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/alsa_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/output/alsa_output_plugin.c (renamed from src/output/alsa_plugin.c)49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/output/alsa_plugin.c b/src/output/alsa_output_plugin.c
index ae06847c2..f939ba5b4 100644
--- a/src/output/alsa_plugin.c
+++ b/src/output/alsa_output_plugin.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2010 The Music Player Daemon Project
+ * Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,6 +18,7 @@
*/
#include "config.h"
+#include "alsa_output_plugin.h"
#include "output_api.h"
#include "mixer_list.h"
@@ -42,6 +43,8 @@ typedef snd_pcm_sframes_t alsa_writei_t(snd_pcm_t * pcm, const void *buffer,
snd_pcm_uframes_t size);
struct alsa_data {
+ struct audio_output base;
+
/** the configured name of the ALSA device; NULL for the
default device */
char *device;
@@ -142,23 +145,27 @@ alsa_configure(struct alsa_data *ad, const struct config_param *param)
#endif
}
-static void *
-alsa_init(G_GNUC_UNUSED const struct audio_format *audio_format,
- const struct config_param *param,
- G_GNUC_UNUSED GError **error)
+static struct audio_output *
+alsa_init(const struct config_param *param, GError **error_r)
{
struct alsa_data *ad = alsa_data_new();
+ if (!ao_base_init(&ad->base, &alsa_output_plugin, param, error_r)) {
+ g_free(ad);
+ return NULL;
+ }
+
alsa_configure(ad, param);
- return ad;
+ return &ad->base;
}
static void
-alsa_finish(void *data)
+alsa_finish(struct audio_output *ao)
{
- struct alsa_data *ad = data;
+ struct alsa_data *ad = (struct alsa_data *)ao;
+ ao_base_finish(&ad->base);
alsa_data_free(ad);
/* free libasound's config cache */
@@ -205,6 +212,9 @@ get_bitformat(enum sample_format sample_format)
case SAMPLE_FORMAT_S32:
return SND_PCM_FORMAT_S32;
+
+ case SAMPLE_FORMAT_FLOAT:
+ return SND_PCM_FORMAT_FLOAT;
}
assert(false);
@@ -532,9 +542,9 @@ error:
}
static bool
-alsa_open(void *data, struct audio_format *audio_format, GError **error)
+alsa_open(struct audio_output *ao, struct audio_format *audio_format, GError **error)
{
- struct alsa_data *ad = data;
+ struct alsa_data *ad = (struct alsa_data *)ao;
int err;
bool success;
@@ -596,9 +606,9 @@ alsa_recover(struct alsa_data *ad, int err)
}
static void
-alsa_drain(void *data)
+alsa_drain(struct audio_output *ao)
{
- struct alsa_data *ad = data;
+ struct alsa_data *ad = (struct alsa_data *)ao;
if (snd_pcm_state(ad->pcm) != SND_PCM_STATE_RUNNING)
return;
@@ -630,9 +640,9 @@ alsa_drain(void *data)
}
static void
-alsa_cancel(void *data)
+alsa_cancel(struct audio_output *ao)
{
- struct alsa_data *ad = data;
+ struct alsa_data *ad = (struct alsa_data *)ao;
ad->period_position = 0;
@@ -640,17 +650,18 @@ alsa_cancel(void *data)
}
static void
-alsa_close(void *data)
+alsa_close(struct audio_output *ao)
{
- struct alsa_data *ad = data;
+ struct alsa_data *ad = (struct alsa_data *)ao;
snd_pcm_close(ad->pcm);
}
static size_t
-alsa_play(void *data, const void *chunk, size_t size, GError **error)
+alsa_play(struct audio_output *ao, const void *chunk, size_t size,
+ GError **error)
{
- struct alsa_data *ad = data;
+ struct alsa_data *ad = (struct alsa_data *)ao;
size /= ad->frame_size;
@@ -671,7 +682,7 @@ alsa_play(void *data, const void *chunk, size_t size, GError **error)
}
}
-const struct audio_output_plugin alsaPlugin = {
+const struct audio_output_plugin alsa_output_plugin = {
.name = "alsa",
.test_default_device = alsa_test_default_device,
.init = alsa_init,