X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/59cf25c47fbda22f3f4e14399f0436cc6ed2c56f..4b37a75e9cb89088451753c7467d1d1bcddd29e0:/cgi/actions.c diff --git a/cgi/actions.c b/cgi/actions.c index f63e519..d752660 100644 --- a/cgi/actions.c +++ b/cgi/actions.c @@ -80,14 +80,14 @@ static void act_playing(void) { if(now + refresh > fin) refresh = fin - now; } - if(dcgi_queue && dcgi_queue->state == playing_isscratch) { + if(dcgi_queue && dcgi_queue->origin == origin_scratch) { /* next track is a scratch, don't leave more than the inter-track gap */ if(refresh > config->gap) refresh = config->gap; } if(!dcgi_playing && ((dcgi_queue - && dcgi_queue->state != playing_random) + && dcgi_queue->origin != origin_random) || dcgi_random_enabled) && dcgi_enabled) { /* no track playing but playing is enabled and there is something coming @@ -179,24 +179,19 @@ static void act_remove(void) { error(0, "missing 'id' argument"); else if(!(q = dcgi_findtrack(id))) error(0, "unknown queue id %s", id); - else switch(q->state) { - case playing_isscratch: - case playing_failed: - case playing_no_player: - case playing_ok: - case playing_quitting: - case playing_scratched: - error(0, "does not make sense to scratch %s", id); - break; - case playing_paused: /* started but paused */ - case playing_started: /* started to play */ + else if(q->origin == origin_scratch) + /* can't scratch scratches */ + error(0, "does not make sense to scratch or remove %s", id); + else if(q->state == playing_paused + || q->state == playing_started) + /* removing the playing track = scratching */ disorder_scratch(dcgi_client, id); - break; - case playing_random: /* unplayed randomly chosen track */ - case playing_unplayed: /* haven't played this track yet */ + else if(q->state == playing_unplayed) + /* otherwise it must be in the queue */ disorder_remove(dcgi_client, id); - break; - } + else + /* various error states */ + error(0, "does not make sense to scratch or remove %s", id); } redirect(0); }