chiark / gitweb /
Update the queue up to every 15s or so to stop expected started times
[disorder] / disobedience / queue.c
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;
 }