[vlc-devel] [PATCH 08/21] video_output: use INT64_MAX for the invalid control pop deadline

Rémi Denis-Courmont remi at remlab.net
Tue Sep 15 18:05:00 CEST 2020


Le tiistaina 15. syyskuuta 2020, 15.36.13 EEST Steve Lhomme a écrit :
> This simplifies setting the value.
> 
> When reading a control with an invalid deadline, we don't wait for a command
> to arrive.

I'm not sure relying implicity on invalid deadline being a large value really 
improves readability, even if it strictly speaking simplifies the code.

> ---
>  src/video_output/control.c      |  2 +-
>  src/video_output/control.h      |  2 ++
>  src/video_output/video_output.c | 14 ++++++--------
>  3 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/src/video_output/control.c b/src/video_output/control.c
> index 3b7fabb07e9..190792a472a 100644
> --- a/src/video_output/control.c
> +++ b/src/video_output/control.c
> @@ -114,7 +114,7 @@ int vout_control_Pop(vout_control_t *ctrl,
> vout_control_cmd_t *cmd,
> 
>      if (ctrl->cmd.i_size <= 0) {
>          /* Spurious wakeups are perfectly fine */
> -        if (deadline != VLC_TICK_INVALID && ctrl->can_sleep) {
> +        if (deadline != INVALID_DEADLINE && ctrl->can_sleep) {
>              ctrl->is_waiting = true;
>              vlc_cond_signal(&ctrl->wait_available);
>              vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, deadline);
> diff --git a/src/video_output/control.h b/src/video_output/control.h index
> 5d84db34d13..78a41502c5d 100644
> --- a/src/video_output/control.h
> +++ b/src/video_output/control.h
> @@ -69,6 +69,8 @@ void vout_control_Hold(vout_control_t *);
>  void vout_control_Release(vout_control_t *);
> 
>  /* control inside of the vout thread */
> +#define INVALID_DEADLINE   ((vlc_tick_t) INT64_MAX)

Useless cast.

> +
>  int vout_control_Pop(vout_control_t *, vout_control_cmd_t *, vlc_tick_t
> deadline); void vout_control_Dead(vout_control_t *);
> 
> diff --git a/src/video_output/video_output.c
> b/src/video_output/video_output.c index 74f0435628a..6e78e7f71d3 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -1486,7 +1486,7 @@ static int ThreadDisplayPicture(vout_thread_sys_t
> *vout, vlc_tick_t *deadline) vlc_mutex_unlock(&sys->filter.lock);
> 
>      if (deadline)
> -        *deadline = VLC_TICK_INVALID;
> +        *deadline = INVALID_DEADLINE;
> 
>      if (first)
>          if (ThreadDisplayPreparePicture(vout, true, frame_by_frame,
> &paused)) /* FIXME not sure it is ok */ @@ -1537,10 +1537,8 @@ static int
> ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline) // the
> next frame is not in the future, skip the current one display_next_frame =
> true;
> 
> -            if (deadline) {
> -                if (*deadline == VLC_TICK_INVALID || date_next < *deadline)
> -                    *deadline = date_next;
> -            }
> +            if (deadline)
> +                *deadline = __MIN(*deadline, date_next);
>          }
>      }
> 
> @@ -1883,7 +1881,7 @@ static void *Thread(void *object)
>      vout_thread_sys_t *vout = object;
>      vout_thread_sys_t *sys = vout;
> 
> -    vlc_tick_t deadline = VLC_TICK_INVALID;
> +    vlc_tick_t deadline = INVALID_DEADLINE;
>      bool wait = false;
> 
>      for (;;) {
> @@ -1892,9 +1890,9 @@ static void *Thread(void *object)
>          if (wait)
>          {
>              const vlc_tick_t max_deadline = vlc_tick_now() +
> VLC_TICK_FROM_MS(100); -            deadline = deadline == VLC_TICK_INVALID
> ? max_deadline : __MIN(deadline, max_deadline); +            deadline =
> __MIN(deadline, max_deadline);
>          } else {
> -            deadline = VLC_TICK_INVALID;
> +            deadline = INVALID_DEADLINE;
>          }
> 
>          while (!vout_control_Pop(&sys->control, &cmd, deadline)) {


-- 
レミ・デニ-クールモン
http://www.remlab.net/





More information about the vlc-devel mailing list