Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/mfplat.spec | 6 ++-- dlls/mfplat/queue.c | 47 +++++++++++++++++++++++++++++ dlls/mfplat/tests/mfplat.c | 62 ++++++++++++++++++++++++++++++++++++-- include/mfapi.h | 2 ++ 4 files changed, 112 insertions(+), 5 deletions(-)
diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec index c4e0b2abfa..39fd7a9d44 100644 --- a/dlls/mfplat/mfplat.spec +++ b/dlls/mfplat/mfplat.spec @@ -28,7 +28,7 @@ @ stub MFCalculateBitmapImageSize @ stub MFCalculateImageSize @ stub MFCancelCreateFile -@ stub MFCancelWorkItem +@ stdcall MFCancelWorkItem(int64) @ stub MFCompareFullToPartialMediaType @ stub MFCompareSockaddrAddresses @ stub MFConvertColorInfoFromDXVA @@ -124,8 +124,8 @@ @ stdcall MFPutWorkItemEx(long ptr) @ stub MFRecordError @ stub MFRemovePeriodicCallback -@ stub MFScheduleWorkItem -@ stub MFScheduleWorkItemEx +@ stdcall MFScheduleWorkItem(ptr ptr int64 ptr) +@ stdcall MFScheduleWorkItemEx(ptr int64 ptr) @ stub MFSerializeAttributesToStream @ stub MFSerializeEvent @ stub MFSerializeMediaTypeToStream diff --git a/dlls/mfplat/queue.c b/dlls/mfplat/queue.c index ebc2ad487b..7c8790b52c 100644 --- a/dlls/mfplat/queue.c +++ b/dlls/mfplat/queue.c @@ -385,3 +385,50 @@ HRESULT WINAPI MFInvokeCallback(IMFAsyncResult *result)
return hr; } + +static HRESULT schedule_work_item(IMFAsyncResult *result, INT64 timeout, MFWORKITEM_KEY *key) +{ + FIXME("%p, %s, %p.\n", result, wine_dbgstr_longlong(timeout), key); + + return E_NOTIMPL; +} + +/*********************************************************************** + * MFScheduleWorkItemEx (mfplat.@) + */ +HRESULT WINAPI MFScheduleWorkItemEx(IMFAsyncResult *result, INT64 timeout, MFWORKITEM_KEY *key) +{ + TRACE("%p, %s, %p.\n", result, wine_dbgstr_longlong(timeout), key); + + return schedule_work_item(result, timeout, key); +} + +/*********************************************************************** + * MFScheduleWorkItemEx (mfplat.@) + */ +HRESULT WINAPI MFScheduleWorkItem(IMFAsyncCallback *callback, IUnknown *state, INT64 timeout, MFWORKITEM_KEY *key) +{ + IMFAsyncResult *result; + HRESULT hr; + + TRACE("%p, %p, %s, %p.\n", callback, state, wine_dbgstr_longlong(timeout), key); + + if (FAILED(hr = MFCreateAsyncResult(NULL, callback, state, &result))) + return hr; + + hr = schedule_work_item(result, timeout, key); + + IMFAsyncResult_Release(result); + + return hr; +} + +/*********************************************************************** + * MFCancelWorkItem (mfplat.@) + */ +HRESULT WINAPI MFCancelWorkItem(MFWORKITEM_KEY key) +{ + FIXME("%s.\n", wine_dbgstr_longlong(key)); + + return E_NOTIMPL; +} diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 609faa5d00..cc8a0f47b8 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -43,6 +43,7 @@ static HRESULT (WINAPI *pMFCreateMFByteStreamOnStream)(IStream *stream, IMFByteS static HRESULT (WINAPI *pMFCreateMemoryBuffer)(DWORD max_length, IMFMediaBuffer **buffer); static void* (WINAPI *pMFHeapAlloc)(SIZE_T size, ULONG flags, char *file, int line, EAllocationType type); static void (WINAPI *pMFHeapFree)(void *p); +static HRESULT (WINAPI *pMFPutWaitingWorkItem)(HANDLE event, LONG priority, IMFAsyncResult *result, MFWORKITEM_KEY *key);
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
@@ -318,6 +319,7 @@ static void init_functions(void) X(MFCreateMemoryBuffer); X(MFHeapAlloc); X(MFHeapFree); + X(MFPutWaitingWorkItem); #undef X }
@@ -718,13 +720,13 @@ static ULONG WINAPI testcallback_Release(IMFAsyncCallback *iface)
static HRESULT WINAPI testcallback_GetParameters(IMFAsyncCallback *iface, DWORD *flags, DWORD *queue) { - ok(0, "Unexpected call.\n"); + ok(flags != NULL && queue != NULL, "Unexpected arguments.\n"); return E_NOTIMPL; }
static HRESULT WINAPI testcallback_Invoke(IMFAsyncCallback *iface, IMFAsyncResult *result) { - ok(0, "Unexpected call.\n"); + ok(result != NULL, "Unexpected result object.\n"); return E_NOTIMPL; }
@@ -1035,6 +1037,61 @@ static void test_MFHeapAlloc(void) pMFHeapFree(res); }
+static void test_scheduled_items(void) +{ + IMFAsyncCallback callback = { &testcallbackvtbl }; + IMFAsyncResult *result; + MFWORKITEM_KEY key, key2; + HRESULT hr; + + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(hr == S_OK, "Failed to start up, hr %#x.\n", hr); + + hr = MFScheduleWorkItem(&callback, NULL, -5000, &key); +todo_wine + ok(hr == S_OK, "Failed to schedule item, hr %#x.\n", hr); + + hr = MFCancelWorkItem(key); +todo_wine + ok(hr == S_OK, "Failed to cancel item, hr %#x.\n", hr); + + hr = MFCancelWorkItem(key); +todo_wine + ok(hr == MF_E_NOT_FOUND || broken(hr == S_OK) /* < win10 */, "Unexpected hr %#x.\n", hr); + + if (!pMFPutWaitingWorkItem) + { + skip("Waiting items are not supported.\n"); + return; + } + + hr = MFCreateAsyncResult(NULL, &callback, NULL, &result); + ok(hr == S_OK, "Failed to create result, hr %#x.\n", hr); + + hr = pMFPutWaitingWorkItem(NULL, 0, result, &key); + ok(hr == S_OK, "Failed to add waiting item, hr %#x.\n", hr); + + hr = pMFPutWaitingWorkItem(NULL, 0, result, &key2); + ok(hr == S_OK, "Failed to add waiting item, hr %#x.\n", hr); + + hr = MFCancelWorkItem(key); + ok(hr == S_OK, "Failed to cancel item, hr %#x.\n", hr); + + hr = MFCancelWorkItem(key2); + ok(hr == S_OK, "Failed to cancel item, hr %#x.\n", hr); + + IMFAsyncResult_Release(result); + + hr = MFScheduleWorkItem(&callback, NULL, -5000, &key); + ok(hr == S_OK, "Failed to schedule item, hr %#x.\n", hr); + + hr = MFCancelWorkItem(key); + ok(hr == S_OK, "Failed to cancel item, hr %#x.\n", hr); + + hr = MFShutdown(); + ok(hr == S_OK, "Failed to shutdown, hr %#x.\n", hr); +} + START_TEST(mfplat) { CoInitialize(NULL); @@ -1056,6 +1113,7 @@ START_TEST(mfplat) test_MFCopyImage(); test_MFCreateCollection(); test_MFHeapAlloc(); + test_scheduled_items();
CoUninitialize(); } diff --git a/include/mfapi.h b/include/mfapi.h index 7c47213d85..4b7d758488 100644 --- a/include/mfapi.h +++ b/include/mfapi.h @@ -115,6 +115,8 @@ HRESULT WINAPI MFInvokeCallback(IMFAsyncResult *result); HRESULT WINAPI MFLockPlatform(void); HRESULT WINAPI MFPutWorkItem(DWORD queue, IMFAsyncCallback *callback, IUnknown *state); HRESULT WINAPI MFPutWorkItemEx(DWORD queue, IMFAsyncResult *result); +HRESULT WINAPI MFScheduleWorkItem(IMFAsyncCallback *callback, IUnknown *state, INT64 timeout, MFWORKITEM_KEY *key); +HRESULT WINAPI MFScheduleWorkItemEx(IMFAsyncResult *result, INT64 timeout, MFWORKITEM_KEY *key); HRESULT WINAPI MFTRegister(CLSID clsid, GUID category, LPWSTR name, UINT32 flags, UINT32 cinput, MFT_REGISTER_TYPE_INFO *input_types, UINT32 coutput, MFT_REGISTER_TYPE_INFO *output_types, IMFAttributes *attributes);