Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/main.c | 18 ++++++++++++++ dlls/mf/mf.spec | 2 +- dlls/mf/tests/mf.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ include/mfidl.idl | 17 +++++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-)
diff --git a/dlls/mf/main.c b/dlls/mf/main.c index 73cd6aa3f1..b3573d78af 100644 --- a/dlls/mf/main.c +++ b/dlls/mf/main.c @@ -74,3 +74,21 @@ HRESULT WINAPI MFGetService(IUnknown *object, REFGUID service, REFIID riid, void IMFGetService_Release(gs); return hr; } + +/*********************************************************************** + * MFShutdownObject (mf.@) + */ +HRESULT WINAPI MFShutdownObject(IUnknown *object) +{ + IMFShutdown *shutdown; + + TRACE("%p.\n", object); + + if (object && SUCCEEDED(IUnknown_QueryInterface(object, &IID_IMFShutdown, (void **)&shutdown))) + { + IMFShutdown_Shutdown(shutdown); + IMFShutdown_Release(shutdown); + } + + return S_OK; +} diff --git a/dlls/mf/mf.spec b/dlls/mf/mf.spec index 64f0b1db83..7ec8e57c1f 100644 --- a/dlls/mf/mf.spec +++ b/dlls/mf/mf.spec @@ -78,6 +78,6 @@ @ stub MFGetTopoNodeCurrentType @ stub MFReadSequencerSegmentOffset @ stub MFRequireProtectedEnvironment -@ stub MFShutdownObject +@ stdcall MFShutdownObject(ptr) @ stub MFTranscodeGetAudioOutputAvailableTypes @ stub MergePropertyStore diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index ba11a27c33..915b851900 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -502,6 +502,66 @@ static void test_topology_loader(void) IMFTopoLoader_Release(loader); }
+static HRESULT WINAPI testshutdown_QueryInterface(IMFShutdown *iface, REFIID riid, void **obj) +{ + if (IsEqualIID(riid, &IID_IMFShutdown) || + IsEqualIID(riid, &IID_IUnknown)) + { + *obj = iface; + IMFShutdown_AddRef(iface); + return S_OK; + } + + *obj = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI testshutdown_AddRef(IMFShutdown *iface) +{ + return 2; +} + +static ULONG WINAPI testshutdown_Release(IMFShutdown *iface) +{ + return 1; +} + +static HRESULT WINAPI testshutdown_Shutdown(IMFShutdown *iface) +{ + return 0xdead; +} + +static HRESULT WINAPI testshutdown_GetShutdownStatus(IMFShutdown *iface, MFSHUTDOWN_STATUS *status) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static const IMFShutdownVtbl testshutdownvtbl = +{ + testshutdown_QueryInterface, + testshutdown_AddRef, + testshutdown_Release, + testshutdown_Shutdown, + testshutdown_GetShutdownStatus, +}; + +static void test_MFShutdownObject(void) +{ + IMFShutdown testshutdown = { &testshutdownvtbl }; + IUnknown testshutdown2 = { &testservicevtbl }; + HRESULT hr; + + hr = MFShutdownObject(NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = MFShutdownObject((IUnknown *)&testshutdown); + ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); + + hr = MFShutdownObject(&testshutdown2); + ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); +} + START_TEST(mf) { test_topology(); @@ -509,4 +569,5 @@ START_TEST(mf) test_MFGetService(); test_MFCreateSequencerSource(); test_media_session(); + test_MFShutdownObject(); } diff --git a/include/mfidl.idl b/include/mfidl.idl index 01e86efc51..be8795c854 100644 --- a/include/mfidl.idl +++ b/include/mfidl.idl @@ -329,6 +329,7 @@ cpp_quote("HRESULT WINAPI MFCreateTopoLoader(IMFTopoLoader **loader);") cpp_quote("HRESULT WINAPI MFGetSupportedMimeTypes(PROPVARIANT *array);") cpp_quote("HRESULT WINAPI MFGetService(IUnknown *object, REFGUID service, REFIID iid, void **obj);") cpp_quote("MFTIME WINAPI MFGetSystemTime(void);") +cpp_quote("HRESULT WINAPI MFShutdownObject(IUnknown *object);")
[ object, @@ -381,6 +382,22 @@ interface IMFMediaSink : IUnknown HRESULT Shutdown(); }
+typedef enum _MFSHUTDOWN_STATUS +{ + MFSHUTDOWN_INITIATED, + MFSHUTDOWN_COMPLETED, +} MFSHUTDOWN_STATUS; + +[ + object, + uuid(97ec2ea4-0e42-4937-97ac-9d6d328824e1) +] +interface IMFShutdown : IUnknown +{ + HRESULT Shutdown(); + HRESULT GetShutdownStatus([out] MFSHUTDOWN_STATUS *status); +} + cpp_quote("#define MF_RESOLUTION_MEDIASOURCE 0x00000001") cpp_quote("#define MF_RESOLUTION_BYTESTREAM 0x00000002") cpp_quote("#define MF_RESOLUTION_CONTENT_DOES_NOT_HAVE_TO_MATCH_EXTENSION_OR_MIME_TYPE 0x00000010")