[vlc-devel] [PATCH 27/36] vdpau: chroma: create the filter output video context

Steve Lhomme robux4 at ycbcr.xyz
Thu Nov 21 15:14:18 CET 2019


---
 modules/hw/vdpau/chroma.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/modules/hw/vdpau/chroma.c b/modules/hw/vdpau/chroma.c
index ff816870d3f..d633e1d2568 100644
--- a/modules/hw/vdpau/chroma.c
+++ b/modules/hw/vdpau/chroma.c
@@ -758,6 +758,21 @@ static picture_pool_t *OutputPoolAlloc(vlc_object_t *obj, vdp_t *vdp,
     return vlc_vdp_output_pool_create(vdp, rgb_fmt, fmt, 3);
 }
 
+struct video_context_private
+{
+    vdp_t *vdp;
+};
+
+static void DestroyVDPAUVideoContext(void *private)
+{
+    struct video_context_private *vctx_priv = private;
+    vdp_release_x11(vctx_priv->vdp);
+}
+
+const struct vlc_video_context_operations vdpau_vctx_ops = {
+    DestroyVDPAUVideoContext,
+};
+
 static int OutputOpen(vlc_object_t *obj)
 {
     filter_t *filter = (filter_t *)obj;
@@ -818,7 +833,12 @@ static int OutputOpen(vlc_object_t *obj)
 
     sys->vdp = GetVDPAUOpaqueDevice(dec_device);
 
+    filter->vctx_out = vlc_video_context_Create(dec_device, VLC_VIDEO_CONTEXT_VDPAU,
+                                             sizeof(struct video_context_private),
+                                             &vdpau_vctx_ops);
     vlc_decoder_device_Release(dec_device);
+    if (unlikely(filter->vctx_out == NULL))
+        return VLC_EGENERIC;
 
     vdp_hold_x11(sys->vdp, &sys->device);
 
@@ -827,7 +847,8 @@ static int OutputOpen(vlc_object_t *obj)
                                 &filter->fmt_out.video);
     if (sys->pool == NULL)
     {
-        vdp_release_x11(sys->vdp);
+        vlc_video_context_Release(filter->vctx_out);
+        filter->vctx_out = NULL;
         return VLC_EGENERIC;
     }
 
@@ -836,7 +857,8 @@ static int OutputOpen(vlc_object_t *obj)
     if (sys->mixer == VDP_INVALID_HANDLE)
     {
         picture_pool_Release(sys->pool);
-        vdp_release_x11(sys->vdp);
+        vlc_video_context_Release(filter->vctx_out);
+        filter->vctx_out = NULL;
         return VLC_EGENERIC;
     }
 
@@ -861,7 +883,7 @@ static void OutputClose(vlc_object_t *obj)
     Flush(filter);
     vdp_video_mixer_destroy(sys->vdp, sys->mixer);
     picture_pool_Release(sys->pool);
-    vdp_release_x11(sys->vdp);
+    vlc_video_context_Release(filter->vctx_out);
 }
 
 typedef struct
-- 
2.17.1



More information about the vlc-devel mailing list