chiark / gitweb /
Obsolete playing_isscratch. The constant still exists as a transition
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 1 Nov 2008 12:39:43 +0000 (12:39 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 1 Nov 2008 12:39:43 +0000 (12:39 +0000)
measure (and will probably do so for some time to come).

cgi/actions.c
lib/queue.h
server/play.c
server/server-queue.c

index b5c516c..d752660 100644 (file)
@@ -80,7 +80,7 @@ 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;
@@ -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);
 }
index f62ccac..17a6d22 100644 (file)
@@ -31,9 +31,10 @@ enum playing_state {
   /** @brief Track failed to play */
   playing_failed,
 
-  /** @brief Track is a scratch and has not been played yet
+  /** @brief OBSOLETE
    *
-   * Going to become obsolete.
+   * Formerly denoted an unplayed scratch.  This is now indicated by @p
+   * playing_unplayed and @p origin_scratch.
    */
   playing_isscratch,
 
index 8b79843..af42bd3 100644 (file)
@@ -643,7 +643,6 @@ void scratch(const char *who, const char *id) {
     if(playing_is_enabled() && config->scratch.n) {
       int r = rand() * (double)config->scratch.n / (RAND_MAX + 1.0);
       q = queue_add(config->scratch.s[r], who, WHERE_START, origin_scratch);
-      q->state = playing_isscratch;
     }
     notify_scratch(playing->track, playing->submitter, who,
                   time(0) - playing->played);
index 779e5e1..e65477c 100644 (file)
@@ -85,9 +85,12 @@ static void queue_do_read(struct queue_entry *head, const char *path) {
       /* Fix up origin field as best we can; will be wrong in some cases but
        * hopefully not too horribly so. */
       q->origin = q->submitter ? origin_picked : origin_random;
+      /* Eliminated obsolete states, since they are assumed elsewhere not to be
+       * set. */
       switch(q->state) {
       case playing_isscratch:
         q->origin = origin_scratch;
+        q->state = playing_unplayed;
         break;
       case playing_random:
         q->state = playing_unplayed;