[vlc-devel] [PATCH] clock: don't return invalid ts when paused

Thomas Guillem thomas at gllm.fr
Wed Sep 4 14:35:40 CEST 2019


vlc_clock_ConvertToSystem() could return INT64_MAX when paused, this was not
documented and not handled at all by the aout and the vout.

To fix this issue, I first tried the obvious choice: handling this INT64_T
value from both outputs. The problem is that I don't really know how to handle
it. Indeed, the main clock and every outputs are requested to pause at the same
time, but they all run on different thread and will process this request on
their own timeline. Therefore, the output might be still running when the clock
is paused. Handling 2 different pause state from the output is not a good idea.

So I decided a simpler fix: the clock will act as it's not paused and will
always return valid values. Indeed, both outputs are very likely to be in the
pause state anyway and will stop requesting/updating time to the clock.

PS: The pause state from the clock is now only used to apply the pause delay on
the reference point.
---
 src/clock/clock.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/clock/clock.c b/src/clock/clock.c
index 15a6cf68e4..cfaef7b151 100644
--- a/src/clock/clock.c
+++ b/src/clock/clock.c
@@ -227,8 +227,6 @@ static vlc_tick_t vlc_clock_slave_to_system_locked(vlc_clock_t *clock,
                                                    vlc_tick_t ts, double rate)
 {
     vlc_clock_main_t *main_clock = clock->owner;
-    if (main_clock->pause_date != VLC_TICK_INVALID)
-        return INT64_MAX;
 
     vlc_tick_t system = main_stream_to_system(main_clock, ts);
     if (system == VLC_TICK_INVALID)
@@ -300,10 +298,7 @@ int vlc_clock_Wait(vlc_clock_t *clock, vlc_tick_t system_now, vlc_tick_t ts,
     while (!main_clock->abort)
     {
         vlc_tick_t deadline;
-        if (main_clock->pause_date != VLC_TICK_INVALID)
-            deadline = INT64_MAX;
-        else
-            deadline = clock->to_system_locked(clock, system_now, ts, rate);
+        deadline = clock->to_system_locked(clock, system_now, ts, rate);
         deadline = __MIN(deadline, max_deadline);
 
         if (vlc_cond_timedwait(&main_clock->cond, &main_clock->lock, deadline))
-- 
2.20.1



More information about the vlc-devel mailing list