chiark / gitweb /
Update the queue up to every 15s or so to stop expected started times
authorRichard Kettlewell <rjk@greenend.org.uk>
Thu, 26 Nov 2009 20:43:51 +0000 (20:43 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Thu, 26 Nov 2009 20:43:51 +0000 (20:43 +0000)
getting too out of date.  This can happen if the queue is not empty
but nothing is playing.  Fixes issue #49.

CHANGES.html
disobedience/queue-generic.c
disobedience/queue.c

index dbe660e8c5d92ac3460598a706b7fe3af556c373..501248f4db355b6fdf591275faf10e153966ec15 100644 (file)
@@ -204,9 +204,12 @@ span.command {
           <td>build-time dependency on <tt>oggdec</tt> removed</td>
         </tr>
 
-        
+        <tr>
+          <td><a href="http://code.google.com/p/disorder/issues/detail?id=49">#49</a></d>
+          <td>Disobedience's 'When' column gets out of date</td>
+        </tr>
+
       </table>
-      
     </div>
   </div>
 
index de86f299894f3a9dfa5b1556dd2f592c08f70b1e..5d44ffa1ff7cc0620cc07de133d32a753b1b2294 100644 (file)
@@ -323,6 +323,8 @@ void ql_new_queue(struct queuelike *ql,
                          ql->ncolumns + QUEUEPOINTER_COLUMN, nqd->new,
                          -1);
       it = gtk_tree_model_iter_next(GTK_TREE_MODEL(ql->store), iter);
+      /* We'll need the new start time */
+      nqd->new->when = q->when;
       ++kept;
     } else {
       /* Delete this row (and move iter to the next one) */
index 0db90d7ded457abfabf0ad3524be6bbb6f38a3dd..00c44c2744e4a3df370daf9545f0981c9a159986 100644 (file)
@@ -135,6 +135,21 @@ static gboolean playing_periodic(gpointer attribute((unused)) data) {
   /* If there's a track playing, update its row */
   if(playing_track)
     ql_update_row(playing_track, 0);
+  /* If the first (nonplaying) track starts in the past, update the queue to
+   * get new expected start times; but rate limit this checking.  (If we only
+   * do it once a minute then the rest of the queue can get out of date too
+   * easily.) */
+  struct queue_entry *q = ql_queue.q;
+  if(q) {
+    if(q == playing_track)
+      q = q->next;
+    if(q) {
+      time_t now;
+      time(&now);
+      if(q->expected / 15 < now / 15)
+        queue_changed(0,0,0);
+    }
+  }
   return TRUE;
 }