From 62d4fa9306fdb5dd0a1b592fd8dbdf1b679d92ca Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 30 Oct 2008 08:38:54 +0100 Subject: decoder: 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/decoder_thread.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/decoder_thread.c') diff --git a/src/decoder_thread.c b/src/decoder_thread.c index 3bbe1f347..e26e2e534 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -73,12 +73,12 @@ static void decodeStart(void) if (dc.command == DECODE_COMMAND_STOP) goto stop; - ret = DECODE_ERROR_UNKTYPE; + ret = false; if (!song_is_file(song)) { unsigned int next = 0; /* first we try mime types: */ - while (ret && (plugin = decoder_plugin_from_mime_type(inStream.mime, next++))) { + while ((plugin = decoder_plugin_from_mime_type(inStream.mime, next++))) { if (plugin->stream_decode == NULL) continue; if (!(plugin->stream_types & INPUT_PLUGIN_STREAM_URL)) @@ -94,7 +94,7 @@ static void decodeStart(void) if (plugin == NULL) { const char *s = getSuffix(path_max_fs); next = 0; - while (ret && (plugin = decoder_plugin_from_suffix(s, next++))) { + while ((plugin = decoder_plugin_from_suffix(s, next++))) { if (plugin->stream_decode == NULL) continue; if (!(plugin->stream_types & @@ -124,7 +124,7 @@ static void decodeStart(void) } else { unsigned int next = 0; const char *s = getSuffix(path_max_fs); - while (ret && (plugin = decoder_plugin_from_suffix(s, next++))) { + while ((plugin = decoder_plugin_from_suffix(s, next++))) { if (!plugin->stream_types & INPUT_PLUGIN_STREAM_FILE) continue; @@ -150,11 +150,10 @@ static void decodeStart(void) ob_flush(); - if (ret < 0 || ret == DECODE_ERROR_UNKTYPE) { - if (ret != DECODE_ERROR_UNKTYPE) - dc.error = DECODE_ERROR_FILE; - else - dc.error = DECODE_ERROR_UNKTYPE; + if (!ret) { + dc.error = plugin == NULL + ? DECODE_ERROR_UNKTYPE + : DECODE_ERROR_FILE; } stop: -- cgit v1.2.3