[vlc-devel] [PATCH 05/11] input: rework decoder_device handling

Steve Lhomme robux4 at ycbcr.xyz
Wed Jul 1 10:31:08 CEST 2020


On 2020-06-30 17:27, Thomas Guillem wrote:
> Merge input_resource_GetVoutDecoderDevice() and input_resource_StartVout() into
> input_resource_RequestVout().
> 
> RequestVout() can be used to create a vout without starting it (if cfg->fmt is
> NULL). It allows the decoder to create a decoder_device from the vout manually,
> then call RequestVout() again with a valid cfg->fmt to start it.
> ---
>   src/input/decoder.c  | 35 ++++++++--------------
>   src/input/resource.c | 71 ++++++++++++++++++++++++--------------------
>   src/input/resource.h |  8 ++---
>   3 files changed, 55 insertions(+), 59 deletions(-)
> 
> diff --git a/src/input/decoder.c b/src/input/decoder.c
> index b013e485f88..4bb809610dd 100644
> --- a/src/input/decoder.c
> +++ b/src/input/decoder.c
> @@ -463,10 +463,9 @@ static int ModuleThread_UpdateVideoFormat( decoder_t *p_dec, vlc_video_context *
>               return -1;
>           }
>       }
> -    int res;
>       if (p_owner->vout_thread_started)
>       {
> -        res = vout_ChangeSource(p_vout, &p_dec->fmt_out.video);
> +        int res = vout_ChangeSource(p_vout, &p_dec->fmt_out.video);
>           if (res == 0)
>               // the display/thread is started and can handle the new source format
>               return 0;
> @@ -476,13 +475,14 @@ static int ModuleThread_UpdateVideoFormat( decoder_t *p_dec, vlc_video_context *
>           .vout = p_vout, .clock = p_owner->p_clock, .fmt = &p_dec->fmt_out.video,
>           .mouse_event = MouseEvent, .mouse_opaque = p_dec,
>       };
> -    res = input_resource_StartVout( p_owner->p_resource, vctx, &cfg);
> -    if (res == 0)
> +    p_vout = input_resource_RequestVout( p_owner->p_resource, vctx, &cfg, NULL);
> +    if (p_vout != NULL)
>       {
>           p_owner->vout_thread_started = true;
>           decoder_Notify(p_owner, on_vout_started, p_vout, vout_order);
> +        return 0;
>       }
> -    return res;
> +    return -1;
>   }
>   
>   static int CreateVoutIfNeeded(vlc_input_decoder_t *p_owner,
> @@ -537,15 +537,11 @@ static int CreateVoutIfNeeded(vlc_input_decoder_t *p_owner,
>       {
>           if (pp_vout || pp_dec_dev)
>           {
> -            vlc_mutex_lock( &p_owner->lock );
>               if ( pp_vout )
>                   *pp_vout = p_owner->p_vout;
>               if ( pp_dec_dev )
> -                *pp_dec_dev = NULL;
> -            input_resource_GetVoutDecoderDevice( p_owner->p_resource,
> -                                                 p_owner->p_vout, order, pp_dec_dev );
> +                *pp_dec_dev = vout_GetDevice(p_owner->p_vout);
>               *order = p_owner->vout_order;
> -            vlc_mutex_unlock( &p_owner->lock );

You should mention why can we used p_owner->p_vout without a lock here. 
(it's read from within the ModuleThread which is the one who 
creates/destroys it)

>           }
>           return 0; // vout unchanged
>       }


More information about the vlc-devel mailing list