Nikolay Sivov : mfplat: Fail to create user queues on uninitialized platform.

Alexandre Julliard julliard at winehq.org
Fri Mar 1 16:42:10 CST 2019


Module: wine
Branch: master
Commit: 5e1b3b2f5aaf17d90fad39864dec1caa077d5bfe
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=5e1b3b2f5aaf17d90fad39864dec1caa077d5bfe

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri Mar  1 11:03:15 2019 +0300

mfplat: Fail to create user queues on uninitialized platform.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mfplat/main.c           |  5 +++++
 dlls/mfplat/mfplat_private.h |  1 +
 dlls/mfplat/queue.c          |  3 +++
 dlls/mfplat/tests/mfplat.c   | 53 +++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index 2d82589..a8963ca 100644
--- a/dlls/mfplat/main.c
+++ b/dlls/mfplat/main.c
@@ -521,6 +521,11 @@ HRESULT WINAPI MFUnlockPlatform(void)
     return S_OK;
 }
 
+BOOL is_platform_locked(void)
+{
+    return platform_lock > 0;
+}
+
 /***********************************************************************
  *      MFCopyImage (mfplat.@)
  */
diff --git a/dlls/mfplat/mfplat_private.h b/dlls/mfplat/mfplat_private.h
index 2d9e7d5..ac35ff2 100644
--- a/dlls/mfplat/mfplat_private.h
+++ b/dlls/mfplat/mfplat_private.h
@@ -18,3 +18,4 @@
 
 extern void init_system_queues(void) DECLSPEC_HIDDEN;
 extern void shutdown_system_queues(void) DECLSPEC_HIDDEN;
+extern BOOL is_platform_locked(void) DECLSPEC_HIDDEN;
diff --git a/dlls/mfplat/queue.c b/dlls/mfplat/queue.c
index 23e54a5..f470cb4 100644
--- a/dlls/mfplat/queue.c
+++ b/dlls/mfplat/queue.c
@@ -543,6 +543,9 @@ static HRESULT alloc_user_queue(MFASYNC_WORKQUEUE_TYPE queue_type, DWORD *queue_
 
     *queue_id = MFASYNC_CALLBACK_QUEUE_UNDEFINED;
 
+    if (!is_platform_locked())
+        return MF_E_SHUTDOWN;
+
     queue = heap_alloc_zero(sizeof(*queue));
     if (!queue)
         return E_OUTOFMEMORY;
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index fa77929..2a2189b 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -837,6 +837,7 @@ static void test_MFCreateAsyncResult(void)
 
 static void test_startup(void)
 {
+    DWORD queue;
     HRESULT hr;
 
     hr = MFStartup(MAKELONG(MF_API_VERSION, 0xdead), MFSTARTUP_FULL);
@@ -845,8 +846,58 @@ static void test_startup(void)
     hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
     ok(hr == S_OK, "Failed to start up, hr %#x.\n", hr);
 
+    hr = MFAllocateWorkQueue(&queue);
+    ok(hr == S_OK, "Failed to allocate a queue, hr %#x.\n", hr);
+    hr = MFUnlockWorkQueue(queue);
+    ok(hr == S_OK, "Failed to unlock the queue, hr %#x.\n", hr);
+
     hr = MFShutdown();
-    ok(hr == S_OK, "Failed to shutdown, hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
+
+    hr = MFAllocateWorkQueue(&queue);
+    ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
+
+    /* Already shut down, has no effect. */
+    hr = MFShutdown();
+    ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
+
+    hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
+    ok(hr == S_OK, "Failed to start up, hr %#x.\n", hr);
+
+    hr = MFAllocateWorkQueue(&queue);
+    ok(hr == S_OK, "Failed to allocate a queue, hr %#x.\n", hr);
+    hr = MFUnlockWorkQueue(queue);
+    ok(hr == S_OK, "Failed to unlock the queue, hr %#x.\n", hr);
+
+    hr = MFShutdown();
+    ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
+
+    /* Platform lock. */
+    hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
+    ok(hr == S_OK, "Failed to start up, hr %#x.\n", hr);
+
+    hr = MFAllocateWorkQueue(&queue);
+    ok(hr == S_OK, "Failed to allocate a queue, hr %#x.\n", hr);
+    hr = MFUnlockWorkQueue(queue);
+    ok(hr == S_OK, "Failed to unlock the queue, hr %#x.\n", hr);
+
+    /* Unlocking implies shutdown. */
+    hr = MFUnlockPlatform();
+    ok(hr == S_OK, "Failed to unlock, %#x.\n", hr);
+
+    hr = MFAllocateWorkQueue(&queue);
+    ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
+
+    hr = MFLockPlatform();
+    ok(hr == S_OK, "Failed to lock, %#x.\n", hr);
+
+    hr = MFAllocateWorkQueue(&queue);
+    ok(hr == S_OK, "Failed to allocate a queue, hr %#x.\n", hr);
+    hr = MFUnlockWorkQueue(queue);
+    ok(hr == S_OK, "Failed to unlock the queue, hr %#x.\n", hr);
+
+    hr = MFShutdown();
+    ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
 }
 
 static void test_allocate_queue(void)




More information about the wine-cvs mailing list