From 86fbac54fd47dc21f3689d0efac207f3d6905927 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 31 Oct 2008 16:29:22 +0100 Subject: [PATCH] decoder: introduce switch statement in decoder_task() switch looks much nicer than if/elseif/... and gcc generates nice warnings when a new command is added to the enum. --- src/decoder_thread.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/decoder_thread.c b/src/decoder_thread.c index e26e2e534..389634896 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -169,15 +169,21 @@ static void * decoder_task(mpd_unused void *arg) while (1) { assert(dc.state == DECODE_STATE_STOP); - if (dc.command == DECODE_COMMAND_START || - dc.command == DECODE_COMMAND_SEEK) { + switch (dc.command) { + case DECODE_COMMAND_START: + case DECODE_COMMAND_SEEK: decodeStart(); - } else if (dc.command == DECODE_COMMAND_STOP) { + break; + + case DECODE_COMMAND_STOP: dc.command = DECODE_COMMAND_NONE; notify_signal(&pc.notify); - } else { + break; + + case DECODE_COMMAND_NONE: notify_wait(&dc.notify); notify_signal(&pc.notify); + break; } }