Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
ec162e44 by Thomas Guillem at 2026-01-19T06:37:01+00:00
test: player: pause: use wait_state helper

- - - - -
efd0465d by Thomas Guillem at 2026-01-19T06:37:01+00:00
test: player: pause: fix data-race

Return a copy of the report_timer.

- - - - -
64d7b7e6 by Thomas Guillem at 2026-01-19T06:37:01+00:00
player: timer: do what the comment say

1/2 to fix spurious player pause test fail:

```
test_src_player_pause: ../../test/src/player/pause.c:97: test_pause: Assertion 
`paused_time == new_paused_time' failed.
```

This could happen after few seconds when running 100 pause tests in
parallel and with heavy CPU load

- - - - -
36e7e738 by Thomas Guillem at 2026-01-19T06:37:01+00:00
player: timer: compare last ts with last updated one

If the input source send a ts, that is not updated (because audio or
video have higher priority), don't store it in last_ts.

Fix video ts being updated 2 times when the same picture was displayed more
than one time.

2/2 to fix spurious player pause test fail:

```
test_src_player_pause: ../../test/src/player/pause.c:97: test_pause: Assertion 
`paused_time == new_paused_time' fail
```

This could happen after few seconds when running 100 pause tests in
parallel and with heavy CPU load

- - - - -
39668d77 by Thomas Guillem at 2026-01-19T06:37:01+00:00
player: replace bool with an enum

A new state will be added in the next commit.
No functional changes.

Refs #28353

- - - - -
46214fdc by Thomas Guillem at 2026-01-19T06:37:01+00:00
player: timer: don't interpolate last point after resume from pause

Wait for a point to be updated before using interpolation.

Fixes #28353

(No problem on Qt as it use the timer API directly).

- - - - -


3 changed files:

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


Changes:

=====================================
src/player/player.h
=====================================
@@ -230,7 +230,12 @@ struct vlc_player_timer
 
     vlc_tick_t seek_ts;
     double seek_position;
-    bool paused;
+    enum
+    {
+        UPDATE_STATE_RESUMED,
+        UPDATE_STATE_PAUSED,
+        UPDATE_STATE_RESUMING,
+    } update_state;
     bool stopping;
 
     struct vlc_player_timer_source sources[VLC_PLAYER_TIMER_TYPE_COUNT];


=====================================
src/player/timer.c
=====================================
@@ -40,7 +40,7 @@ vlc_player_ResetTimer(vlc_player_t *player)
     player->timer.smpte_source.smpte.last_framenum = ULONG_MAX;
     player->timer.seek_ts = VLC_TICK_INVALID;
     player->timer.seek_position = -1;
-    player->timer.paused = false;
+    player->timer.update_state = UPDATE_STATE_RESUMED;
     player->timer.stopping = false;
 
     vlc_mutex_unlock(&player->timer.lock);
