X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/2dc2f4788add40c2fe7c8fdede76189b54259155..0fc2fcd010ac5cc98aab67222f3c2af2ec2beefe:/cgi/actions.c diff --git a/cgi/actions.c b/cgi/actions.c index b5c516c..ab52c2d 100644 --- a/cgi/actions.c +++ b/cgi/actions.c @@ -75,12 +75,12 @@ static void act_playing(void) { && length && dcgi_playing->sofar >= 0) { /* Try to put the next refresh at the start of the next track. */ - time(&now); + xtime(&now); fin = now + length - dcgi_playing->sofar + config->gap; 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; @@ -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); }