aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs/audioOutput_ao.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-24 07:20:55 +0200
committerMax Kellermann <max@duempel.org>2008-09-24 07:20:55 +0200
commitacc4a0ba2dd0be3f28c4ca009e08d1cc1bbc534a (patch)
tree7d4ea0359c85f67d0366fb58ae80c8aa35f3a473 /src/audioOutputs/audioOutput_ao.c
parent63fb1efb5cd6665b73ced155ba89a5c7f094d9ab (diff)
downloadmpd-acc4a0ba2dd0be3f28c4ca009e08d1cc1bbc534a.tar.gz
mpd-acc4a0ba2dd0be3f28c4ca009e08d1cc1bbc534a.tar.xz
mpd-acc4a0ba2dd0be3f28c4ca009e08d1cc1bbc534a.zip
output: make "struct audio_output" opaque for output plugins
We have eliminated direct accesses to the audio_output struct from the all output plugins. Make it opaque for them, and move its real declaration to output_internal.h, similar to decoder_internal.h. Pass the opaque structure to plugin.init() only, which will return the plugin's data pointer on success, and NULL on failure. This data pointer will be passed to all other methods instead of the audio_output struct.
Diffstat (limited to 'src/audioOutputs/audioOutput_ao.c')
-rw-r--r--src/audioOutputs/audioOutput_ao.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/audioOutputs/audioOutput_ao.c b/src/audioOutputs/audioOutput_ao.c
index aeb267cef..e712d582a 100644
--- a/src/audioOutputs/audioOutput_ao.c
+++ b/src/audioOutputs/audioOutput_ao.c
@@ -54,9 +54,9 @@ static void audioOutputAo_error(void)
}
}
-static int audioOutputAo_initDriver(struct audio_output *audioOutput,
- mpd_unused const struct audio_format *audio_format,
- ConfigParam * param)
+static void *audioOutputAo_initDriver(struct audio_output *ao,
+ mpd_unused const struct audio_format *audio_format,
+ ConfigParam * param)
{
ao_info *ai;
char *duplicated;
@@ -69,8 +69,6 @@ static int audioOutputAo_initDriver(struct audio_output *audioOutput,
AoData *ad = newAoData();
BlockParam *blockParam;
- audioOutput->data = ad;
-
if ((blockParam = getBlockParam(param, "write_size"))) {
ad->writeSize = strtol(blockParam->value, &test, 10);
if (*test != '\0') {
@@ -100,7 +98,7 @@ static int audioOutputAo_initDriver(struct audio_output *audioOutput,
}
DEBUG("using ao driver \"%s\" for \"%s\"\n", ai->short_name,
- audio_output_get_name(audioOutput));
+ audio_output_get_name(ao));
blockParam = getBlockParam(param, "options");
@@ -138,7 +136,7 @@ static int audioOutputAo_initDriver(struct audio_output *audioOutput,
}
free(duplicated);
- return 0;
+ return ad;
}
static void freeAoData(AoData * ad)
@@ -147,9 +145,9 @@ static void freeAoData(AoData * ad)
free(ad);
}
-static void audioOutputAo_finishDriver(struct audio_output *audioOutput)
+static void audioOutputAo_finishDriver(void *data)
{
- AoData *ad = (AoData *) audioOutput->data;
+ AoData *ad = (AoData *)data;
freeAoData(ad);
driverInitCount--;
@@ -158,14 +156,14 @@ static void audioOutputAo_finishDriver(struct audio_output *audioOutput)
ao_shutdown();
}
-static void audioOutputAo_dropBufferedAudio(mpd_unused struct audio_output *audioOutput)
+static void audioOutputAo_dropBufferedAudio(mpd_unused void *data)
{
/* not supported by libao */
}
-static void audioOutputAo_closeDevice(struct audio_output *audioOutput)
+static void audioOutputAo_closeDevice(void *data)
{
- AoData *ad = (AoData *) audioOutput->data;
+ AoData *ad = (AoData *)data;
if (ad->device) {
ao_close(ad->device);
@@ -173,14 +171,14 @@ static void audioOutputAo_closeDevice(struct audio_output *audioOutput)
}
}
-static int audioOutputAo_openDevice(struct audio_output *audioOutput,
+static int audioOutputAo_openDevice(void *data,
struct audio_format *audio_format)
{
ao_sample_format format;
- AoData *ad = (AoData *) audioOutput->data;
+ AoData *ad = (AoData *)data;
if (ad->device) {
- audioOutputAo_closeDevice(audioOutput);
+ audioOutputAo_closeDevice(ad);
}
format.bits = audio_format->bits;
@@ -213,11 +211,10 @@ static int ao_play_deconst(ao_device *device, const void *output_samples,
return ao_play(device, u.out, num_bytes);
}
-static int audioOutputAo_play(struct audio_output *audioOutput,
- const char *playChunk, size_t size)
+static int audioOutputAo_play(void *data, const char *playChunk, size_t size)
{
+ AoData *ad = (AoData *)data;
size_t chunk_size;
- AoData *ad = (AoData *) audioOutput->data;
if (ad->device == NULL)
return -1;
@@ -229,7 +226,7 @@ static int audioOutputAo_play(struct audio_output *audioOutput,
if (ao_play_deconst(ad->device, playChunk, chunk_size) == 0) {
audioOutputAo_error();
ERROR("closing audio device due to write error\n");
- audioOutputAo_closeDevice(audioOutput);
+ audioOutputAo_closeDevice(ad);
return -1;
}