[vlc-devel] [PATCH 2/2] vout: simplify without cancellation

Thomas Guillem thomas at gllm.fr
Tue Apr 14 22:58:26 CEST 2020


OK

On Tue, Apr 14, 2020, at 21:08, RĂ©mi Denis-Courmont wrote:
> ---
>  src/video_output/control.c      |  2 --
>  src/video_output/control.h      |  1 +
>  src/video_output/video_output.c | 14 +++++---------
>  3 files changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/src/video_output/control.c b/src/video_output/control.c
> index d8da02fc35..fd0c80fe6e 100644
> --- a/src/video_output/control.c
> +++ b/src/video_output/control.c
> @@ -144,7 +144,6 @@ int vout_control_Pop(vout_control_t *ctrl, 
> vout_control_cmd_t *cmd,
>                       vlc_tick_t deadline)
>  {
>      vlc_mutex_lock(&ctrl->lock);
> -    mutex_cleanup_push(&ctrl->lock);
>  
>      if (ctrl->cmd.i_size <= 0) {
>          /* Spurious wakeups are perfectly fine */
> @@ -158,7 +157,6 @@ int vout_control_Pop(vout_control_t *ctrl, 
> vout_control_cmd_t *cmd,
>  
>      while (ctrl->is_held)
>          vlc_cond_wait(&ctrl->wait_available, &ctrl->lock);
> -    vlc_cleanup_pop();
>  
>      bool has_cmd;
>      if (ctrl->cmd.i_size > 0) {
> diff --git a/src/video_output/control.h b/src/video_output/control.h
> index 02b0696028..eee86c4ca9 100644
> --- a/src/video_output/control.h
> +++ b/src/video_output/control.h
> @@ -27,6 +27,7 @@
>  
>  /* */
>  enum {
> +    VOUT_CONTROL_TERMINATE,
>      VOUT_CONTROL_CHANGE_FILTERS,        /* string */
>      VOUT_CONTROL_CHANGE_INTERLACE,      /* boolean */
>  
> diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
> index 6a361e568d..480dfe75f3 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -33,8 +33,6 @@
>  # include "config.h"
>  #endif
>  
> -#include <stdnoreturn.h>
> -
>  #include <vlc_common.h>
>  
>  #include <math.h>
> @@ -1674,7 +1672,7 @@ error:
>   * terminated. It handles the pictures arriving in the video heap and the
>   * display device events.
>   *****************************************************************************/
> -noreturn static void *Thread(void *object)
> +static void *Thread(void *object)
>  {
>      vout_thread_t *vout = object;
>      vout_thread_sys_t *sys = vout->p;
> @@ -1692,10 +1690,11 @@ noreturn static void *Thread(void *object)
>          } else {
>              deadline = VLC_TICK_INVALID;
>          }
> -        while (!vout_control_Pop(&sys->control, &cmd, deadline)) {
> -            int canc = vlc_savecancel();
>  
> +        while (!vout_control_Pop(&sys->control, &cmd, deadline)) {
>              switch(cmd.type) {
> +                case VOUT_CONTROL_TERMINATE:
> +                    return NULL; /* no need to clean &cmd */
>                  case VOUT_CONTROL_CHANGE_FILTERS:
>                      ThreadChangeFilters(vout, cmd.string, NULL, false);
>                      break;
> @@ -1707,17 +1706,14 @@ noreturn static void *Thread(void *object)
>                      break;
>              }
>              vout_control_cmd_Clean(&cmd);
> -            vlc_restorecancel(canc);
>          }
>  
> -        int canc = vlc_savecancel();
>          deadline = VLC_TICK_INVALID;
>          wait = ThreadDisplayPicture(vout, &deadline) != VLC_SUCCESS;
>  
>          const bool picture_interlaced = sys->displayed.is_interlaced;
>  
>          vout_SetInterlacingState(vout, picture_interlaced);
> -        vlc_restorecancel(canc);
>      }
>  }
>  
> @@ -1772,7 +1768,7 @@ void vout_StopDisplay(vout_thread_t *vout)
>  {
>      vout_thread_sys_t *sys = vout->p;
>  
> -    vlc_cancel(sys->thread);
> +    vout_control_PushVoid(&sys->control, VOUT_CONTROL_TERMINATE);
>      vlc_join(sys->thread, NULL);
>  
>      vout_ReleaseDisplay(vout);
> -- 
> 2.26.0
> 
> _______________________________________________
> 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