[vlc-devel] [PATCH 01/12] decoder: use an object to create the decoder device

Rémi Denis-Courmont remi at remlab.net
Mon Dec 2 18:37:26 CET 2019


Le maanantaina 2. joulukuuta 2019, 15.26.08 EET Steve Lhomme a écrit :
> Allowing the window to be NULL, which is OK for D3D11/D3D9/NVDEC.
> ---
>  include/vlc_codec.h             | 6 ++++--
>  src/input/decoder_helpers.c     | 7 ++++---
>  src/video_output/video_output.c | 2 +-
>  3 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/include/vlc_codec.h b/include/vlc_codec.h
> index 6649ef94cc2..c0394522aae 100644
> --- a/include/vlc_codec.h
> +++ b/include/vlc_codec.h
> @@ -604,8 +604,10 @@ typedef int
> (*vlc_decoder_device_Open)(vlc_decoder_device *device, * This function will
> be hidden in the future. It is now used by opengl vout * module as a
> transition.
>   */
> -VLC_USED vlc_decoder_device *
> -vlc_decoder_device_Create(vout_window_t *window);
> +vlc_decoder_device *
> +vlc_decoder_device_Create(vlc_object_t *, vout_window_t *window) VLC_USED;
> +#define vlc_decoder_device_Create(a, b) \
> +        vlc_decoder_device_Create(VLC_OBJECT(a), (b))
> 
>  /**
>   * Hold a decoder device
> diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
> index da64af09dbd..ca92f4f9c4e 100644
> --- a/src/input/decoder_helpers.c
> +++ b/src/input/decoder_helpers.c
> @@ -181,14 +181,15 @@ static int decoder_device_Open(void *func, bool
> forced, va_list ap) return open(device, window);
>  }
> 
> +#undef vlc_decoder_device_Create

Better remove that and put vlc_decoder_device_Create inside parenthesises - it 
won't cause problem if code below calls vlc_decoder_device_Create().

But really, better not rely on the questionable VLC_OBJECT() macro in new 
code.

>  vlc_decoder_device *
> -vlc_decoder_device_Create(vout_window_t *window)
> +vlc_decoder_device_Create(vlc_object_t *o, vout_window_t *window)
>  {
>      struct vlc_decoder_device_priv *priv =
> -            vlc_object_create(window, sizeof (*priv));
> +            vlc_object_create(o, sizeof (*priv));
>      if (!priv)
>          return NULL;
> -    char *name = var_InheritString(window, "dec-dev");
> +    char *name = var_InheritString(o, "dec-dev");
>      module_t *module = vlc_module_load(&priv->device, "decoder device",
> name, true, decoder_device_Open, &priv->device, window);
> diff --git a/src/video_output/video_output.c
> b/src/video_output/video_output.c index ee7e54072a2..1aa936b748c 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -2031,7 +2031,7 @@ static int vout_EnableWindow(vout_thread_t *vout,
> const video_format_t *original if (pp_dec_device)
>      {
>          if (sys->dec_device == NULL)
> -            sys->dec_device =
> vlc_decoder_device_Create(sys->display_cfg.window); +           
> sys->dec_device = vlc_decoder_device_Create(vout, sys->display_cfg.window);
> *pp_dec_device = sys->dec_device ? vlc_decoder_device_Hold( sys->dec_device
> ) : NULL; }
>      vlc_mutex_unlock(&sys->window_lock);


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





More information about the vlc-devel mailing list