aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/oss_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-29 20:40:27 +0100
committerMax Kellermann <max@duempel.org>2008-10-29 20:40:27 +0100
commit58c5bee9f0bcb46da7d113b66a4e1e2d7add9837 (patch)
tree4517d2156aa3643247e7f2fc886af86d3dfd8791 /src/output/oss_plugin.c
parent03390d8be1cb8983778faf6eedb9bcfd26a6dbce (diff)
downloadmpd-58c5bee9f0bcb46da7d113b66a4e1e2d7add9837.tar.gz
mpd-58c5bee9f0bcb46da7d113b66a4e1e2d7add9837.tar.xz
mpd-58c5bee9f0bcb46da7d113b66a4e1e2d7add9837.zip
output: use bool for return values and flags
Don't return 0/-1 on success/error, but true/false. Instead of int, use bool for storing flags.
Diffstat (limited to '')
-rw-r--r--src/output/oss_plugin.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/output/oss_plugin.c b/src/output/oss_plugin.c
index 2992368d9..26bc1b3aa 100644
--- a/src/output/oss_plugin.c
+++ b/src/output/oss_plugin.c
@@ -322,20 +322,20 @@ static int oss_statDevice(const char *device, int *stErrno)
static const char *default_devices[] = { "/dev/sound/dsp", "/dev/dsp" };
-static int oss_testDefault(void)
+static bool oss_testDefault(void)
{
int fd, i;
for (i = ARRAY_SIZE(default_devices); --i >= 0; ) {
if ((fd = open(default_devices[i], O_WRONLY)) >= 0) {
xclose(fd);
- return 0;
+ return true;
}
WARNING("Error opening OSS device \"%s\": %s\n",
default_devices[i], strerror(errno));
}
- return -1;
+ return false;
}
static void *oss_open_default(ConfigParam *param)
@@ -438,7 +438,7 @@ static void oss_close(OssData * od)
od->fd = -1;
}
-static int oss_open(OssData *od)
+static bool oss_open(OssData *od)
{
int tmp;
@@ -486,23 +486,24 @@ static int oss_open(OssData *od)
goto fail;
}
- return 0;
+ return true;
fail:
oss_close(od);
- return -1;
+ return false;
}
-static int oss_openDevice(void *data,
- struct audio_format *audioFormat)
+static bool
+oss_openDevice(void *data, struct audio_format *audioFormat)
{
- int ret;
+ bool ret;
OssData *od = data;
od->audio_format = *audioFormat;
- if ((ret = oss_open(od)) < 0)
- return ret;
+ ret = oss_open(od);
+ if (!ret)
+ return false;
*audioFormat = od->audio_format;
@@ -531,15 +532,15 @@ static void oss_dropBufferedAudio(void *data)
}
}
-static int oss_playAudio(void *data,
- const char *playChunk, size_t size)
+static bool
+oss_playAudio(void *data, const char *playChunk, size_t size)
{
OssData *od = data;
ssize_t ret;
/* reopen the device since it was closed by dropBufferedAudio */
if (od->fd < 0 && oss_open(od) < 0)
- return -1;
+ return false;
while (size > 0) {
ret = write(od->fd, playChunk, size);
@@ -549,13 +550,13 @@ static int oss_playAudio(void *data,
ERROR("closing oss device \"%s\" due to write error: "
"%s\n", od->device, strerror(errno));
oss_closeDevice(od);
- return -1;
+ return false;
}
playChunk += ret;
size -= ret;
}
- return 0;
+ return true;
}
const struct audio_output_plugin ossPlugin = {