@@ -261,7 +261,7 @@ vlc_player_UpdateTimerEvent(vlc_player_t *player, 
vlc_es_id_t *es_source,
 
         case VLC_PLAYER_TIMER_EVENT_PAUSED:
             assert(system_date != VLC_TICK_INVALID);
-            player->timer.paused = true;
+            player->timer.update_state = UPDATE_STATE_PAUSED;
 
             for (size_t i = 0; i < VLC_PLAYER_TIMER_TYPE_COUNT; ++i)
             {
@@ -276,7 +276,7 @@ vlc_player_UpdateTimerEvent(vlc_player_t *player, 
vlc_es_id_t *es_source,
 
         case VLC_PLAYER_TIMER_EVENT_PLAYING:
             assert(!player->timer.stopping);
-            player->timer.paused = false;
+            player->timer.update_state = UPDATE_STATE_RESUMING;
             break;
 
         case VLC_PLAYER_TIMER_EVENT_STOPPING:
@@ -400,11 +400,11 @@ vlc_player_UpdateTimerBestSource(vlc_player_t *player, 
vlc_es_id_t *es_source,
          * time from the video source, only send it if different in that case.
          */
         if (point->ts != player->timer.last_ts
-          || source->point.system_date != system_date
-          || system_date != VLC_TICK_MAX)
+          || (source->point.system_date != system_date && system_date != 
VLC_TICK_MAX))
         {
             vlc_player_UpdateTimerSource(player, source, point->rate, 
point->ts,
                                          system_date);
+            player->timer.last_ts = point->ts;
 
             /* It is possible to receive valid points while seeking. These
              * points could be updated when the input thread didn't yet process
@@ -420,6 +420,9 @@ vlc_player_UpdateTimerBestSource(vlc_player_t *player, 
vlc_es_id_t *es_source,
             if (!vlc_list_is_empty(&source->listeners))
                 vlc_player_SendTimerSourceUpdates(player, source, force_update,
                                                   &source->point);
+
+            if (player->timer.update_state == UPDATE_STATE_RESUMING)
+                player->timer.update_state = UPDATE_STATE_RESUMED;
         }
     }
 }
@@ -443,7 +446,6 @@ vlc_player_UpdateTimerSmpteSource(vlc_player_t *player, 
vlc_es_id_t *es_source,
          || frame_rate_base != source->smpte.frame_rate_base))
         {
             assert(frame_rate_base != 0);
-            player->timer.last_ts = VLC_TICK_INVALID;
             vlc_player_UpdateSmpteTimerFPS(player, source, frame_rate,
                                            frame_rate_base);
         }
@@ -514,7 +516,7 @@ vlc_player_UpdateTimer(vlc_player_t *player, vlc_es_id_t 
*es_source,
     assert(point->ts != VLC_TICK_INVALID);
 
     vlc_tick_t system_date = point->system_date;
-    if (player->timer.paused)
+    if (player->timer.update_state == UPDATE_STATE_PAUSED)
     {
         if (es_source != NULL && point->system_date == VLC_TICK_MAX)
         {
@@ -532,8 +534,6 @@ vlc_player_UpdateTimer(vlc_player_t *player, vlc_es_id_t 
*es_source,
     vlc_player_UpdateTimerSmpteSource(player, es_source, point, system_date,
                                       frame_rate, frame_rate_base);
 
-    player->timer.last_ts = point->ts;
-
     vlc_mutex_unlock(&player->timer.lock);
 }
 
@@ -599,7 +599,8 @@ vlc_player_GetTimerPoint(vlc_player_t *player, bool 
*seeking,
     if (player->timer.best_source.point.system_date == VLC_TICK_INVALID)
         goto end;
 
-    if (system_now != VLC_TICK_INVALID && !player->timer.paused)
+    if (system_now != VLC_TICK_INVALID
+     && player->timer.update_state == UPDATE_STATE_RESUMED)
         ret = 
vlc_player_timer_point_Interpolate(&player->timer.best_source.point,
                                                  system_now, out_ts, out_pos);
     else


=====================================
test/src/player/pause.c
=====================================
@@ -8,7 +8,7 @@
 #include "common.h"
 #include "timers.h"
 
-static struct report_timer *
+static struct report_timer
 wait_timer_report(vlc_player_t *player, struct timer_state *timer,
                   unsigned type)
 {
@@ -24,15 +24,16 @@ wait_timer_report(vlc_player_t *player, struct timer_state 
*timer,
         }
     }
     assert(r_found != NULL);
+    struct report_timer ret_timer = *r_found;
     player_unlock_timer(player, timer);
-    return r_found;
+    return ret_timer;
 }
 
-static struct report_timer *
+static struct report_timer
 get_timer_report(vlc_player_t *player, struct timer_state *timer)
 {
     player_lock_timer(player, timer);
-    struct report_timer *r = &timer->vec.data[timer->vec.size -1];
+    struct report_timer r = timer->vec.data[timer->vec.size -1];
     player_unlock_timer(player, timer);
     return r;
 }
@@ -52,15 +53,8 @@ test_pause(struct ctx *ctx)
     /* Start paused */
     vlc_player_SetStartPaused(player, true);
     player_start(ctx);
-    {
-        vec_on_state_changed *vec = &ctx->report.on_state_changed;
-        while (vec->size == 0 || VEC_LAST(vec) != VLC_PLAYER_STATE_PAUSED)
-            vlc_player_CondWait(player, &ctx->wait);
-        assert(vec->size == 3);
-        assert(vec->data[0] == VLC_PLAYER_STATE_STARTED);
-        assert(vec->data[1] == VLC_PLAYER_STATE_PLAYING);
-        assert(vec->data[2] == VLC_PLAYER_STATE_PAUSED);
-    }
+
+    wait_state(ctx, VLC_PLAYER_STATE_PAUSED);
 
     {
         vec_on_position_changed *vec = &ctx->report.on_position_changed;
@@ -74,12 +68,7 @@ test_pause(struct ctx *ctx)
     /* Resume */
     vlc_player_Resume(player);
 
-    {
-        vec_on_state_changed *vec = &ctx->report.on_state_changed;
-        while (VEC_LAST(vec) != VLC_PLAYER_STATE_PLAYING)
-            vlc_player_CondWait(player, &ctx->wait);
-        assert(vec->size == 4);
-    }
+    wait_state(ctx, VLC_PLAYER_STATE_PLAYING);
 
     {
         vec_on_position_changed *vec = &ctx->report.on_position_changed;
@@ -94,25 +83,19 @@ test_pause(struct ctx *ctx)
     /* Pause again (while playing) */
     vlc_player_Pause(player);
 
-    {
-        vec_on_state_changed *vec = &ctx->report.on_state_changed;
-        while (VEC_LAST(vec) != VLC_PLAYER_STATE_PAUSED)
-            vlc_player_CondWait(player, &ctx->wait);
-        assert(vec->size == 5);
-    }
+    wait_state(ctx, VLC_PLAYER_STATE_PAUSED);
 
     /* Ensure all timers are paused */
-    struct report_timer *r_video_paused, *r_paused;
-    r_video_paused = wait_timer_report(player, &video_timer, 
REPORT_TIMER_PAUSED);
-    r_paused = wait_timer_report(player, &timer, REPORT_TIMER_PAUSED);
+    wait_timer_report(player, &video_timer, REPORT_TIMER_PAUSED);
+    wait_timer_report(player, &timer, REPORT_TIMER_PAUSED);
 
     /* Ensure we stay paused */
     vlc_tick_sleep(VLC_TICK_FROM_MS(100));
 
     /* Ensure the last video timer report is the paused one (and that no ouput
      * are updated after) */
-    assert(get_timer_report(player, &video_timer) == r_video_paused);
-    assert(get_timer_report(player, &timer) == r_paused);
+    assert(get_timer_report(player, &video_timer).type == REPORT_TIMER_PAUSED);
+    assert(get_timer_report(player, &timer).type == REPORT_TIMER_PAUSED);
 
     test_end(ctx);
     player_remove_timer(player, &video_timer);



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/5dd32a7e17e91eb3afc494b820d4bfb0c7668dcc...46214fdcebb91622bd8beb7eb69c4a78b00f2cf9

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/5dd32a7e17e91eb3afc494b820d4bfb0c7668dcc...46214fdcebb91622bd8beb7eb69c4a78b00f2cf9
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to