From: Richard Kettlewell Date: Thu, 26 Nov 2009 20:43:51 +0000 (+0000) Subject: Update the queue up to every 15s or so to stop expected started times X-Git-Tag: 5.0~40^2~3 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/e03df0a5bce30b363ab422c779ce9fe9321cc027?hp=3af7654d5105d051ca3442c0da04911ce1207fb7 Update the queue up to every 15s or so to stop expected started times getting too out of date. This can happen if the queue is not empty but nothing is playing. Fixes issue #49. --- diff --git a/CHANGES.html b/CHANGES.html index dbe660e..501248f 100644 --- a/CHANGES.html +++ b/CHANGES.html @@ -204,9 +204,12 @@ span.command { build-time dependency on oggdec removed - + + #49 + Disobedience's 'When' column gets out of date + + - diff --git a/disobedience/queue-generic.c b/disobedience/queue-generic.c index de86f29..5d44ffa 100644 --- a/disobedience/queue-generic.c +++ b/disobedience/queue-generic.c @@ -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) */ diff --git a/disobedience/queue.c b/disobedience/queue.c index 0db90d7..00c44c2 100644 --- a/disobedience/queue.c +++ b/disobedience/queue.c @@ -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; }