[vlc-devel] [PATCH 06/36] vdpau: chroma: get the decoder device using filter_HoldDecoderDevice()

Steve Lhomme robux4 at ycbcr.xyz
Thu Nov 21 15:13:57 CET 2019


Use vdp_get_x11() to get the VdpDevice since we already have the vdp from the
decoder device.
---
 modules/hw/vdpau/chroma.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/modules/hw/vdpau/chroma.c b/modules/hw/vdpau/chroma.c
index e2791eced4d..51a958ccc2d 100644
--- a/modules/hw/vdpau/chroma.c
+++ b/modules/hw/vdpau/chroma.c
@@ -768,9 +768,21 @@ static int OutputOpen(vlc_object_t *obj)
     assert(filter->fmt_out.video.orientation == ORIENT_TOP_LEFT
         || filter->fmt_in.video.orientation == filter->fmt_out.video.orientation);
 
+    vlc_decoder_device *dec_device = filter_HoldDecoderDevice(filter);
+    if (dec_device == NULL)
+        return VLC_EGENERIC;
+    if (dec_device->type != VLC_DECODER_DEVICE_VDPAU)
+    {
+        vlc_decoder_device_Release(dec_device);
+        return VLC_EGENERIC;
+    }
+
     vlc_vdp_mixer_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
     if (unlikely(sys == NULL))
+    {
+        vlc_decoder_device_Release(dec_device);
         return VLC_ENOMEM;
+    }
 
     filter->p_sys = sys;
 
@@ -799,11 +811,16 @@ static int OutputOpen(vlc_object_t *obj)
                               &sys->chroma, &sys->format))
         video_filter = YCbCrRender;
     else
+    {
+        vlc_decoder_device_Release(dec_device);
         return VLC_EGENERIC;
+    }
 
-    VdpStatus err = vdp_get_x11(NULL, -1, &sys->vdp, &sys->device);
-    if (err != VDP_STATUS_OK)
-        return VLC_EGENERIC;
+    sys->vdp = GetVDPAUOpaqueDevice(dec_device);
+
+    vlc_decoder_device_Release(dec_device);
+
+    vdp_hold_x11(sys->vdp, &sys->device);
 
     /* Allocate the output surface picture pool */
     sys->pool = OutputPoolAlloc(obj, sys->vdp, sys->device,
-- 
2.17.1



More information about the vlc-devel mailing list