[vlc-commits] hw:d3d11: move the code to get the D3D11DeviceContext mutex in D3D11_FilterHoldInstance

Steve Lhomme git at videolan.org
Mon May 28 13:24:51 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Thu Nov 30 11:28:07 2017 +0100| [031536832f4356e3cae4e3769aee4ebb57bccbce] | committer: Steve Lhomme

hw:d3d11: move the code to get the D3D11DeviceContext mutex in D3D11_FilterHoldInstance

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

 modules/hw/d3d11/d3d11_deinterlace.c |  7 -------
 modules/hw/d3d11/d3d11_filters.c     |  7 -------
 modules/hw/d3d11/d3d11_instance.c    | 16 ++++++++++++++--
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/modules/hw/d3d11/d3d11_deinterlace.c b/modules/hw/d3d11/d3d11_deinterlace.c
index e385f8213c..2a4e6a60e4 100644
--- a/modules/hw/d3d11/d3d11_deinterlace.c
+++ b/modules/hw/d3d11/d3d11_deinterlace.c
@@ -382,13 +382,6 @@ int D3D11OpenDeinterlace(vlc_object_t *obj)
        goto error;
     }
 
-    HANDLE context_lock = INVALID_HANDLE_VALUE;
-    UINT dataSize = sizeof(context_lock);
-    hr = ID3D11Device_GetPrivateData(sys->d3d_dev.d3ddevice, &GUID_CONTEXT_MUTEX, &dataSize, &context_lock);
-    if (FAILED(hr))
-        msg_Warn(filter, "No mutex found to lock the decoder");
-    sys->d3d_dev.context_mutex = context_lock;
-
     const video_format_t *fmt = &filter->fmt_out.video;
 
     D3D11_VIDEO_PROCESSOR_CONTENT_DESC processorDesc = {
diff --git a/modules/hw/d3d11/d3d11_filters.c b/modules/hw/d3d11/d3d11_filters.c
index 369a624520..cba82af128 100644
--- a/modules/hw/d3d11/d3d11_filters.c
+++ b/modules/hw/d3d11/d3d11_filters.c
@@ -379,13 +379,6 @@ static int D3D11OpenAdjust(vlc_object_t *obj)
        goto error;
     }
 
-    HANDLE context_lock = INVALID_HANDLE_VALUE;
-    UINT dataSize = sizeof(context_lock);
-    hr = ID3D11Device_GetPrivateData(sys->d3d_dev.d3ddevice, &GUID_CONTEXT_MUTEX, &dataSize, &context_lock);
-    if (FAILED(hr))
-        msg_Warn(filter, "No mutex found to lock the decoder");
-    sys->d3d_dev.context_mutex = context_lock;
-
     const video_format_t *fmt = &filter->fmt_out.video;
 
     D3D11_VIDEO_PROCESSOR_CONTENT_DESC processorDesc = {
diff --git a/modules/hw/d3d11/d3d11_instance.c b/modules/hw/d3d11/d3d11_instance.c
index d9a2ebfb0d..e9aa7ce314 100644
--- a/modules/hw/d3d11/d3d11_instance.c
+++ b/modules/hw/d3d11/d3d11_instance.c
@@ -35,12 +35,12 @@
 #include "d3d11_filters.h"
 
 static vlc_mutex_t inst_lock = VLC_STATIC_MUTEX;
-static d3d11_device_t device = { .d3dcontext = NULL };
+static d3d11_device_t device = { .context_mutex = INVALID_HANDLE_VALUE };
 static size_t instances = 0;
 
 void D3D11_FilterHoldInstance(filter_t *filter, d3d11_device_t *out, D3D11_TEXTURE2D_DESC *dstDesc)
 {
-    out->d3dcontext = NULL;
+    *out = (d3d11_device_t) { .context_mutex = INVALID_HANDLE_VALUE };
     picture_t *pic = filter_NewPicture(filter);
     if (!pic)
         return;
@@ -52,12 +52,24 @@ void D3D11_FilterHoldInstance(filter_t *filter, d3d11_device_t *out, D3D11_TEXTU
     {
         out->d3dcontext = p_sys->context;
         ID3D11DeviceContext_GetDevice(out->d3dcontext, &out->d3ddevice);
+
+        UINT dataSize = sizeof(out->context_mutex);
+        HRESULT hr = ID3D11Device_GetPrivateData(out->d3ddevice, &GUID_CONTEXT_MUTEX,
+                                                 &dataSize, &out->context_mutex);
+        if (FAILED(hr) || dataSize != sizeof(out->context_mutex))
+        {
+            msg_Warn(filter, "No mutex found to lock the decoder");
+            out->context_mutex = INVALID_HANDLE_VALUE;
+        }
+
         ID3D11Device_Release(out->d3ddevice);
         if (device.d3dcontext == NULL)
         {
             device = *out;
             instances++;
         }
+        if (device.context_mutex == INVALID_HANDLE_VALUE)
+            device.context_mutex = out->context_mutex;
 
         ID3D11Texture2D_GetDesc(p_sys->texture[KNOWN_DXGI_INDEX], dstDesc);
     }



More information about the vlc-commits mailing list