From: Richard Kettlewell Date: Sat, 31 Jan 2009 12:33:59 +0000 (+0000) Subject: Set last_playing to NULL when we don't have up to date information X-Git-Tag: 4.3~12 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/3900d6d655918df285b875887aa304666db0f63e?ds=sidebyside Set last_playing to NULL when we don't have up to date information about the playing track (including, importantly, just after pausing). column_length() returns NULL in this case, and ql_update_row() leaves cells that have a NULL value along. The effect is that the played so far indicator is left as it is until we're sure what the right value is. Usually in fact it will already be right, so we don't even lie; when it isn't, at least it jumps around less before reaching the right value. http://code.google.com/p/disorder/issues/detail?id=26 --- diff --git a/disobedience/queue-generic.c b/disobedience/queue-generic.c index fe327ca..636f10c 100644 --- a/disobedience/queue-generic.c +++ b/disobedience/queue-generic.c @@ -127,6 +127,8 @@ const char *column_length(const struct queue_entry *q, if(last_state & DISORDER_TRACK_PAUSED) l = playing_track->sofar; else { + if(!last_playing) + return NULL; time(&now); l = playing_track->sofar + (now - last_playing); } @@ -176,11 +178,14 @@ void ql_update_row(struct queue_entry *q, iter = my_iter; } /* Update all the columns */ - for(int col = 0; col < ql->ncolumns; ++col) - gtk_list_store_set(ql->store, iter, - col, ql->columns[col].value(q, - ql->columns[col].data), - -1); + for(int col = 0; col < ql->ncolumns; ++col) { + const char *const v = ql->columns[col].value(q, + ql->columns[col].data); + if(v) + gtk_list_store_set(ql->store, iter, + col, v, + -1); + } gtk_list_store_set(ql->store, iter, ql->ncolumns + QUEUEPOINTER_COLUMN, q, -1); diff --git a/disobedience/queue.c b/disobedience/queue.c index bf77fd0..6dac960 100644 --- a/disobedience/queue.c +++ b/disobedience/queue.c @@ -29,7 +29,10 @@ static struct queue_entry *actual_playing_track; /** @brief The playing track */ struct queue_entry *playing_track; -/** @brief When we last got the playing track */ +/** @brief When we last got the playing track + * + * Set to 0 if the timings are currently off due to having just unpaused. + */ time_t last_playing; static void queue_completed(void *v, @@ -118,6 +121,9 @@ static void playing_changed(const char attribute((unused)) *event, void attribute((unused)) *callbackdata) { D(("playing_changed")); gtk_label_set_text(GTK_LABEL(report_label), "updating playing track"); + /* Setting last_playing=0 means that we don't know what the correct value + * is right now, e.g. because things have been deranged by a pause. */ + last_playing = 0; disorder_eclient_playing(client, playing_completed, 0); }