+ /* Check that the playing track isn't in the queue. There's a race here due
+ * to the fact that we issue the two commands at slightly different times.
+ * If it goes wrong we re-issue and try again, so that we never offer up an
+ * inconsistent state. */
+ if(actual_playing_track) {
+ struct queue_entry *q;
+ for(q = actual_queue; q; q = q->next)
+ if(!strcmp(q->id, actual_playing_track->id))
+ break;
+ if(q) {
+ disorder_eclient_playing(client, playing_completed, 0);
+ disorder_eclient_queue(client, queue_completed, 0);
+ return;
+ }
+ }
+
+ struct queue_entry *q = xmalloc(sizeof *q);
+ if(actual_playing_track) {
+ *q = *actual_playing_track;
+ q->next = actual_queue;
+ playing_track = q;
+ } else {
+ playing_track = NULL;
+ q = actual_queue;
+ }