From e03df0a5bce30b363ab422c779ce9fe9321cc027 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Thu, 26 Nov 2009 20:43:51 +0000 Subject: [PATCH] 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. Organization: Straylight/Edgeware From: Richard Kettlewell --- CHANGES.html | 7 +++++-- disobedience/queue-generic.c | 2 ++ disobedience/queue.c | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) 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; } -- [mdw]