aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/fifo_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-23 09:29:56 +0100
committerMax Kellermann <max@duempel.org>2009-02-23 09:29:56 +0100
commit5a898c15e79ab87d2466e61549fcc20ce115c67e (patch)
treecb65b88718b0b8f3cf05221816b193833c41fe8a /src/output/fifo_plugin.c
parentd50a3d513eb0452e762f1e4eeb717318958cd83c (diff)
downloadmpd-5a898c15e79ab87d2466e61549fcc20ce115c67e.tar.gz
mpd-5a898c15e79ab87d2466e61549fcc20ce115c67e.tar.xz
mpd-5a898c15e79ab87d2466e61549fcc20ce115c67e.zip
output_api: play() returns a length
The old API required an output plugin to not return until all data passed to the play() method is consumed. Some output plugins have to loop to fulfill that requirement, and may block during that. Simplify these, by letting them consume only part of the buffer: make play() return the length of the consumed data.
Diffstat (limited to '')
-rw-r--r--src/output/fifo_plugin.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/output/fifo_plugin.c b/src/output/fifo_plugin.c
index b0c6d12f4..1be0f2a7d 100644
--- a/src/output/fifo_plugin.c
+++ b/src/output/fifo_plugin.c
@@ -237,11 +237,10 @@ static void fifo_dropBufferedAudio(void *data)
}
}
-static bool
+static size_t
fifo_playAudio(void *data, const char *playChunk, size_t size)
{
FifoData *fd = (FifoData *)data;
- size_t offset = 0;
ssize_t bytes;
if (!fd->timer->started)
@@ -251,8 +250,11 @@ fifo_playAudio(void *data, const char *playChunk, size_t size)
timer_add(fd->timer, size);
- while (size) {
- bytes = write(fd->output, playChunk + offset, size);
+ while (true) {
+ bytes = write(fd->output, playChunk, size);
+ if (bytes > 0)
+ return (size_t)bytes;
+
if (bytes < 0) {
switch (errno) {
case EAGAIN:
@@ -265,14 +267,9 @@ fifo_playAudio(void *data, const char *playChunk, size_t size)
g_warning("Closing FIFO output \"%s\" due to write error: %s",
fd->path, strerror(errno));
- return false;
+ return 0;
}
-
- size -= bytes;
- offset += bytes;
}
-
- return true;
}
const struct audio_output_plugin fifoPlugin = {