[vlc-commits] [Git][videolan/vlc][master] 6 commits: test: player: add pts_delay in struct media_params

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Apr 14 12:40:08 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
c2429632 by Thomas Guillem at 2024-04-14T12:19:45+00:00
test: player: add pts_delay in struct media_params

Refs #26609

- - - - -
55c2b8a8 by Thomas Guillem at 2024-04-14T12:19:45+00:00
test: player: set pts_delay to the length of the test

This will prevent a RESET_PCR and ensure we receive all outputs points.

Refs #26609

- - - - -
b685494e by Thomas Guillem at 2024-04-14T12:19:45+00:00
player: timer: assert the state is handled

- - - - -
1c5d6998 by Thomas Guillem at 2024-04-14T12:19:45+00:00
player: timer: split vlc_player_UpdateTimer

In 2 functions: vlc_player_UpdateTimerBestSource and
vlc_player_UpdateTimerSmpteSource.

No functional changes.

- - - - -
acf833a6 by Thomas Guillem at 2024-04-14T12:19:45+00:00
player: timer: don't update BestSource when stopping

This will prevent to send updates after the last discontinuity (when the output
is deleted) from other ES sources.

This could happen with a high CPU load:

timer: update: source: audio/0, ts: 197001 npt: 1
timer: update: source: audio/0, ts: 198001 npt: 1
timer: update: source: audio/0, ts: 199001 npt: 1
timer: discontinuity: source: input
timer: discontinuity: source: audio/0
timer: update: source: video/0, ts: 191660 npt: 1
timer: discontinuity: source: video/0

Refs #26609

- - - - -
d221a4a4 by Thomas Guillem at 2024-04-14T12:19:45+00:00
player: don't add npt to input times

The player timer will handle it.

Fixes #26609

- - - - -


4 changed files:

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


Changes:

=====================================
src/player/input.c
=====================================
@@ -276,6 +276,10 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
                                         VLC_PLAYER_TIMER_STATE_DISCONTINUITY,
                                         VLC_TICK_INVALID);
 
+            vlc_player_UpdateTimerState(player, NULL,
+                                        VLC_PLAYER_TIMER_STATE_STOPPING,
+                                        VLC_TICK_INVALID);
+
             if (input == player->input)
                 player->input = NULL;
 
@@ -945,7 +949,7 @@ input_thread_Events(input_thread_t *input_thread,
                 const struct vlc_player_timer_point point = {
                     .position = input->position,
                     .rate = input->rate,
-                    .ts = input->time + input->normal_time,
+                    .ts = input->time,
                     .length = input->length,
                     .system_date = system_date,
                 };


=====================================
src/player/player.h
=====================================
@@ -208,6 +208,7 @@ enum vlc_player_timer_state
     VLC_PLAYER_TIMER_STATE_PLAYING,
     VLC_PLAYER_TIMER_STATE_PAUSED,
     VLC_PLAYER_TIMER_STATE_DISCONTINUITY,
+    VLC_PLAYER_TIMER_STATE_STOPPING,
 };
 
 struct vlc_player_timer


=====================================
src/player/timer.c
=====================================
@@ -237,12 +237,18 @@ vlc_player_UpdateTimerState(vlc_player_t *player, vlc_es_id_t *es_source,
             assert(system_date != VLC_TICK_INVALID);
             break;
 
-        default:
         case VLC_PLAYER_TIMER_STATE_PLAYING:
             break;
+
+        case VLC_PLAYER_TIMER_STATE_STOPPING:
+            break;
+
+        default:
+            vlc_assert_unreachable();
     }
 
