X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/087a9b2eaf10974c1b3025bf7d439c2371625e70..ff92debd29cab62e0f824ca3e40914f64e0bcb05:/cgi/actions.c diff --git a/cgi/actions.c b/cgi/actions.c index 30ddba1..6f094cb 100644 --- a/cgi/actions.c +++ b/cgi/actions.c @@ -76,14 +76,13 @@ static void act_playing(void) { && dcgi_playing->sofar >= 0) { /* Try to put the next refresh at the start of the next track. */ xtime(&now); - fin = now + length - dcgi_playing->sofar + config->gap; + fin = now + length - dcgi_playing->sofar; if(now + refresh > fin) refresh = fin - now; } 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; + /* next track is a scratch, refresh immediately */ + refresh = 0; } if(!dcgi_playing && ((dcgi_queue @@ -91,10 +90,13 @@ static void act_playing(void) { || dcgi_random_enabled) && dcgi_enabled) { /* no track playing but playing is enabled and there is something coming - * up, must be in a gap */ - if(refresh > config->gap) - refresh = config->gap; + * up, so refresh immediately */ + refresh = 0; } + /* Bound the refresh interval below as a back-stop against the above + * calculations coming up with a stupid answer */ + if(refresh < config->refresh_min) + refresh = config->refresh_min; if((action = cgi_get("action"))) url = cgi_makeurl(config->url, "action", action, (char *)0); else @@ -236,16 +238,17 @@ static void act_play(void) { char **tracks; int ntracks, n; struct tracksort_data *tsd; + char *id; if(dcgi_client) { if((track = cgi_get("track"))) { - disorder_play(dcgi_client, track); + disorder_play(dcgi_client, track, &id); } else if((dir = cgi_get("dir"))) { if(disorder_files(dcgi_client, dir, 0, &tracks, &ntracks)) ntracks = 0; tsd = tracksort_init(ntracks, tracks, "track"); for(n = 0; n < ntracks; ++n) - disorder_play(dcgi_client, tsd[n].track); + disorder_play(dcgi_client, tsd[n].track, &id); } } redirect(0); @@ -304,8 +307,12 @@ static int login_as(const char *username, const char *password) { if(dcgi_cookie && dcgi_client) disorder_revoke(dcgi_client); - /* We'll need a new connection as we are going to stop being guest */ + /* We'll need a new connection as we are going to stop being guest. + * Make sure it's unprivileged, so that the server actually bothers checking + * the password we supply. + */ c = disorder_new(0); + disorder_force_unpriv(c); if(disorder_connect_user(c, username, password)) { login_error("loginfailed"); return -1; @@ -608,7 +615,7 @@ static int process_prefs(int numfile) { byte_xasprintf((char **)&name, "trackname_%s_%s", context, part); disorder_set(dcgi_client, file, name, value); } - if((value = numbered_arg("random", numfile))) + if(numbered_arg("random", numfile)) disorder_unset(dcgi_client, file, "pick_at_random"); else disorder_set(dcgi_client, file, "pick_at_random", "0");