[v2 PATCH 2/4] mfplat: Hold platform lock for async results lifetime.

Nikolay Sivov nsivov at codeweavers.com
Tue Feb 19 07:20:04 CST 2019


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/mfplat/main.c      | 23 +++++++++++++++++++++++
 dlls/mfplat/mfplat.spec |  4 ++--
 dlls/mfplat/queue.c     |  4 ++++
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index 7e1736cc16..94d5ab0f48 100644
--- a/dlls/mfplat/main.c
+++ b/dlls/mfplat/main.c
@@ -38,6 +38,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
 
+static LONG platform_lock;
+
 static const WCHAR transform_keyW[] = {'M','e','d','i','a','F','o','u','n','d','a','t','i','o','n','\\',
                                  'T','r','a','n','s','f','o','r','m','s',0};
 static const WCHAR categories_keyW[] = {'M','e','d','i','a','F','o','u','n','d','a','t','i','o','n','\\',
@@ -450,6 +452,27 @@ HRESULT WINAPI MFStartup(ULONG version, DWORD flags)
 HRESULT WINAPI MFShutdown(void)
 {
     FIXME("(): stub\n");
+
+    return S_OK;
+}
+
+/***********************************************************************
+ *      MFLockPlatform (mfplat.@)
+ */
+HRESULT WINAPI MFLockPlatform(void)
+{
+    InterlockedIncrement(&platform_lock);
+
+    return S_OK;
+}
+
+/***********************************************************************
+ *      MFUnlockPlatform (mfplat.@)
+ */
+HRESULT WINAPI MFUnlockPlatform(void)
+{
+    InterlockedDecrement(&platform_lock);
+
     return S_OK;
 }
 
diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec
index b4e6c77aae..9813789fa6 100644
--- a/dlls/mfplat/mfplat.spec
+++ b/dlls/mfplat/mfplat.spec
@@ -118,7 +118,7 @@
 @ stub MFInitVideoFormat_RGB
 @ stub MFInvokeCallback
 @ stub MFJoinIoPort
-@ stub MFLockPlatform
+@ stdcall MFLockPlatform()
 @ stub MFLockWorkQueue
 @ stub MFPutWorkItem
 @ stub MFPutWorkItemEx
@@ -146,7 +146,7 @@
 @ stub MFTraceError
 @ stub MFTraceFuncEnter
 @ stub MFUnblockThread
-@ stub MFUnlockPlatform
+@ stdcall MFUnlockPlatform()
 @ stub MFUnlockWorkQueue
 @ stub MFUnwrapMediaType
 @ stub MFValidateMediaTypeSize
diff --git a/dlls/mfplat/queue.c b/dlls/mfplat/queue.c
index 762af248f0..32c7a6c31e 100644
--- a/dlls/mfplat/queue.c
+++ b/dlls/mfplat/queue.c
@@ -83,6 +83,8 @@ static ULONG WINAPI async_result_Release(IMFAsyncResult *iface)
         if (result->state)
             IUnknown_Release(result->state);
         heap_free(result);
+
+        MFUnlockPlatform();
     }
 
     return refcount;
@@ -172,6 +174,8 @@ HRESULT WINAPI MFCreateAsyncResult(IUnknown *object, IMFAsyncCallback *callback,
     if (!result)
         return E_OUTOFMEMORY;
 
+    MFLockPlatform();
+
     result->result.AsyncResult.lpVtbl = &async_result_vtbl;
     result->refcount = 1;
     result->object = object;
-- 
2.20.1




More information about the wine-devel mailing list