Commit 5e1b3b2f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplat: Fail to create user queues on uninitialized platform.

parent 48b713ef
...@@ -521,6 +521,11 @@ HRESULT WINAPI MFUnlockPlatform(void) ...@@ -521,6 +521,11 @@ HRESULT WINAPI MFUnlockPlatform(void)
return S_OK; return S_OK;
} }
BOOL is_platform_locked(void)
{
return platform_lock > 0;
}
/*********************************************************************** /***********************************************************************
* MFCopyImage (mfplat.@) * MFCopyImage (mfplat.@)
*/ */
......
...@@ -18,3 +18,4 @@ ...@@ -18,3 +18,4 @@
extern void init_system_queues(void) DECLSPEC_HIDDEN; extern void init_system_queues(void) DECLSPEC_HIDDEN;
extern void shutdown_system_queues(void) DECLSPEC_HIDDEN; extern void shutdown_system_queues(void) DECLSPEC_HIDDEN;
extern BOOL is_platform_locked(void) DECLSPEC_HIDDEN;
...@@ -543,6 +543,9 @@ static HRESULT alloc_user_queue(MFASYNC_WORKQUEUE_TYPE queue_type, DWORD *queue_ ...@@ -543,6 +543,9 @@ static HRESULT alloc_user_queue(MFASYNC_WORKQUEUE_TYPE queue_type, DWORD *queue_
*queue_id = MFASYNC_CALLBACK_QUEUE_UNDEFINED; *queue_id = MFASYNC_CALLBACK_QUEUE_UNDEFINED;
if (!is_platform_locked())
return MF_E_SHUTDOWN;
queue = heap_alloc_zero(sizeof(*queue)); queue = heap_alloc_zero(sizeof(*queue));
if (!queue) if (!queue)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -837,6 +837,7 @@ static void test_MFCreateAsyncResult(void) ...@@ -837,6 +837,7 @@ static void test_MFCreateAsyncResult(void)
static void test_startup(void) static void test_startup(void)
{ {
DWORD queue;
HRESULT hr; HRESULT hr;
hr = MFStartup(MAKELONG(MF_API_VERSION, 0xdead), MFSTARTUP_FULL); hr = MFStartup(MAKELONG(MF_API_VERSION, 0xdead), MFSTARTUP_FULL);
...@@ -845,8 +846,58 @@ static void test_startup(void) ...@@ -845,8 +846,58 @@ static void test_startup(void)
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
ok(hr == S_OK, "Failed to start up, hr %#x.\n", hr); 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(); 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) static void test_allocate_queue(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment