aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio.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/audio.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/audio.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/audio.c b/src/audio.c
index 0eff63f8f..f4f0ffe14 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -247,9 +247,9 @@ static void syncAudioDeviceStates(void)
}
}
-int playAudio(const char *buffer, size_t length)
+bool playAudio(const char *buffer, size_t length)
{
- int ret = -1, err;
+ bool ret = false;
unsigned int i;
/* no partial frames allowed */
@@ -262,8 +262,8 @@ int playAudio(const char *buffer, size_t length)
audio_output_play(&audioOutputArray[i],
buffer, length);
- while (1) {
- int finished = 1;
+ while (true) {
+ bool finished = true;
for (i = 0; i < audioOutputArraySize; ++i) {
struct audio_output *ao = &audioOutputArray[i];
@@ -272,16 +272,16 @@ int playAudio(const char *buffer, size_t length)
continue;
if (audio_output_command_is_finished(ao)) {
- err = audio_output_get_result(ao);
- if (!err)
- ret = 0;
- else if (err < 0)
+ bool success = audio_output_get_result(ao);
+ if (success)
+ ret = true;
+ else
/* device should already be
closed if the play func
returned an error */
audioDeviceStates[i] = true;
} else {
- finished = 0;
+ finished = false;
audio_output_signal(ao);
}
}
@@ -295,13 +295,13 @@ int playAudio(const char *buffer, size_t length)
return ret;
}
-int openAudioDevice(const struct audio_format *audioFormat)
+bool openAudioDevice(const struct audio_format *audioFormat)
{
- int ret = -1;
+ bool ret = false;
unsigned int i;
if (!audioOutputArray)
- return -1;
+ return false;
if (audioFormat != NULL)
input_audio_format = *audioFormat;
@@ -310,10 +310,10 @@ int openAudioDevice(const struct audio_format *audioFormat)
for (i = 0; i < audioOutputArraySize; ++i) {
if (audioOutputArray[i].open)
- ret = 0;
+ ret = true;
}
- if (ret != 0)
+ if (!ret)
/* close all devices if there was an error */
closeAudioDevice();