-    player->timer.state = state;
+    if (player->timer.state != VLC_PLAYER_TIMER_STATE_STOPPING)
+        player->timer.state = state;
 
     if (!notify)
     {
@@ -328,59 +334,13 @@ vlc_player_UpdateTimerSource(vlc_player_t *player,
         source->point.position = player->timer.input_position;
 }
 
-void
-vlc_player_UpdateTimer(vlc_player_t *player, vlc_es_id_t *es_source,
-                       bool es_source_is_master,
-                       const struct vlc_player_timer_point *point,
-                       vlc_tick_t normal_time,
-                       unsigned frame_rate, unsigned frame_rate_base)
+static void
+vlc_player_UpdateTimerBestSource(vlc_player_t *player, vlc_es_id_t *es_source,
+                                 bool es_source_is_master,
+                                 const struct vlc_player_timer_point *point,
+                                 vlc_tick_t system_date,
+                                 bool force_update)
 {
-    struct vlc_player_timer_source *source;
-    assert(point);
-    /* A null source can't be the master */
-    assert(es_source == NULL ? !es_source_is_master : true);
-
-    vlc_mutex_lock(&player->timer.lock);
-
-    bool force_update = false;
-    if (!es_source) /* input source */
-    {
-        /* Only valid for input sources */
-        if (player->timer.input_normal_time != normal_time)
-        {
-            player->timer.input_normal_time = normal_time;
-            player->timer.last_ts = VLC_TICK_INVALID;
-            force_update = true;
-        }
-        if (player->timer.input_length != point->length
-         && point->length >= VLC_TICK_0)
-        {
-            player->timer.input_length = point->length;
-            player->timer.last_ts = VLC_TICK_INVALID;
-            force_update = true;
-        }
-        /* Will likely be overridden by non input source */
-        player->timer.input_position = point->position;
-
-        if (point->ts == VLC_TICK_INVALID
-         || point->system_date == VLC_TICK_INVALID)
-        {
-            /* ts can only be invalid from the input source */
-            vlc_mutex_unlock(&player->timer.lock);
-            return;
-        }
-    }
-
-    assert(point->ts != VLC_TICK_INVALID);
-
-    vlc_tick_t system_date = point->system_date;
-    if (player->timer.state == VLC_PLAYER_TIMER_STATE_PAUSED)
-        system_date = VLC_TICK_MAX;
-
-    /* An update after a discontinuity means that the playback is resumed */
-    if (player->timer.state == VLC_PLAYER_TIMER_STATE_DISCONTINUITY)
-        player->timer.state = VLC_PLAYER_TIMER_STATE_PLAYING;
-
     /* Best source priority:
      * 1/ es_source != NULL when paused (any ES tracks when paused. Indeed,
      * there is likely no audio update (master) when paused but only video
@@ -389,7 +349,7 @@ vlc_player_UpdateTimer(vlc_player_t *player, vlc_es_id_t *es_source,
      * 3/ es_source != NULL (from the first ES track updated)
      * 4/ es_source == NULL (from the input)
      */
-    source = &player->timer.best_source;
+    struct vlc_player_timer_source *source = &player->timer.best_source;
     if (!source->es || es_source_is_master
      || (es_source && player->timer.state == VLC_PLAYER_TIMER_STATE_PAUSED))
         source->es = es_source;
@@ -429,8 +389,15 @@ vlc_player_UpdateTimer(vlc_player_t *player, vlc_es_id_t *es_source,
                                                   &source->point);
         }
     }
+}
 
-    source = &player->timer.smpte_source;
+static void
+vlc_player_UpdateTimerSmpteSource(vlc_player_t *player, vlc_es_id_t *es_source,
+                                  const struct vlc_player_timer_point *point,
+                                  vlc_tick_t system_date,
+                                  unsigned frame_rate, unsigned frame_rate_base)
+{
+    struct vlc_player_timer_source *source = &player->timer.smpte_source;
     /* SMPTE source: only the video source */
     if (!source->es && es_source && vlc_es_id_GetCat(es_source) == VIDEO_ES)
         source->es = es_source;
@@ -458,6 +425,67 @@ vlc_player_UpdateTimer(vlc_player_t *player, vlc_es_id_t *es_source,
                                                        &source->point);
         }
     }
