[vlc-devel] [PATCH 09/10] WIP: player: implement gapless

Thomas Guillem thomas at gllm.fr
Tue Mar 19 17:45:24 CET 2019


Notify the aout when there is a next media to play

FIXME: next_media are missed when they are not added from the beginning.
---
 src/input/player.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/input/player.c b/src/input/player.c
index a45f6b1d38..b59ae295aa 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -697,6 +697,17 @@ vlc_player_input_Start(struct vlc_player_input *input)
     return ret;
 }
 
+static void
+vlc_player_SetGaplessEnabled(vlc_player_t *player, bool enabled)
+{
+    audio_output_t *aout = input_resource_HoldAout(player->resource);
+    if (aout)
+    {
+        aout_OutputSetGaplessEnabled(aout, enabled);
+        aout_Release(aout);
+    }
+}
+
 static void
 vlc_player_PrepareNextMedia(vlc_player_t *player)
 {
@@ -711,6 +722,7 @@ vlc_player_PrepareNextMedia(vlc_player_t *player)
     player->next_media =
         player->media_provider->get_next(player, player->media_provider_data);
     player->has_next_media = true;
+    vlc_player_SetGaplessEnabled(player, player->next_media != NULL);
 }
 
 static int
@@ -971,15 +983,13 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
             if (input == player->input)
                 player->input = NULL;
 
-            if (player->started)
-            {
-                vlc_player_PrepareNextMedia(player);
-                if (!player->next_media)
-                    player->started = false;
-            }
+            if (!player->next_media)
+                player->started = false;
             send_event = !player->started;
             break;
         case VLC_PLAYER_STATE_STARTED:
+            vlc_player_PrepareNextMedia(player);
+            /* fall-through */
         case VLC_PLAYER_STATE_PLAYING:
             if (player->started &&
                 player->global_state == VLC_PLAYER_STATE_PLAYING)
@@ -2152,6 +2162,7 @@ vlc_player_InvalidateNextMedia(vlc_player_t *player)
     }
     player->has_next_media = false;
 
+    vlc_player_SetGaplessEnabled(player, false);
 }
 
 int
@@ -2218,6 +2229,7 @@ vlc_player_Stop(vlc_player_t *player)
     vlc_player_destructor_AddInput(player, input);
     player->input = NULL;
 
+    vlc_player_SetGaplessEnabled(player, false);
 }
 
 void
@@ -3451,6 +3463,7 @@ vlc_player_Delete(vlc_player_t *player)
 
     vlc_player_DestroyLocks(player);
 
+    vlc_player_SetGaplessEnabled(player, false);
     audio_output_t *aout = vlc_player_aout_Hold(player);
     if (aout)
     {
-- 
2.20.1



More information about the vlc-devel mailing list