[vlc-devel] [PATCH 4/8] d3d11_fmt: use a context_mutex with external devices for hardware decoding

Steve Lhomme robux4 at ycbcr.xyz
Wed Mar 31 06:25:24 UTC 2021


If the owner doesn't set the GUID_CONTEXT_MUTEX we should still have a mutex
when we want to use the device with a hardware decoder.

The owner of the ID3D11DeviceContext doesn't need to set the mutex if it
doesn't it outside of the callbacks called by libvlc.
---
 modules/video_chroma/d3d11_fmt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c
index 988cf98fd75..affc0312463 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -366,6 +366,13 @@ static HRESULT D3D11_CreateDeviceExternal(vlc_object_t *obj, ID3D11DeviceContext
     hr = ID3D11DeviceContext_GetPrivateData(d3d11ctx, &GUID_CONTEXT_MUTEX, &dataSize, &context_lock);
     if (SUCCEEDED(hr))
         out->context_mutex = context_lock;
+    else if (hw_decoding)
+    {
+        out->mutex_owner = true;
+        out->context_mutex = CreateMutexEx( NULL, NULL, 0, SYNCHRONIZE );
+        ID3D11DeviceContext_SetPrivateData( out->d3dcontext, &GUID_CONTEXT_MUTEX,
+                                            sizeof( out->context_mutex ), &out->context_mutex );
+    }
     else
         out->context_mutex = INVALID_HANDLE_VALUE;
 
-- 
2.29.2



More information about the vlc-devel mailing list