[vlc-devel] [PATCH 03/48] video_output: add a function to release the display separately from its thread

Thomas Guillem thomas at gllm.fr
Mon Oct 14 10:21:08 CEST 2019


LGTM then, this fixes an unlikely UB in case of thread clone failure.

On Fri, Oct 11, 2019, at 15:33, Steve Lhomme wrote:
> vout_Stop does a vout_StopDisplay + vout_DisableWindow
> 
> When we failed to start the thread we shouldn't stop it (by calling 
> vout_StopDisplay)
> So just call vout_ReleaseDisplay + vout_DisableWindow
> ---
>  src/video_output/video_output.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
> index 44b2fb503d3..060768e1ab6 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -1688,13 +1688,11 @@ noreturn static void *Thread(void *object)
>      }
>  }
>  
> -void vout_StopDisplay(vout_thread_t *vout)
> +static void vout_ReleaseDisplay(vout_thread_t *vout)
>  {
>      vout_thread_sys_t *sys = vout->p;
>  
>      assert(sys->display != NULL);
> -    vlc_cancel(sys->thread);
> -    vlc_join(sys->thread, NULL);
>  
>      if (sys->spu_blend != NULL)
>          filter_DeleteBlend(sys->spu_blend);
> @@ -1732,6 +1730,16 @@ void vout_StopDisplay(vout_thread_t *vout)
>      video_format_Clean(&sys->original);
>  }
>  
> +void vout_StopDisplay(vout_thread_t *vout)
> +{
> +    vout_thread_sys_t *sys = vout->p;
> +
> +    vlc_cancel(sys->thread);
> +    vlc_join(sys->thread, NULL);
> +
> +    vout_ReleaseDisplay(vout);
> +}
> +
>  static void vout_DisableWindow(vout_thread_t *vout)
>  {
>      vout_thread_sys_t *sys = vout->p;
> @@ -2010,7 +2018,8 @@ int vout_Request(const vout_configuration_t *cfg, 
> input_thread_t *input)
>          return -1;
>      }
>      if (vlc_clone(&sys->thread, Thread, vout, 
> VLC_THREAD_PRIORITY_OUTPUT)) {
> -        vout_Stop(vout);
> +        vout_ReleaseDisplay(vout);
> +        vout_DisableWindow(vout);
>          return -1;
>      }
>  
> -- 
> 2.17.1
> 
> _______________________________________________
> 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