[vlc-commits] d3d11_fmt: clean the lock usage

Steve Lhomme git at videolan.org
Fri Feb 7 15:58:55 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Feb  5 10:35:29 2020 +0100| [e23ee6127f00862d956975c42202d214b25fe7a8] | committer: Steve Lhomme

d3d11_fmt: clean the lock usage

Make sure the handle value is always set.

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

 modules/video_chroma/d3d11_fmt.c | 8 +++++---
 modules/video_chroma/d3d11_fmt.h | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c
index 4607d51434..d39c2889bc 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -231,7 +231,7 @@ void D3D11_ReleaseDevice(d3d11_device_t *d3d_dev)
         d3d_dev->d3ddevice = NULL;
     }
 #if defined(HAVE_ID3D11VIDEODECODER)
-    if( d3d_dev->owner && d3d_dev->context_mutex != INVALID_HANDLE_VALUE )
+    if( d3d_dev->mutex_owner && d3d_dev->context_mutex != INVALID_HANDLE_VALUE )
     {
         CloseHandle( d3d_dev->context_mutex );
         d3d_dev->context_mutex = INVALID_HANDLE_VALUE;
@@ -273,7 +273,7 @@ HRESULT D3D11_CreateDeviceExternal(vlc_object_t *obj, ID3D11DeviceContext *d3d11
 
     ID3D11DeviceContext_AddRef( d3d11ctx );
     out->d3dcontext = d3d11ctx;
-    out->owner = false;
+    out->mutex_owner = false;
     out->feature_level = ID3D11Device_GetFeatureLevel(out->d3ddevice );
 
     HANDLE context_lock = INVALID_HANDLE_VALUE;
@@ -381,8 +381,10 @@ HRESULT D3D11_CreateDevice(vlc_object_t *obj, d3d11_handle_t *hd3d,
                                             sizeof( out->context_mutex ), &out->context_mutex );
 #endif
 
-        out->owner = true;
+        out->mutex_owner = true;
     }
+    else
+        out->context_mutex = INVALID_HANDLE_VALUE;
 
     return hr;
 }
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index d359b6d425..ada202d1f8 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -47,7 +47,7 @@ typedef struct
 {
     ID3D11Device             *d3ddevice;       /* D3D device */
     ID3D11DeviceContext      *d3dcontext;      /* D3D context */
-    bool                     owner;
+    bool                     mutex_owner;
     HANDLE                   context_mutex;
     struct wddm_version      WDDM;
     D3D_FEATURE_LEVEL        feature_level;



More information about the vlc-commits mailing list