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.
This commit is contained in:
Max Kellermann 2008-10-31 16:29:22 +01:00
parent 78448fe1a5
commit 86fbac54fd
1 changed files with 10 additions and 4 deletions

View File

@ -169,15 +169,21 @@ static void * decoder_task(mpd_unused void *arg)
while (1) { while (1) {
assert(dc.state == DECODE_STATE_STOP); assert(dc.state == DECODE_STATE_STOP);
if (dc.command == DECODE_COMMAND_START || switch (dc.command) {
dc.command == DECODE_COMMAND_SEEK) { case DECODE_COMMAND_START:
case DECODE_COMMAND_SEEK:
decodeStart(); decodeStart();
} else if (dc.command == DECODE_COMMAND_STOP) { break;
case DECODE_COMMAND_STOP:
dc.command = DECODE_COMMAND_NONE; dc.command = DECODE_COMMAND_NONE;
notify_signal(&pc.notify); notify_signal(&pc.notify);
} else { break;
case DECODE_COMMAND_NONE:
notify_wait(&dc.notify); notify_wait(&dc.notify);
notify_signal(&pc.notify); notify_signal(&pc.notify);
break;
} }
} }