[vlc-devel] [PATCH] clock: handle the INT64_MAX slave update early

Thomas Guillem thomas at gllm.fr
Fri Aug 14 10:08:03 CEST 2020


LGTM

On Thu, Aug 13, 2020, at 14:09, Steve Lhomme wrote:
> Don't lock the main clock when we don't need to.
> ---
>  src/clock/clock.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/src/clock/clock.c b/src/clock/clock.c
> index 26e380b4396..e6c126d1c00 100644
> --- a/src/clock/clock.c
> +++ b/src/clock/clock.c
> @@ -292,17 +292,23 @@ static vlc_tick_t 
> vlc_clock_slave_update(vlc_clock_t *clock,
>                                           unsigned frame_rate_base)
>  {
>      vlc_clock_main_t *main_clock = clock->owner;
> +
> +    if (system_now == INT64_MAX)
> +    {
> +        /* If system_now is INT64_MAX, the update is forced, don't 
> modify anything
> +        * but only notify the new clock point. */
> +        vlc_clock_on_update(clock, INT64_MAX, ts, rate, frame_rate, 
> frame_rate_base);
> +        return INT64_MAX;
> +    }
> +
>      vlc_mutex_lock(&main_clock->lock);
>  
> -    /* If system_now is INT64_MAX, the update is forced, don't modify anything
> -     * but only notify the new clock point. */
> -    vlc_tick_t computed = system_now == INT64_MAX ? INT64_MAX
> -                        : clock->to_system_locked(clock, system_now, ts, rate);
> +    vlc_tick_t computed = clock->to_system_locked(clock, system_now, ts, rate);
>  
>      vlc_mutex_unlock(&main_clock->lock);
>  
>      vlc_clock_on_update(clock, computed, ts, rate, frame_rate, 
> frame_rate_base);
> -    return computed != INT64_MAX ? computed - system_now : INT64_MAX;
> +    return computed - system_now;
>  }
>  
>  static void vlc_clock_slave_reset(vlc_clock_t *clock)
> -- 
> 2.26.2
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list