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 b5c516c0c605cecb49c5198b28ae30f1d72daa64..d752660a141fe6d0d1406cf818028d39279851ea 100644 (file)
@@ -80,7 +80,7 @@ static void act_playing(void) {
     if(now + refresh > fin)
       refresh = fin - now;
   }
     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;
     /* 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);
       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);
       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);
       disorder_remove(dcgi_client, id);
-      break;
-    }
+    else
+      /* various error states */
+      error(0, "does not make sense to scratch or remove %s", id);
   }
   redirect(0);
 }
   }
   redirect(0);
 }
index f62ccac3225c17a490b5af521867c28757364155..17a6d2270c0af3114364977a520e260915bbf9c0 100644 (file)
@@ -31,9 +31,10 @@ enum playing_state {
   /** @brief Track failed to play */
   playing_failed,
 
   /** @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,
 
    */
   playing_isscratch,
 
index 8b798433d1e9819d5f25070df6c5795b69cfcccd..af42bd3ae2a17e819859a22396edbcfba9e58731 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);
     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);
     }
     notify_scratch(playing->track, playing->submitter, who,
                   time(0) - playing->played);
index 779e5e175b6bd318f0bb06ca547344bdd8970129..e65477ce6349ff7007e0f02c4f8eeb250c96f7a8 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;
       /* 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;
       switch(q->state) {
       case playing_isscratch:
         q->origin = origin_scratch;
+        q->state = playing_unplayed;
         break;
       case playing_random:
         q->state = playing_unplayed;
         break;
       case playing_random:
         q->state = playing_unplayed;