From 58c5bee9f0bcb46da7d113b66a4e1e2d7add9837 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 29 Oct 2008 20:40:27 +0100 Subject: 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. --- src/audio.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/audio.c') 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(); -- cgit v1.2.3