diff options
author | Max Kellermann <max@duempel.org> | 2009-02-23 09:29:56 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-23 09:29:56 +0100 |
commit | 5a898c15e79ab87d2466e61549fcc20ce115c67e (patch) | |
tree | cb65b88718b0b8f3cf05221816b193833c41fe8a /src/output/oss_plugin.c | |
parent | d50a3d513eb0452e762f1e4eeb717318958cd83c (diff) | |
download | mpd-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/oss_plugin.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/output/oss_plugin.c b/src/output/oss_plugin.c index 007d5bc84..eca6f9101 100644 --- a/src/output/oss_plugin.c +++ b/src/output/oss_plugin.c @@ -553,7 +553,7 @@ static void oss_dropBufferedAudio(void *data) } } -static bool +static size_t oss_playAudio(void *data, const char *playChunk, size_t size) { OssData *od = data; @@ -563,20 +563,17 @@ oss_playAudio(void *data, const char *playChunk, size_t size) if (od->fd < 0 && !oss_open(od)) return false; - while (size > 0) { + while (true) { ret = write(od->fd, playChunk, size); - if (ret < 0) { - if (errno == EINTR) - continue; + if (ret > 0) + return (size_t)ret; + + if (ret < 0 && errno != EINTR) { g_warning("closing oss device \"%s\" due to write error: " "%s\n", od->device, strerror(errno)); - return false; + return 0; } - playChunk += ret; - size -= ret; } - - return true; } const struct audio_output_plugin ossPlugin = { |