chiark / gitweb /
mention copy-drag track playing in CHANGES
[disorder] / server / server-queue.c
index 779e5e175b6bd318f0bb06ca547344bdd8970129..ab154748900cde84fd247b66e305cadb01180790 100644 (file)
@@ -15,6 +15,9 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+/** @file server/server-queue.c
+ * @brief Server-specific track queue support
+ */
 #include "disorder-server.h"
 
 /* the head of the queue is played next, so normally we add to the tail */
@@ -47,11 +50,11 @@ void queue_fix_sofar(struct queue_entry *q) {
       if(q->uptopause == -1)           /* Don't know how far thru. */
        sofar = -1;
       else if(q->lastresumed)          /* Has been paused and resumed. */
-       sofar = q->uptopause + time(0) - q->lastresumed;
+       sofar = q->uptopause + xtime(0) - q->lastresumed;
       else                             /* Currently paused. */
        sofar = q->uptopause;
     } else                             /* Never been paused. */
-      sofar = time(0) - q->played;
+      sofar = xtime(0) - q->played;
     q->sofar = sofar;
   }
 }
@@ -65,7 +68,7 @@ static void queue_do_read(struct queue_entry *head, const char *path) {
   char *buffer;
   FILE *fp;
   struct queue_entry *q;
-  int version = 0;
+  int ver = 0;
 
   if(!(fp = fopen(path, "r"))) {
     if(errno == ENOENT)
@@ -76,18 +79,21 @@ static void queue_do_read(struct queue_entry *head, const char *path) {
   while(!inputline(path, fp, &buffer, '\n')) {
     if(buffer[0] == '#') {
       /* Version indicator */
-      version = atoi(buffer + 1);
+      ver = atoi(buffer + 1);
       continue;
     }
     q = xmalloc(sizeof *q);
     queue_unmarshall(q, buffer, queue_read_error, (void *)path);
-    if(version < 1) {
+    if(ver < 1) {
       /* 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;