[vlc-devel] [PATCH 03/26] decoder: get the decoder device from the vout

Rémi Denis-Courmont remi at remlab.net
Sat Sep 21 09:26:38 CEST 2019


Le perjantaina 20. syyskuuta 2019, 17.28.33 EEST Steve Lhomme a écrit :
> ---
>  src/audio_output/filters.c       |  2 +-
>  src/input/decoder.c              | 12 ++++++++++--
>  src/input/resource.c             |  7 ++++---
>  src/input/resource.h             |  5 +++--
>  src/video_output/video_output.c  | 14 +++++++++++++-
>  src/video_output/vout_internal.h |  4 +++-
>  6 files changed, 34 insertions(+), 10 deletions(-)
> 
> diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
> index 6a37c8e8ab7..dad467b44f0 100644
> --- a/src/audio_output/filters.c
> +++ b/src/audio_output/filters.c
> @@ -395,7 +395,7 @@ vout_thread_t *aout_filter_GetVout(filter_t *filter,
> const video_format_t *fmt)
> 
>      video_format_AdjustColorSpace(&adj_fmt);
> 
> -    if (vout_Request(&cfg, NULL)) {
> +    if (vout_Request(&cfg, NULL, NULL)) {
>          vout_Close(vout);
>          vout = NULL;
>      }
> diff --git a/src/input/decoder.c b/src/input/decoder.c
> index 57c9de6a1ee..f2f69a05fd1 100644
> --- a/src/input/decoder.c
> +++ b/src/input/decoder.c
> @@ -122,6 +122,7 @@ struct decoder_owner
>      audio_output_t *p_aout;
> 
>      vout_thread_t   *p_vout;
> +    vlc_decoder_device *p_dec_dev;
> 
>      /* -- Theses variables need locking on read *and* write -- */
>      /* Preroll */
> @@ -560,17 +561,21 @@ static int ModuleThread_UpdateVideoFormat( decoder_t
> *p_dec ) break;
>          }
>          enum vlc_vout_order order;
> -        p_vout = input_resource_GetVout( p_owner->p_resource,
> +        vlc_decoder_device *dec_dev = NULL;
> +        p_vout = input_resource_GetVoutHoldDevice( p_owner->p_resource,
>              &(vout_configuration_t) {
>                  .vout = p_vout, .clock = p_owner->p_clock, .fmt = &fmt,
>                  .dpb_size = dpb_size + p_dec->i_extra_picture_buffers + 1,
>                  .mouse_event = MouseEvent, .mouse_opaque = p_dec
> -            }, &order );
> +            }, &order, &dec_dev );
>          if (p_vout)
>              decoder_Notify(p_owner, on_vout_added, p_vout, order);
> 
>          vlc_mutex_lock( &p_owner->lock );
>          p_owner->p_vout = p_vout;
> +        if ( p_owner->p_dec_dev != NULL )
> +            vlc_decoder_device_Release( p_owner->p_dec_dev );
> +        p_owner->p_dec_dev = dec_dev;
> 
>          DecoderUpdateFormatLocked( p_owner );
>          p_owner->fmt.video.i_chroma = p_dec->fmt_out.i_codec;
> @@ -1906,6 +1911,9 @@ static void DeleteDecoder( decoder_t * p_dec )
>      const enum es_format_category_e i_cat =p_dec->fmt_in.i_cat;
>      decoder_Clean( p_dec );
> 
> +    if ( p_owner->p_dec_dev )
> +        vlc_decoder_device_Release( p_owner->p_dec_dev );
> +
>      /* Free all packets still in the decoder fifo. */
>      block_FifoRelease( p_owner->p_fifo );
> 
> diff --git a/src/input/resource.c b/src/input/resource.c
> index b4ffbd68ce3..39d1a87a464 100644
> --- a/src/input/resource.c
> +++ b/src/input/resource.c
> @@ -368,9 +368,10 @@ void input_resource_PutVout(input_resource_t
> *p_resource, vlc_mutex_unlock( &p_resource->lock );
>  }
> 
> -vout_thread_t *input_resource_GetVout(input_resource_t *p_resource,
> +vout_thread_t *input_resource_GetVoutHoldDevice(input_resource_t
> *p_resource, const vout_configuration_t *cfg, -                            
>          enum vlc_vout_order *order) +                                     
> enum vlc_vout_order *order, +                                     
> vlc_decoder_device **dec_dev) {
>      vout_configuration_t cfg_buf;
>      vout_thread_t *vout;
> @@ -425,7 +426,7 @@ vout_thread_t *input_resource_GetVout(input_resource_t
> *p_resource, }
>  #endif
> 
> -    if (vout_Request(cfg, p_resource->p_input)) {
> +    if (vout_Request(cfg, dec_dev, p_resource->p_input)) {
>          input_resource_PutVoutLocked(p_resource, cfg->vout, false);
>          vlc_mutex_unlock(&p_resource->lock);
>          return NULL;
> diff --git a/src/input/resource.h b/src/input/resource.h
> index a13ca0dc85c..ab456d7ce5d 100644
> --- a/src/input/resource.h
> +++ b/src/input/resource.h
> @@ -37,9 +37,10 @@ void input_resource_SetInput( input_resource_t *,
> input_thread_t * ); */
>  sout_instance_t *input_resource_RequestSout( input_resource_t *,
> sout_instance_t *, const char *psz_sout );
> 
> -vout_thread_t *input_resource_GetVout(input_resource_t *,
> +vout_thread_t *input_resource_GetVoutHoldDevice(input_resource_t *,
>                                        const vout_configuration_t *,
> -                                      enum vlc_vout_order *order);
> +                                      enum vlc_vout_order *order,
> +                                      vlc_decoder_device **);
>  void input_resource_PutVout(input_resource_t *, vout_thread_t *);
> 
>  /**
> diff --git a/src/video_output/video_output.c
> b/src/video_output/video_output.c index cf2132a089c..2a38bd677c4 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -1860,7 +1860,8 @@ vout_thread_t *vout_Hold(vout_thread_t *vout)
>      return vout;
>  }
> 
> -int vout_Request(const vout_configuration_t *cfg, input_thread_t *input)
> +int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device
> **dec_dev, +                 input_thread_t *input)
>  {
>      vout_thread_t *vout = cfg->vout;
>      vout_thread_sys_t *sys = vout->p;
> @@ -1870,6 +1871,10 @@ int vout_Request(const vout_configuration_t *cfg,
> input_thread_t *input) assert(cfg->fmt != NULL);
>      assert(cfg->clock != NULL);
> 
> +    if (dec_dev)
> +        // don't return a decoder device by default, we need a proper
> reference +        *dec_dev = NULL;
> +
>      if (!VoutCheckFormat(cfg->fmt))
>          return -1;
> 
> @@ -1949,6 +1954,13 @@ error:
>          return -1;
>      }
> 
> +    if (dec_dev)
> +    {
> +        vlc_mutex_lock(&sys->window_lock);
> +        *dec_dev = sys->dec_device ? vlc_decoder_device_Hold(
> sys->dec_device ) : NULL;
> +        vlc_mutex_unlock(&sys->window_lock);

Locking seems dubious here. What does it protect against?

> +    }
> +
>      if (input != NULL && sys->spu)
>          spu_Attach(sys->spu, input);
>      vout_IntfReinit(vout);
> diff --git a/src/video_output/vout_internal.h
> b/src/video_output/vout_internal.h index ee24cd9153f..1f88997779c 100644
> --- a/src/video_output/vout_internal.h
> +++ b/src/video_output/vout_internal.h
> @@ -207,11 +207,13 @@ vout_thread_t *vout_CreateDummy(vlc_object_t *obj)
> VLC_USED; * You can release the returned value either by vout_Request() or
> vout_Close(). *
>   * \param cfg the video configuration requested.
> + * \param dec_dev pointer to receive the decoder device reference to use
> with the vout or NULL * \param input used to get attachments for spu
> filters
>   * \retval 0 on success
>   * \retval -1 on error
>   */
> -int vout_Request(const vout_configuration_t *cfg, input_thread_t *input);
> +int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device
> **dec_dev, +                 input_thread_t *input);
> 
>  /**
>   * Disables a vout.


-- 
Rémi Denis-Courmont
http://www.remlab.net/





More information about the vlc-devel mailing list