[vlc-commits] va: move close callback to vlc_va_t

Rémi Denis-Courmont git at videolan.org
Wed Jul 17 21:05:37 CEST 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jul 17 22:03:20 2019 +0300| [a78f59b9d8bb1890cdcaf7f2fe4bf8c12fd94671] | committer: Rémi Denis-Courmont

va: move close callback to vlc_va_t

This is simpler and type-safer.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a78f59b9d8bb1890cdcaf7f2fe4bf8c12fd94671
---

 modules/codec/avcodec/d3d11va.c |  6 +++---
 modules/codec/avcodec/dxva2.c   |  6 +++---
 modules/codec/avcodec/va.c      | 14 ++------------
 modules/codec/avcodec/va.h      |  3 ++-
 modules/codec/avcodec/vaapi.c   |  3 ++-
 modules/hw/vdpau/avcodec.c      |  3 ++-
 6 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 91df7bc397..9ceea6c32d 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -60,14 +60,13 @@ typedef picture_sys_d3d11_t VA_PICSYS;
 
 static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
                 const es_format_t *, picture_sys_d3d11_t *p_sys);
-static void Close(vlc_va_t *, void **);
 
 vlc_module_begin()
     set_description(N_("Direct3D11 Video Acceleration"))
     set_capability("hw decoder", 110)
     set_category(CAT_INPUT)
     set_subcategory(SUBCAT_INPUT_VCODEC)
-    set_callbacks(Open, Close)
+    set_callbacks(Open, NULL)
 vlc_module_end()
 
 /*
@@ -410,7 +409,8 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
 
     ctx->hwaccel_context = &sys->hw;
 
-    va->get     = Get;
+    va->get = Get;
+    va->close = Close;
 
     return VLC_SUCCESS;
 
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 9796823945..7c521d4575 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -47,14 +47,13 @@ typedef picture_sys_d3d9_t VA_PICSYS;
 
 static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
                 const es_format_t *, picture_sys_d3d9_t *p_sys);
-static void Close(vlc_va_t *, void **);
 
 vlc_module_begin()
     set_description(N_("DirectX Video Acceleration (DXVA) 2.0"))
     set_capability("hw decoder", 100)
     set_category(CAT_INPUT)
     set_subcategory(SUBCAT_INPUT_VCODEC)
-    set_callbacks(Open, Close)
+    set_callbacks(Open, NULL)
 vlc_module_end()
 
 #include <initguid.h> /* must be last included to not redefine existing GUIDs */
@@ -338,7 +337,8 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
 
     ctx->hwaccel_context = &sys->hw;
 
-    va->get     = Get;
+    va->get = Get;
+    va->close = Close;
     return VLC_SUCCESS;
 
 error:
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index fe9884c714..3843782b03 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -102,15 +102,6 @@ static int vlc_va_Start(void *func, bool forced, va_list ap)
     return open(va, ctx, pix_fmt, fmt, p_sys);
 }
 
-static void vlc_va_Stop(void *func, va_list ap)
-{
-    vlc_va_t *va = va_arg(ap, vlc_va_t *);
-    void *hwctx = va_arg(ap, void *);
-    void (*close)(vlc_va_t *, void *) = func;
-
-    close(va, hwctx);
-}
-
 struct vlc_va_priv {
     struct vlc_va_t va;
     module_t *module;
@@ -140,8 +131,7 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
 
 void vlc_va_Delete(vlc_va_t *va, void **hwctx)
 {
-    struct vlc_va_priv *priv = container_of(va, struct vlc_va_priv, va);
-
-    vlc_module_unload(priv->module, vlc_va_Stop, va, hwctx);
+    if (va->close != NULL)
+        va->close(va, hwctx);
     vlc_object_delete(va);
 }
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index 97df858389..5ef2df1307 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -32,7 +32,8 @@ struct vlc_va_t {
     struct vlc_object_t obj;
 
     vlc_va_sys_t *sys;
-    int  (*get)(vlc_va_t *, picture_t *pic, uint8_t **surface);
+    int (*get)(vlc_va_t *, picture_t *pic, uint8_t **surface);
+    void (*close)(vlc_va_t *, void **hwctx);
 };
 
 /**
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index 54e8f16cb2..1761837f71 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -202,6 +202,7 @@ static int Create(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
     ctx->hwaccel_context = &sys->hw_ctx;
     va->sys = sys;
     va->get = Get;
+    va->close = Delete;
     return VLC_SUCCESS;
 
 error:
@@ -217,7 +218,7 @@ error:
 vlc_module_begin ()
     set_description( N_("VA-API video decoder") )
     set_capability( "hw decoder", 100 )
-    set_callbacks( Create, Delete )
+    set_callbacks( Create, NULL )
     add_shortcut( "vaapi" )
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_VCODEC )
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index 8186a70906..6604625215 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -216,6 +216,7 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat pix_fmt,
         msg_Info(va, "Using %s", infos);
 
     va->get = Lock;
+    va->close = Close;
     return VLC_SUCCESS;
 
 error:
@@ -229,6 +230,6 @@ vlc_module_begin()
     set_capability("hw decoder", 100)
     set_category(CAT_INPUT)
     set_subcategory(SUBCAT_INPUT_VCODEC)
-    set_callbacks(Open, Close)
+    set_callbacks(Open, NULL)
     add_shortcut("vdpau")
 vlc_module_end()



More information about the vlc-commits mailing list