aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs/audioOutput_fifo.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_fifo.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 '')
-rw-r--r--src/audioOutputs/audioOutput_fifo.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/audioOutputs/audioOutput_fifo.c b/src/audioOutputs/audioOutput_fifo.c
index 38aad8e2c..7a0180741 100644
--- a/src/audioOutputs/audioOutput_fifo.c
+++ b/src/audioOutputs/audioOutput_fifo.c
@@ -151,9 +151,9 @@ static int openFifo(FifoData *fd)
return 0;
}
-static int fifo_initDriver(struct audio_output *audioOutput,
- mpd_unused const struct audio_format *audio_format,
- ConfigParam *param)
+static void *fifo_initDriver(mpd_unused struct audio_output *ao,
+ mpd_unused const struct audio_format *audio_format,
+ ConfigParam *param)
{
FifoData *fd;
BlockParam *blockParam;
@@ -173,28 +173,27 @@ static int fifo_initDriver(struct audio_output *audioOutput,
fd = newFifoData();
fd->path = path;
- audioOutput->data = fd;
if (openFifo(fd) < 0) {
freeFifoData(fd);
- return -1;
+ return NULL;
}
- return 0;
+ return fd;
}
-static void fifo_finishDriver(struct audio_output *audioOutput)
+static void fifo_finishDriver(void *data)
{
- FifoData *fd = (FifoData *)audioOutput->data;
+ FifoData *fd = (FifoData *)data;
closeFifo(fd);
freeFifoData(fd);
}
-static int fifo_openDevice(struct audio_output *audioOutput,
+static int fifo_openDevice(void *data,
struct audio_format *audio_format)
{
- FifoData *fd = (FifoData *)audioOutput->data;
+ FifoData *fd = (FifoData *)data;
if (fd->timer)
timer_free(fd->timer);
@@ -204,9 +203,9 @@ static int fifo_openDevice(struct audio_output *audioOutput,
return 0;
}
-static void fifo_closeDevice(struct audio_output *audioOutput)
+static void fifo_closeDevice(void *data)
{
- FifoData *fd = (FifoData *)audioOutput->data;
+ FifoData *fd = (FifoData *)data;
if (fd->timer) {
timer_free(fd->timer);
@@ -214,9 +213,9 @@ static void fifo_closeDevice(struct audio_output *audioOutput)
}
}
-static void fifo_dropBufferedAudio(struct audio_output *audioOutput)
+static void fifo_dropBufferedAudio(void *data)
{
- FifoData *fd = (FifoData *)audioOutput->data;
+ FifoData *fd = (FifoData *)data;
char buf[FIFO_BUFFER_SIZE];
int bytes = 1;
@@ -231,10 +230,10 @@ static void fifo_dropBufferedAudio(struct audio_output *audioOutput)
}
}
-static int fifo_playAudio(struct audio_output *audioOutput,
+static int fifo_playAudio(void *data,
const char *playChunk, size_t size)
{
- FifoData *fd = (FifoData *)audioOutput->data;
+ FifoData *fd = (FifoData *)data;
size_t offset = 0;
ssize_t bytes;
@@ -251,7 +250,7 @@ static int fifo_playAudio(struct audio_output *audioOutput,
switch (errno) {
case EAGAIN:
/* The pipe is full, so empty it */
- fifo_dropBufferedAudio(audioOutput);
+ fifo_dropBufferedAudio(fd);
continue;
case EINTR:
continue;
@@ -259,7 +258,7 @@ static int fifo_playAudio(struct audio_output *audioOutput,
ERROR("Closing FIFO output \"%s\" due to write error: "
"%s\n", fd->path, strerror(errno));
- fifo_closeDevice(audioOutput);
+ fifo_closeDevice(fd);
return -1;
}