Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/Makefile.in | 2 +- dlls/quartz/{version.rc => quartz.rc} | 3 + dlls/quartz/quartz.rgs | 82 +++++++ dlls/quartz/regsvr.c | 305 -------------------------- 4 files changed, 86 insertions(+), 306 deletions(-) rename dlls/quartz/{version.rc => quartz.rc} (95%) create mode 100644 dlls/quartz/quartz.rgs
diff --git a/dlls/quartz/Makefile.in b/dlls/quartz/Makefile.in index efd96dbb1c..4e5f18d20a 100644 --- a/dlls/quartz/Makefile.in +++ b/dlls/quartz/Makefile.in @@ -24,7 +24,7 @@ C_SRCS = \ vmr9.c \ waveparser.c
-RC_SRCS = version.rc +RC_SRCS = quartz.rc
IDL_SRCS = \ control_tlb.idl \ diff --git a/dlls/quartz/version.rc b/dlls/quartz/quartz.rc similarity index 95% rename from dlls/quartz/version.rc rename to dlls/quartz/quartz.rc index 8245cfbe0d..2355351274 100644 --- a/dlls/quartz/version.rc +++ b/dlls/quartz/quartz.rc @@ -25,3 +25,6 @@ #define WINE_EXTRAVALUES VALUE "OLESelfRegister",""
#include "wine/wine_common_ver.rc" + +/* @makedep: quartz.rgs */ +1 WINE_REGISTRY quartz.rgs diff --git a/dlls/quartz/quartz.rgs b/dlls/quartz/quartz.rgs new file mode 100644 index 0000000000..f99f59423e --- /dev/null +++ b/dlls/quartz/quartz.rgs @@ -0,0 +1,82 @@ +HKCR +{ + NoRemove 'Media Type' + { + '{e436eb83-524f-11ce-9f53-0020af0ba770}' + { + '{7364696d-0000-0010-8000-00aa00389b71}' + { + val '0' = s '0,4,,52494646,8,4,,524d4944' + val '1' = s '0,4,,4d546864' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{73747874-0000-0010-8000-00aa00389b71}' + { + val '0' = s '0,4,,4c595249' + val '1' = s '0,4,,6c797269' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{e06d8022-db46-11cf-b4d1-00805f6cbbea}' + { + val '0' = s '0,5,ffffffffc0,000001ba40' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{e436eb84-524f-11ce-9f53-0020af0ba770}' + { + val '0' = s '0,16,fffffffff100010001800001ffffffff,000001ba2100010001800001000001bb' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{e436eb85-524f-11ce-9f53-0020af0ba770}' + { + val '0' = s '0,4,,52494646,8,8,,43445841666D7420,36,20,FFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFF,646174610000000000FFFFFFFFFFFFFFFFFFFF00' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{e436eb86-524f-11ce-9f53-0020af0ba770}' + { + val '0' = s '0,4,,000001b3' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{e436eb87-524f-11ce-9f53-0020af0ba770}' + { + val '0' = s '0,2,ffe0,ffe0' + val '1' = s '0,10,ffffff00000080808080,494433000000000000' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{e436eb88-524f-11ce-9f53-0020af0ba770}' + { + val '0' = s '0,4,,52494646,8,4,,41564920' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{e436eb89-524f-11ce-9f53-0020af0ba770}' + { + val '0' = s '4,4,,6d646174' + val '1' = s '4,4,,6d6f6f76' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{e436eb8b-524f-11ce-9f53-0020af0ba770}' + { + val '0' = s '0,4,,52494646,8,4,,57415645' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{e436eb8c-524f-11ce-9f53-0020af0ba770}' + { + val '0' = s '0,4,,2e736e64' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + '{e436eb8d-524f-11ce-9f53-0020af0ba770}' + { + val '0' = s '0,4,,464f524d,8,4,,41494646' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + } + NoRemove Extensions + { + '.mp3' + { + val 'Media Type' = s '{e436eb83-524f-11ce-9f53-0020af0ba770}' + val 'Subtype' = s '{e436eb87-524f-11ce-9f53-0020af0ba770}' + val 'Source Filter' = s '{e436ebb5-524f-11ce-9f53-0020af0ba770}' + } + } + } +} diff --git a/dlls/quartz/regsvr.c b/dlls/quartz/regsvr.c index 839af311a6..7773caa947 100644 --- a/dlls/quartz/regsvr.c +++ b/dlls/quartz/regsvr.c @@ -45,23 +45,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz); * DllUnregisterServer, which make all this worthwhile. */
-struct regsvr_mediatype_parsing -{ - CLSID const *majortype; /* NULL for end of list */ - CLSID const *subtype; - LPCSTR line[11]; /* NULL for end of list */ -}; - -static HRESULT register_mediatypes_parsing(struct regsvr_mediatype_parsing const *list); -static HRESULT unregister_mediatypes_parsing(struct regsvr_mediatype_parsing const *list); - -struct regsvr_mediatype_extension -{ - CLSID const *majortype; /* NULL for end of list */ - CLSID const *subtype; - LPCSTR extension; -}; - struct mediatype { CLSID const *majortype; /* NULL for end of list */ @@ -84,201 +67,6 @@ struct regsvr_filter struct pin pins[11]; };
-static HRESULT register_mediatypes_extension(struct regsvr_mediatype_extension const *list); -static HRESULT unregister_mediatypes_extension(struct regsvr_mediatype_extension const *list); - -static HRESULT register_filters(struct regsvr_filter const *list); -static HRESULT unregister_filters(struct regsvr_filter const *list); - -/*********************************************************************** - * static string constants - */ -static const WCHAR mediatype_name[] = { - 'M', 'e', 'd', 'i', 'a', ' ', 'T', 'y', 'p', 'e', 0 }; -static const WCHAR subtype_valuename[] = { - 'S', 'u', 'b', 't', 'y', 'p', 'e', 0 }; -static const WCHAR sourcefilter_valuename[] = { - 'S', 'o', 'u', 'r', 'c', 'e', ' ', 'F', 'i', 'l', 't', 'e', 'r', 0 }; -static const WCHAR extensions_keyname[] = { - 'E', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', 's', 0 }; - -/*********************************************************************** - * register_mediatypes_parsing - */ -static HRESULT register_mediatypes_parsing(struct regsvr_mediatype_parsing const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY mediatype_key; - WCHAR buf[39]; - int i; - - res = RegCreateKeyExW(HKEY_CLASSES_ROOT, mediatype_name, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &mediatype_key, NULL); - if (res != ERROR_SUCCESS) return HRESULT_FROM_WIN32(res); - - for (; res == ERROR_SUCCESS && list->majortype; ++list) { - HKEY majortype_key = NULL; - HKEY subtype_key = NULL; - - StringFromGUID2(list->majortype, buf, 39); - res = RegCreateKeyExW(mediatype_key, buf, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &majortype_key, NULL); - if (res != ERROR_SUCCESS) goto error_close_keys; - - StringFromGUID2(list->subtype, buf, 39); - res = RegCreateKeyExW(majortype_key, buf, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &subtype_key, NULL); - if (res != ERROR_SUCCESS) goto error_close_keys; - - StringFromGUID2(&CLSID_AsyncReader, buf, 39); - res = RegSetValueExW(subtype_key, sourcefilter_valuename, 0, REG_SZ, (const BYTE*)buf, - (lstrlenW(buf) + 1) * sizeof(WCHAR)); - if (res != ERROR_SUCCESS) goto error_close_keys; - - for(i = 0; list->line[i]; i++) { - char buffer[3]; - wsprintfA(buffer, "%d", i); - res = RegSetValueExA(subtype_key, buffer, 0, REG_SZ, (const BYTE*)list->line[i], - lstrlenA(list->line[i])); - if (res != ERROR_SUCCESS) goto error_close_keys; - } - -error_close_keys: - if (majortype_key) - RegCloseKey(majortype_key); - if (subtype_key) - RegCloseKey(subtype_key); - } - - RegCloseKey(mediatype_key); - - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * register_mediatypes_extension - */ -static HRESULT register_mediatypes_extension(struct regsvr_mediatype_extension const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY mediatype_key; - HKEY extensions_root_key = NULL; - WCHAR buf[39]; - - res = RegCreateKeyExW(HKEY_CLASSES_ROOT, mediatype_name, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &mediatype_key, NULL); - if (res != ERROR_SUCCESS) return HRESULT_FROM_WIN32(res); - - res = RegCreateKeyExW(mediatype_key, extensions_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &extensions_root_key, NULL); - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->majortype; ++list) { - HKEY extension_key; - - res = RegCreateKeyExA(extensions_root_key, list->extension, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &extension_key, NULL); - if (res != ERROR_SUCCESS) break; - - StringFromGUID2(list->majortype, buf, 39); - res = RegSetValueExW(extension_key, mediatype_name, 0, REG_SZ, (const BYTE*)buf, - (lstrlenW(buf) + 1) * sizeof(WCHAR)); - if (res != ERROR_SUCCESS) goto error_close_key; - - StringFromGUID2(list->subtype, buf, 39); - res = RegSetValueExW(extension_key, subtype_valuename, 0, REG_SZ, (const BYTE*)buf, - (lstrlenW(buf) + 1) * sizeof(WCHAR)); - if (res != ERROR_SUCCESS) goto error_close_key; - - StringFromGUID2(&CLSID_AsyncReader, buf, 39); - res = RegSetValueExW(extension_key, sourcefilter_valuename, 0, REG_SZ, (const BYTE*)buf, - (lstrlenW(buf) + 1) * sizeof(WCHAR)); - if (res != ERROR_SUCCESS) goto error_close_key; - -error_close_key: - RegCloseKey(extension_key); - } - -error_return: - RegCloseKey(mediatype_key); - if (extensions_root_key) - RegCloseKey(extensions_root_key); - - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * unregister_mediatypes_parsing - */ -static HRESULT unregister_mediatypes_parsing(struct regsvr_mediatype_parsing const *list) -{ - LONG res; - HKEY mediatype_key; - HKEY majortype_key; - WCHAR buf[39]; - - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, mediatype_name, 0, - KEY_READ | KEY_WRITE, &mediatype_key); - if (res == ERROR_FILE_NOT_FOUND) return S_OK; - if (res != ERROR_SUCCESS) return HRESULT_FROM_WIN32(res); - - for (; res == ERROR_SUCCESS && list->majortype; ++list) { - StringFromGUID2(list->majortype, buf, 39); - res = RegOpenKeyExW(mediatype_key, buf, 0, - KEY_READ | KEY_WRITE, &majortype_key); - if (res == ERROR_FILE_NOT_FOUND) { - res = ERROR_SUCCESS; - continue; - } - if (res != ERROR_SUCCESS) break; - - StringFromGUID2(list->subtype, buf, 39); - res = RegDeleteTreeW(majortype_key, buf); - if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS; - - /* Removed majortype key if there is no more subtype key */ - res = RegDeleteKeyW(majortype_key, 0); - if (res == ERROR_ACCESS_DENIED) res = ERROR_SUCCESS; - - RegCloseKey(majortype_key); - } - - RegCloseKey(mediatype_key); - - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * unregister_mediatypes_extension - */ -static HRESULT unregister_mediatypes_extension(struct regsvr_mediatype_extension const *list) -{ - LONG res; - HKEY mediatype_key; - HKEY extensions_root_key = NULL; - - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, mediatype_name, 0, - KEY_READ | KEY_WRITE, &mediatype_key); - if (res == ERROR_FILE_NOT_FOUND) return S_OK; - if (res != ERROR_SUCCESS) return HRESULT_FROM_WIN32(res); - - res = RegOpenKeyExW(mediatype_key, extensions_keyname, 0, - KEY_READ | KEY_WRITE, &extensions_root_key); - if (res == ERROR_FILE_NOT_FOUND) - res = ERROR_SUCCESS; - else if (res == ERROR_SUCCESS) - for (; res == ERROR_SUCCESS && list->majortype; ++list) { - res = RegDeleteTreeA(extensions_root_key, list->extension); - if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS; - } - - RegCloseKey(mediatype_key); - if (extensions_root_key) - RegCloseKey(extensions_root_key); - - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - /*********************************************************************** * register_filters */ @@ -386,91 +174,6 @@ static HRESULT unregister_filters(struct regsvr_filter const *list) return hr; }
-/*********************************************************************** - * mediatype list - */ - -static struct regsvr_mediatype_parsing const mediatype_parsing_list[] = { - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_Avi, - { "0,4,,52494646,8,4,,41564920", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_MPEG1System, - { "0, 16, FFFFFFFFF100010001800001FFFFFFFF, 000001BA2100010001800001000001BB", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_MPEG1VideoCD, - { "0, 4, , 52494646, 8, 8, , 43445841666D7420, 36, 20, FFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFF, 646174610000000000FFFFFFFFFFFFFFFFFFFF00", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_MPEG1Video, - { "0, 4, , 000001B3", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_MPEG1Audio, - { "0, 2, FFE0, FFE0", - "0, 10, FFFFFF00000080808080, 494433000000000000", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_MPEG2_PROGRAM, - { "0, 5, FFFFFFFFC0, 000001BA40", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_QTMovie, - { "4, 4, , 6d646174", - "4, 4, , 6d6f6f76", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_WAVE, - { "0,4,,52494646,8,4,,57415645", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_AU, - { "0,4,,2e736e64", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_AIFF, - { "0,4,,464f524d,8,4,,41494646", - "0,4,,464f524d,8,4,,41494643", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIATYPE_Text, - { "0,4,,4C595249", - "0,4,,6C797269", - NULL } - }, - { &MEDIATYPE_Stream, - &MEDIATYPE_Midi, - { "0,4,,52494646,8,4,,524D4944", - "0,4,,4D546864", - NULL } - }, - { NULL } /* list terminator */ -}; - -/*********************************************************************** - * mediatype list - */ - -static struct regsvr_mediatype_extension const mediatype_extension_list[] = { - { &MEDIATYPE_Stream, - &MEDIASUBTYPE_MPEG1Audio, - ".mp3" - }, - { NULL } /* list terminator */ -}; - /*********************************************************************** * filter list */ @@ -687,10 +390,6 @@ HRESULT WINAPI DllRegisterServer(void) TRACE("\n");
hr = QUARTZ_DllRegisterServer(); - if (SUCCEEDED(hr)) - hr = register_mediatypes_parsing(mediatype_parsing_list); - if (SUCCEEDED(hr)) - hr = register_mediatypes_extension(mediatype_extension_list); if (SUCCEEDED(hr)) hr = register_filters(filter_list); return hr; @@ -706,10 +405,6 @@ HRESULT WINAPI DllUnregisterServer(void) TRACE("\n");
hr = unregister_filters(filter_list); - if (SUCCEEDED(hr)) - hr = unregister_mediatypes_parsing(mediatype_parsing_list); - if (SUCCEEDED(hr)) - hr = unregister_mediatypes_extension(mediatype_extension_list); if (SUCCEEDED(hr)) hr = QUARTZ_DllUnregisterServer(); return hr;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/Makefile.in | 2 +- dlls/quartz/filesource.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/quartz/Makefile.in b/dlls/quartz/Makefile.in index 4e5f18d20a..56ca40da1b 100644 --- a/dlls/quartz/Makefile.in +++ b/dlls/quartz/Makefile.in @@ -1,6 +1,6 @@ MODULE = quartz.dll IMPORTLIB = quartz -IMPORTS = strmiids dxguid strmbase uuid dsound msacm32 msvfw32 ole32 oleaut32 shlwapi rpcrt4 user32 gdi32 advapi32 +IMPORTS = strmiids dxguid strmbase uuid dsound msacm32 msvfw32 ole32 oleaut32 rpcrt4 user32 gdi32 advapi32
C_SRCS = \ acmwrapper.c \ diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index fc3e508960..e53db995f4 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -100,8 +100,7 @@ static HRESULT process_extensions(HKEY hkeyExtensions, LPCOLESTR pszFileName, GU return E_POINTER;
/* Get the part of the name that matters */ - extension = PathFindExtensionW(pszFileName); - if (*extension != '.') + if (!(extension = strrchrW(pszFileName, '.'))) return E_FAIL;
l = RegOpenKeyExW(hkeyExtensions, extension, 0, KEY_READ, &hsub);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/evr/tests/Makefile.in | 2 +- dlls/evr/tests/evr.c | 134 +++++++++++++++++++++++++++ dlls/evr/tests/filter.c | 179 ------------------------------------- 3 files changed, 135 insertions(+), 180 deletions(-) create mode 100644 dlls/evr/tests/evr.c delete mode 100644 dlls/evr/tests/filter.c
diff --git a/dlls/evr/tests/Makefile.in b/dlls/evr/tests/Makefile.in index 5ee4f84bad..8dc11e5e55 100644 --- a/dlls/evr/tests/Makefile.in +++ b/dlls/evr/tests/Makefile.in @@ -2,4 +2,4 @@ TESTDLL = evr.dll IMPORTS = mfuuid strmiids uuid ole32 oleaut32
C_SRCS = \ - filter.c + evr.c diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c new file mode 100644 index 0000000000..f90b91d4f3 --- /dev/null +++ b/dlls/evr/tests/evr.c @@ -0,0 +1,134 @@ +/* + * Enhanced Video Renderer filter unit tests + * + * Copyright 2018 Zebediah Figura + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS +#include "dshow.h" +#include "wine/test.h" + +static ULONG get_refcount(void *iface) +{ + IUnknown *unknown = iface; + IUnknown_AddRef(unknown); + return IUnknown_Release(unknown); +} + +static const GUID test_iid = {0x33333333}; +static LONG outer_ref = 1; + +static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out) +{ + if (IsEqualGUID(iid, &IID_IUnknown) + || IsEqualGUID(iid, &IID_IBaseFilter) + || IsEqualGUID(iid, &test_iid)) + { + *out = (IUnknown *)0xdeadbeef; + return S_OK; + } + ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI outer_AddRef(IUnknown *iface) +{ + return InterlockedIncrement(&outer_ref); +} + +static ULONG WINAPI outer_Release(IUnknown *iface) +{ + return InterlockedDecrement(&outer_ref); +} + +static const IUnknownVtbl outer_vtbl = +{ + outer_QueryInterface, + outer_AddRef, + outer_Release, +}; + +static IUnknown test_outer = {&outer_vtbl}; + +static void test_aggregation(void) +{ + IBaseFilter *filter, *filter2; + IUnknown *unk, *unk2; + HRESULT hr; + ULONG ref; + + filter = (IBaseFilter *)0xdeadbeef; + hr = CoCreateInstance(&CLSID_EnhancedVideoRenderer, &test_outer, CLSCTX_INPROC_SERVER, + &IID_IBaseFilter, (void **)&filter); + ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr); + ok(!filter, "Got interface %p.\n", filter); + + hr = CoCreateInstance(&CLSID_EnhancedVideoRenderer, &test_outer, CLSCTX_INPROC_SERVER, + &IID_IUnknown, (void **)&unk); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (FAILED(hr)) return; + ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref); + ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n"); + ref = get_refcount(unk); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + + ref = IUnknown_AddRef(unk); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); + ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref); + + ref = IUnknown_Release(unk); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref); + + hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2); + IUnknown_Release(unk2); + + hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void **)&filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBaseFilter_QueryInterface(filter, &IID_IUnknown, (void **)&unk2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2); + + hr = IBaseFilter_QueryInterface(filter, &IID_IBaseFilter, (void **)&filter2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(filter2 == (IBaseFilter *)0xdeadbeef, "Got unexpected IBaseFilter %p.\n", filter2); + + hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2); + ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr); + ok(!unk2, "Got unexpected IUnknown %p.\n", unk2); + + hr = IBaseFilter_QueryInterface(filter, &test_iid, (void **)&unk2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2); + + IBaseFilter_Release(filter); + ref = IUnknown_Release(unk); + ok(!ref, "Got unexpected refcount %d.\n", ref); + ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref); +} + +START_TEST(evr) +{ + CoInitialize(NULL); + + test_aggregation(); + + CoUninitialize(); +} diff --git a/dlls/evr/tests/filter.c b/dlls/evr/tests/filter.c deleted file mode 100644 index 84fff6df82..0000000000 --- a/dlls/evr/tests/filter.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2017 Fabian Maurer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define COBJMACROS - -#include <stdio.h> - -#include "dshow.h" -#include "evr.h" -#include "d3d9.h" -#include "initguid.h" -#include "dxva2api.h" - -#include "wine/test.h" - -#define QI_SUCCEED(iface, riid, ppv) hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \ - ok(hr == S_OK, "%s: run %d: IUnknown_QueryInterface returned %x\n", testid, testrun, hr); \ - ok(ppv != NULL, "%s: run %d: Pointer is NULL\n", testid, testrun); - -#define QI_FAIL(iface, riid, ppv) hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \ - ok(hr == E_NOINTERFACE, "%s: run %d: IUnknown_QueryInterface returned %x\n", testid, testrun, hr); \ - ok(ppv == NULL, "%s: run %d: Pointer is %p\n", testid, testrun, ppv); - -#define ADDREF_EXPECT(iface, num) if (iface) { \ - refCount = IUnknown_AddRef(iface); \ - ok(refCount == num, "%s: run %d: IUnknown_AddRef should return %d, got %d\n", testid, testrun, num, refCount); \ -} - -#define RELEASE_EXPECT(iface, num) if (iface) { \ - refCount = IUnknown_Release(iface); \ - ok(refCount == num, "%s: run %d: IUnknown_Release should return %d, got %d\n", testid, testrun, num, refCount); \ -} - -static void test_aggregation(const CLSID clsid_inner, const IID iid_inner, const char *testid, int testrun) -{ - const CLSID clsid_outer = CLSID_SystemClock; - const IID iid_outer = IID_IReferenceClock; - HRESULT hr; - ULONG refCount; - IUnknown *unk_outer = NULL; - IUnknown *unk_inner = NULL; - IUnknown *unk_inner_fail = NULL; - IUnknown *unk_outer_test = NULL; - IUnknown *unk_inner_test = NULL; - IUnknown *unk_aggregatee = NULL; - IUnknown *unk_aggregator = NULL; - IUnknown *unk_test = NULL; - - hr = CoCreateInstance(&clsid_outer, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (LPVOID*)&unk_outer); - ok(hr == S_OK, "%s: run %d: First CoCreateInstance failed with %x\n", testid, testrun, hr); - ok(unk_outer != NULL, "%s: run %d: unk_outer is NULL\n", testid, testrun); - - if (!unk_outer) - { - skip("%s: run %d: unk_outer is NULL\n", testid, testrun); - return; - } - - /* for aggregation, we should only be able to request IUnknown */ - hr = CoCreateInstance(&clsid_inner, unk_outer, CLSCTX_INPROC_SERVER, &iid_inner, (LPVOID*)&unk_inner_fail); - if (hr == REGDB_E_CLASSNOTREG) - { - skip("%s: run %d: Class not registered\n", testid, testrun); - return; - } - ok(hr == E_NOINTERFACE, "%s: run %d: Second CoCreateInstance returned %x\n", testid, testrun, hr); - ok(unk_inner_fail == NULL, "%s: run %d: unk_inner_fail is not NULL\n", testid, testrun); - - /* aggregation, request IUnknown */ - hr = CoCreateInstance(&clsid_inner, unk_outer, CLSCTX_INPROC_SERVER, &IID_IUnknown, (LPVOID*)&unk_inner); - todo_wine ok(hr == S_OK, "%s: run %d: Third CoCreateInstance returned %x\n", testid, testrun, hr); - todo_wine ok(unk_inner != NULL, "%s: run %d: unk_inner is NULL\n", testid, testrun); - - if (!unk_inner) - { - skip("%s: run %d: unk_inner is NULL\n", testid, testrun); - return; - } - - ADDREF_EXPECT(unk_outer, 2); - ADDREF_EXPECT(unk_inner, 2); - RELEASE_EXPECT(unk_outer, 1); - RELEASE_EXPECT(unk_inner, 1); - - QI_FAIL(unk_outer, iid_inner, unk_aggregatee); - QI_FAIL(unk_inner, iid_outer, unk_aggregator); - - QI_SUCCEED(unk_outer, iid_outer, unk_aggregator); - QI_SUCCEED(unk_outer, IID_IUnknown, unk_outer_test); - QI_SUCCEED(unk_inner, iid_inner, unk_aggregatee); - QI_SUCCEED(unk_inner, IID_IUnknown, unk_inner_test); - - if (!unk_aggregator || !unk_outer_test || !unk_aggregatee || !unk_inner_test) - { - skip("%s: run %d: One of the required interfaces is NULL\n", testid, testrun); - return; - } - - ADDREF_EXPECT(unk_aggregator, 5); - ADDREF_EXPECT(unk_outer_test, 6); - ADDREF_EXPECT(unk_aggregatee, 7); - ADDREF_EXPECT(unk_inner_test, 3); - RELEASE_EXPECT(unk_aggregator, 6); - RELEASE_EXPECT(unk_outer_test, 5); - RELEASE_EXPECT(unk_aggregatee, 4); - RELEASE_EXPECT(unk_inner_test, 2); - - QI_SUCCEED(unk_aggregator, IID_IUnknown, unk_test); - QI_SUCCEED(unk_outer_test, IID_IUnknown, unk_test); - QI_SUCCEED(unk_aggregatee, IID_IUnknown, unk_test); - QI_SUCCEED(unk_inner_test, IID_IUnknown, unk_test); - - QI_FAIL(unk_aggregator, iid_inner, unk_test); - QI_FAIL(unk_outer_test, iid_inner, unk_test); - QI_FAIL(unk_aggregatee, iid_inner, unk_test); - QI_SUCCEED(unk_inner_test, iid_inner, unk_test); - - QI_SUCCEED(unk_aggregator, iid_outer, unk_test); - QI_SUCCEED(unk_outer_test, iid_outer, unk_test); - QI_SUCCEED(unk_aggregatee, iid_outer, unk_test); - QI_FAIL(unk_inner_test, iid_outer, unk_test); - - RELEASE_EXPECT(unk_aggregator, 10); - RELEASE_EXPECT(unk_outer_test, 9); - RELEASE_EXPECT(unk_aggregatee, 8); - RELEASE_EXPECT(unk_inner_test, 2); - RELEASE_EXPECT(unk_outer, 7); - RELEASE_EXPECT(unk_inner, 1); - - do - { - refCount = IUnknown_Release(unk_inner); - } while (refCount); - - do - { - refCount = IUnknown_Release(unk_outer); - } while (refCount); -} - -static void test_evr_filter_aggregations(void) -{ - const IID * iids[] = { - &IID_IAMCertifiedOutputProtection, &IID_IAMFilterMiscFlags, &IID_IBaseFilter, - &IID_IKsPropertySet, &IID_IMediaEventSink, &IID_IMediaSeeking, &IID_IQualityControl, - &IID_IQualProp, &IID_IEVRFilterConfig, &IID_IMFGetService, &IID_IMFVideoPositionMapper, - &IID_IMFVideoRenderer, &IID_IQualityControl - }; - int i; - - for (i = 0; i < ARRAY_SIZE(iids); i++) - { - test_aggregation(CLSID_EnhancedVideoRenderer, *iids[i], "filter", i); - } -} - -START_TEST(filter) -{ - CoInitialize(NULL); - - test_evr_filter_aggregations(); - - CoUninitialize(); -}
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/evr/tests/evr.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c index f90b91d4f3..34db51c900 100644 --- a/dlls/evr/tests/evr.c +++ b/dlls/evr/tests/evr.c @@ -21,6 +21,18 @@ #define COBJMACROS #include "dshow.h" #include "wine/test.h" +#include "d3d9.h" +#include "initguid.h" +#include "dxva2api.h" + +static IBaseFilter *create_evr(void) +{ + IBaseFilter *filter = NULL; + HRESULT hr = CoCreateInstance(&CLSID_EnhancedVideoRenderer, NULL, CLSCTX_INPROC_SERVER, + &IID_IBaseFilter, (void **)&filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + return filter; +}
static ULONG get_refcount(void *iface) { @@ -124,11 +136,53 @@ static void test_aggregation(void) ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref); }
+#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) +static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) +{ + IUnknown *iface = iface_ptr; + HRESULT hr, expected_hr; + IUnknown *unk; + + expected_hr = supported ? S_OK : E_NOINTERFACE; + + hr = IUnknown_QueryInterface(iface, iid, (void **)&unk); + ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); + if (SUCCEEDED(hr)) + IUnknown_Release(unk); +} + +static void test_interfaces(void) +{ + IBaseFilter *filter = create_evr(); + ULONG ref; + + todo_wine check_interface(filter, &IID_IAMFilterMiscFlags, TRUE); + check_interface(filter, &IID_IBaseFilter, TRUE); + check_interface(filter, &IID_IMediaFilter, TRUE); + todo_wine check_interface(filter, &IID_IMediaPosition, TRUE); + todo_wine check_interface(filter, &IID_IMediaSeeking, TRUE); + check_interface(filter, &IID_IPersist, TRUE); + check_interface(filter, &IID_IUnknown, TRUE); + + check_interface(filter, &IID_IBasicAudio, FALSE); + check_interface(filter, &IID_IBasicVideo, FALSE); + check_interface(filter, &IID_IDirectXVideoMemoryConfiguration, FALSE); + check_interface(filter, &IID_IMemInputPin, FALSE); + check_interface(filter, &IID_IPersistPropertyBag, FALSE); + check_interface(filter, &IID_IPin, FALSE); + check_interface(filter, &IID_IReferenceClock, FALSE); + check_interface(filter, &IID_IVideoWindow, FALSE); + + ref = IBaseFilter_Release(filter); + ok(!ref, "Got unexpected refcount %d.\n", ref); +} + START_TEST(evr) { CoInitialize(NULL);
test_aggregation(); + test_interfaces();
CoUninitialize(); }