+}
+
+void
+vlc_player_UpdateTimer(vlc_player_t *player, vlc_es_id_t *es_source,
+                       bool es_source_is_master,
+                       const struct vlc_player_timer_point *point,
+                       vlc_tick_t normal_time,
+                       unsigned frame_rate, unsigned frame_rate_base)
+{
+    assert(point);
+    /* A null source can't be the master */
+    assert(es_source == NULL ? !es_source_is_master : true);
+
+    vlc_mutex_lock(&player->timer.lock);
+
+    bool force_update = false;
+    if (!es_source) /* input source */
+    {
+        /* Only valid for input sources */
+        if (player->timer.input_normal_time != normal_time)
+        {
+            player->timer.input_normal_time = normal_time;
+            player->timer.last_ts = VLC_TICK_INVALID;
+            force_update = true;
+        }
+        if (player->timer.input_length != point->length
+         && point->length >= VLC_TICK_0)
+        {
+            player->timer.input_length = point->length;
+            player->timer.last_ts = VLC_TICK_INVALID;
+            force_update = true;
+        }
+        /* Will likely be overridden by non input source */
+        player->timer.input_position = point->position;
+
+        if (point->ts == VLC_TICK_INVALID
+         || point->system_date == VLC_TICK_INVALID)
+        {
+            /* ts can only be invalid from the input source */
+            vlc_mutex_unlock(&player->timer.lock);
+            return;
+        }
+    }
+
+    assert(point->ts != VLC_TICK_INVALID);
+
+    vlc_tick_t system_date = point->system_date;
+    if (player->timer.state == VLC_PLAYER_TIMER_STATE_PAUSED)
+        system_date = VLC_TICK_MAX;
+
+    /* An update after a discontinuity means that the playback is resumed */
+    if (player->timer.state == VLC_PLAYER_TIMER_STATE_DISCONTINUITY)
+        player->timer.state = VLC_PLAYER_TIMER_STATE_PLAYING;
+
+    if (player->timer.state != VLC_PLAYER_TIMER_STATE_STOPPING)
+        vlc_player_UpdateTimerBestSource(player, es_source,
+                                         es_source_is_master, point, system_date,
+                                         force_update);
+
+    vlc_player_UpdateTimerSmpteSource(player, es_source, point, system_date,
+                                      frame_rate, frame_rate_base);
 
     player->timer.last_ts = point->ts;
 


=====================================
test/src/player/player.c
=====================================
@@ -217,6 +217,7 @@ struct media_params
     bool can_pause;
     bool error;
     bool null_names;
+    vlc_tick_t pts_delay;
 
     const char *config;
 };
@@ -240,6 +241,7 @@ struct media_params
     .can_pause = true, \
     .error = false, \
     .null_names = false, \
+    .pts_delay = DEFAULT_PTS_DELAY, \
     .config = NULL, \
 }
 
@@ -783,7 +785,7 @@ create_mock_media(const char *name, const struct media_params *params)
         "sub_packetized=%d;length=%"PRId64";audio_sample_length=%"PRId64";"
         "video_frame_rate=%u;video_frame_rate_base=%u;"
         "title_count=%zu;chapter_count=%zu;"
-        "can_seek=%d;can_pause=%d;error=%d;null_names=%d;"
+        "can_seek=%d;can_pause=%d;error=%d;null_names=%d;pts_delay=%"PRId64";"
         "config=%s;attachment_count=%zu",
         params->track_count[VIDEO_ES], params->track_count[AUDIO_ES],
         params->track_count[SPU_ES], params->program_count,
@@ -792,6 +794,7 @@ create_mock_media(const char *name, const struct media_params *params)
         params->video_frame_rate, params->video_frame_rate_base,
         params->title_count, params->chapter_count,
         params->can_seek, params->can_pause, params->error, params->null_names,
+        params->pts_delay,
         params->config ? params->config : "", params->attachment_count);
     assert(ret != -1);
     input_item_t *item = input_item_New(url, name);
@@ -2633,6 +2636,7 @@ test_timers(struct ctx *ctx)
         for (size_t j = 0; j < ARRAY_SIZE(df_min_test_list); ++j)
         {
             unsigned minute = df_min_test_list[j];
+            vlc_tick_t check_duration = VLC_TICK_FROM_SEC(2);
 
             struct media_params params =
                 DEFAULT_MEDIA_PARAMS(minute * VLC_TICK_FROM_SEC(60)
@@ -2643,10 +2647,14 @@ test_timers(struct ctx *ctx)
             params.video_frame_rate = fps * 1000;
             params.video_frame_rate_base = 1001;
 
+            /* This will prevent a RESET_PCR and ensure we receive all outputs
+             * points. */
+            params.pts_delay = check_duration;
+
             player_set_current_mock_media(ctx, "media1", &params, false);
             player_set_rate(ctx, 24);
 
-            vlc_player_SetTime(player, params.length - VLC_TICK_FROM_SEC(2));
+            vlc_player_SetTime(player, params.length - check_duration);
 
             player_start(ctx);
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e64f5d7cc3b3f3c94e5c50a536d5b20eb1e7ae74...d221a4a4db538f6a30825b01dcf16a58e4f62647

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e64f5d7cc3b3f3c94e5c50a536d5b20eb1e7ae74...d221a4a4db538f6a30825b01dcf16a58e4f62647
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