examples: playout: Decrement the currently-playing counter correctly
authorNirbheek Chauhan <nirbheek@centricular.com>
Fri, 12 Jun 2015 20:05:59 +0000 (01:35 +0530)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 12 Jun 2015 20:14:57 +0000 (21:14 +0100)
Only do that when we're removing an item that was playing, otherwise we'll mess
things up while trying to edit the play queue (playlist).

tests/examples/playout.c

index 29ae812..05afe21 100644 (file)
@@ -757,8 +757,9 @@ playout_app_remove_item (PlayoutItem * item)
 
   g_mutex_lock (&app->play_queue_lock);
   g_ptr_array_remove (app->play_queue, item);
-  /* This item has been removed from the array, decrement the index */
-  app->play_queue_current--;
+  if (item->state >= PLAYOUT_ITEM_STATE_ACTIVATED)
+    /* Removed item was playing; decrement the current-play-queue index */
+    app->play_queue_current--;
   g_mutex_unlock (&app->play_queue_lock);
 
   /* Don't call this again */