[vlc-commits] [Git][videolan/vlc][master] player: don't start next medias if in stopped state

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Fri Mar 15 19:40:41 UTC 2024



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
a9036494 by Thomas Guillem at 2024-03-15T19:07:45+00:00
player: don't start next medias if in stopped state

And don't send the STOPPED state from the STOPPED state.

Fixes the following assert leading to an invalid state:
test_src_player: ../../src/player/player.c:1195: vlc_player_Start: Assertion `!player->input->started' failed.

- - - - -


2 changed files:

- src/player/input.c
- test/src/player/player.c


Changes:

=====================================
src/player/input.c
=====================================
@@ -221,6 +221,7 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
      && state != VLC_PLAYER_STATE_STOPPED)
         return;
 
+    enum vlc_player_state last_state = input->state;
     input->state = state;
 
     /* Override the global state if the player is still playing and has a next
@@ -250,7 +251,8 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
                     player->eos_burst_count = 0;
             }
 
-            vlc_player_WaitRetryDelay(player);
+            if (player->started)
+                vlc_player_WaitRetryDelay(player);
 
             /* Assign the current date after the wait */
             player->last_eos = vlc_tick_now();
@@ -258,13 +260,14 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
             if (!player->deleting)
             {
                 vlc_player_OpenNextMedia(player);
-                if (player->input)
+                /* It is possible to open several medias in a stopped state */
+                if (player->input && player->started)
                     vlc_player_input_Start(player->input);
             }
             if (!player->input)
                 player->started = false;
 
-            send_event = !player->started;
+            send_event = !player->started && last_state != VLC_PLAYER_STATE_STOPPED;
             break;
         case VLC_PLAYER_STATE_STOPPING:
             input->started = false;
@@ -307,6 +310,7 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
 
     if (send_event)
     {
+        assert(player->global_state != input->state);
         player->global_state = input->state;
         vlc_player_SendEvent(player, on_state_changed, player->global_state);
     }


=====================================
test/src/player/player.c
=====================================
@@ -2025,6 +2025,34 @@ test_same_media(struct ctx *ctx)
     test_end(ctx);
 }
 
+static void
+test_media_stopped(struct ctx *ctx)
+{
+    test_log("media_stopped\n");
+
+    vlc_player_t *player = ctx->player;
+    struct media_params params = DEFAULT_MEDIA_PARAMS(VLC_TICK_FROM_MS(10));
+
+    /* This test checks for player_start() success, and doesn't care about the
+     * stopped state. */
+    //params.error = true;
+
+    player_set_current_mock_media(ctx, "media1", &params, true);
+    player_set_current_mock_media(ctx, "media2", &params, false);
+
+    {
+        vec_on_current_media_changed *vec = &ctx->report.on_current_media_changed;
+        while (vec->size != 2)
+            vlc_player_CondWait(player, &ctx->wait);
+    }
+    player_start(ctx);
+
+    wait_state(ctx, VLC_PLAYER_STATE_STARTED);
+    wait_state(ctx, VLC_PLAYER_STATE_STOPPED);
+
+    test_end(ctx);
+}
+
 static void
 test_set_current_media(struct ctx *ctx)
 {
@@ -3063,6 +3091,7 @@ main(void)
     test_outputs(&ctx); /* Must be the first test */
 
     test_same_media(&ctx);
+    test_media_stopped(&ctx);
     test_set_current_media(&ctx);
     test_next_media(&ctx);
     test_seeks(&ctx);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/a90364941ec84b2ea59b4e1a81ae8bf8fcf4bc12

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/a90364941ec84b2ea59b4e1a81ae8bf8fcf4bc12
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list