Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/filtergraph.c | 94 +++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 49 deletions(-)
diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c index 1ed41bdcec..1ef9c6e3af 100644 --- a/dlls/quartz/filtergraph.c +++ b/dlls/quartz/filtergraph.c @@ -184,7 +184,9 @@ typedef struct _IFilterGraphImpl { LONG ref; IUnknown *punkFilterMapper2; struct list filters; - LONG nameIndex; + + unsigned int name_index; + IReferenceClock *refClock; IBaseFilter *refClockProvider; EventsQueue evqueue; @@ -554,74 +556,68 @@ static IBaseFilter *find_filter_by_name(IFilterGraphImpl *graph, const WCHAR *na }
/*** IFilterGraph methods ***/ -static HRESULT WINAPI FilterGraph2_AddFilter(IFilterGraph2 *iface, IBaseFilter *pFilter, - LPCWSTR pName) +static HRESULT WINAPI FilterGraph2_AddFilter(IFilterGraph2 *iface, + IBaseFilter *filter, const WCHAR *name) { - IFilterGraphImpl *This = impl_from_IFilterGraph2(iface); + IFilterGraphImpl *graph = impl_from_IFilterGraph2(iface); + BOOL duplicate_name = FALSE; struct filter *entry; + unsigned int i; HRESULT hr; - int j; - WCHAR* wszFilterName = NULL; - BOOL duplicate_name = FALSE;
- TRACE("(%p/%p)->(%p, %s (%p))\n", This, iface, pFilter, debugstr_w(pName), pName); + TRACE("graph %p, filter %p, name %s.\n", graph, filter, debugstr_w(name));
- if (!pFilter) + if (!filter) return E_POINTER;
- wszFilterName = CoTaskMemAlloc( (pName ? lstrlenW(pName) + 6 : 5) * sizeof(WCHAR) ); + if (!(entry = heap_alloc(sizeof(*entry)))) + return E_OUTOFMEMORY;
- if (pName && find_filter_by_name(This, pName)) + if (!(entry->name = CoTaskMemAlloc((name ? wcslen(name) + 6 : 5) * sizeof(WCHAR)))) + { + heap_free(entry); + return E_OUTOFMEMORY; + } + + if (name && find_filter_by_name(graph, name)) duplicate_name = TRUE;
- /* If no name given or name already existing, generate one */ - if (!pName || duplicate_name) + if (!name || duplicate_name) { - static const WCHAR wszFmt1[] = {'%','s',' ','%','0','4','d',0}; - static const WCHAR wszFmt2[] = {'%','0','4','d',0}; - - for (j = 0; j < 10000 ; j++) - { - /* Create name */ - if (pName) - swprintf(wszFilterName, pName ? lstrlenW(pName) + 6 : 5, wszFmt1, pName, This->nameIndex); - else - swprintf(wszFilterName, pName ? lstrlenW(pName) + 6 : 5, wszFmt2, This->nameIndex); - TRACE("Generated name %s\n", debugstr_w(wszFilterName)); + for (i = 0; i < 10000 ; ++i) + { + if (name) + swprintf(entry->name, name ? wcslen(name) + 6 : 5, L"%s %04u", name, graph->name_index); + else + swprintf(entry->name, name ? wcslen(name) + 6 : 5, L"%04u", graph->name_index);
- if (This->nameIndex++ == 10000) - This->nameIndex = 1; + graph->name_index = (graph->name_index + 1) % 10000;
- if (!find_filter_by_name(This, wszFilterName)) + if (!find_filter_by_name(graph, entry->name)) break; - } - /* Unable to find a suitable name */ - if (j == 10000) - { - CoTaskMemFree(wszFilterName); - return VFW_E_DUPLICATE_NAME; - } + } + + if (i == 10000) + { + CoTaskMemFree(entry->name); + heap_free(entry); + return VFW_E_DUPLICATE_NAME; + } } else - memcpy(wszFilterName, pName, (lstrlenW(pName) + 1) * sizeof(WCHAR)); + wcscpy(entry->name, name);
- hr = IBaseFilter_JoinFilterGraph(pFilter, (IFilterGraph *)&This->IFilterGraph2_iface, wszFilterName); - if (FAILED(hr)) + if (FAILED(hr = IBaseFilter_JoinFilterGraph(filter, + (IFilterGraph *)&graph->IFilterGraph2_iface, entry->name))) { - CoTaskMemFree(wszFilterName); + CoTaskMemFree(entry->name); + heap_free(entry); return hr; }
- if (!(entry = heap_alloc(sizeof(*entry)))) - { - CoTaskMemFree(wszFilterName); - return E_OUTOFMEMORY; - } - - IBaseFilter_AddRef(entry->filter = pFilter); - entry->name = wszFilterName; - list_add_head(&This->filters, &entry->entry); - This->version++; + IBaseFilter_AddRef(entry->filter = filter); + list_add_head(&graph->filters, &entry->entry); + ++graph->version;
return duplicate_name ? VFW_S_DUPLICATE_NAME : hr; } @@ -5706,7 +5702,7 @@ static HRESULT filter_graph_common_create(IUnknown *outer, void **out, BOOL thre fimpl->IGraphVersion_iface.lpVtbl = &IGraphVersion_VTable; fimpl->ref = 1; list_init(&fimpl->filters); - fimpl->nameIndex = 1; + fimpl->name_index = 1; fimpl->refClock = NULL; fimpl->hEventCompletion = CreateEventW(0, TRUE, FALSE, 0); fimpl->HandleEcComplete = TRUE;
Avoid some unnecessary allocations.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/filtermapper.c | 66 ++++++++++++++------------------------ 1 file changed, 24 insertions(+), 42 deletions(-)
diff --git a/dlls/quartz/filtermapper.c b/dlls/quartz/filtermapper.c index f0a52c4411..96faa163ae 100644 --- a/dlls/quartz/filtermapper.c +++ b/dlls/quartz/filtermapper.c @@ -253,62 +253,44 @@ static ULONG WINAPI FilterMapper3_Release(IFilterMapper3 * iface)
/*** IFilterMapper3 methods ***/
-static HRESULT WINAPI FilterMapper3_CreateCategory( - IFilterMapper3 * iface, - REFCLSID clsidCategory, - DWORD dwCategoryMerit, - LPCWSTR szDescription) +static HRESULT WINAPI FilterMapper3_CreateCategory(IFilterMapper3 *iface, + REFCLSID category, DWORD merit, const WCHAR *description) { - LPWSTR wClsidAMCat = NULL; - LPWSTR wClsidCategory = NULL; - WCHAR wszKeyName[ARRAY_SIZE(wszClsidSlash)-1 + ARRAY_SIZE(wszSlashInstance)-1 + (CHARS_IN_GUID-1) * 2 + 1]; - HKEY hKey = NULL; - LONG lRet; - HRESULT hr; - - TRACE("(%s, %x, %s)\n", debugstr_guid(clsidCategory), dwCategoryMerit, debugstr_w(szDescription)); - - hr = StringFromCLSID(&CLSID_ActiveMovieCategories, &wClsidAMCat); + WCHAR guidstr[39], keypath[93]; + HKEY key; + LONG ret;
- if (SUCCEEDED(hr)) - { - hr = StringFromCLSID(clsidCategory, &wClsidCategory); - } + TRACE("iface %p, category %s, merit %#x, description %s.\n", iface, + debugstr_guid(category), merit, debugstr_w(description));
- if (SUCCEEDED(hr)) - { - lstrcpyW(wszKeyName, wszClsidSlash); - lstrcatW(wszKeyName, wClsidAMCat); - lstrcatW(wszKeyName, wszSlashInstance); - lstrcatW(wszKeyName, wClsidCategory); + StringFromGUID2(category, guidstr, ARRAY_SIZE(guidstr)); + wcscpy(keypath, L"CLSID\{da4e3da0-d07d-11d0-bd50-00a0c911ce86}\Instance\"); + wcscat(keypath, guidstr);
- lRet = RegCreateKeyExW(HKEY_CLASSES_ROOT, wszKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL); - hr = HRESULT_FROM_WIN32(lRet); - } + if ((ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, keypath, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL))) + return HRESULT_FROM_WIN32(ret);
- if (SUCCEEDED(hr)) + if ((ret = RegSetValueExW(key, L"FriendlyName", 0, REG_SZ, + (const BYTE *)description, (wcslen(description) + 1) * sizeof(WCHAR)))) { - lRet = RegSetValueExW(hKey, wszFriendlyName, 0, REG_SZ, (const BYTE*)szDescription, (lstrlenW(szDescription) + 1) * sizeof(WCHAR)); - hr = HRESULT_FROM_WIN32(lRet); + RegCloseKey(key); + return HRESULT_FROM_WIN32(ret); }
- if (SUCCEEDED(hr)) + if ((ret = RegSetValueExW(key, L"CLSID", 0, REG_SZ, (const BYTE *)guidstr, sizeof(guidstr)))) { - lRet = RegSetValueExW(hKey, wszClsidName, 0, REG_SZ, (LPBYTE)wClsidCategory, (lstrlenW(wClsidCategory) + 1) * sizeof(WCHAR)); - hr = HRESULT_FROM_WIN32(lRet); + RegCloseKey(key); + return HRESULT_FROM_WIN32(ret); }
- if (SUCCEEDED(hr)) + if ((ret = RegSetValueExW(key, L"Merit", 0, REG_DWORD, (const BYTE *)&merit, sizeof(DWORD)))) { - lRet = RegSetValueExW(hKey, wszMeritName, 0, REG_DWORD, (LPBYTE)&dwCategoryMerit, sizeof(dwCategoryMerit)); - hr = HRESULT_FROM_WIN32(lRet); + RegCloseKey(key); + return HRESULT_FROM_WIN32(ret); }
- RegCloseKey(hKey); - CoTaskMemFree(wClsidCategory); - CoTaskMemFree(wClsidAMCat); - - return hr; + RegCloseKey(key); + return S_OK; }
static HRESULT WINAPI FilterMapper3_UnregisterFilter(
Avoid some unnecessary allocations.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/filtermapper.c | 54 +++++++++++--------------------------- 1 file changed, 15 insertions(+), 39 deletions(-)
diff --git a/dlls/quartz/filtermapper.c b/dlls/quartz/filtermapper.c index 96faa163ae..4bbc96f774 100644 --- a/dlls/quartz/filtermapper.c +++ b/dlls/quartz/filtermapper.c @@ -73,7 +73,6 @@ static inline FilterMapper3Impl *impl_from_IUnknown( IUnknown *iface ) }
static const WCHAR wszClsidSlash[] = {'C','L','S','I','D','\',0}; -static const WCHAR wszSlashInstance[] = {'\','I','n','s','t','a','n','c','e','\',0}; static const WCHAR wszSlash[] = {'\',0};
/* CLSID property in media category Moniker */ @@ -293,49 +292,26 @@ static HRESULT WINAPI FilterMapper3_CreateCategory(IFilterMapper3 *iface, return S_OK; }
-static HRESULT WINAPI FilterMapper3_UnregisterFilter( - IFilterMapper3 * iface, - const CLSID *pclsidCategory, - const OLECHAR *szInstance, - REFCLSID Filter) +static HRESULT WINAPI FilterMapper3_UnregisterFilter(IFilterMapper3 *iface, + const CLSID *category, const WCHAR *instance, REFCLSID clsid) { - WCHAR wszKeyName[MAX_PATH]; - LPWSTR wClsidCategory = NULL; - LPWSTR wFilter = NULL; - HRESULT hr; + WCHAR keypath[93];
- TRACE("(%p, %s, %s)\n", pclsidCategory, debugstr_w(szInstance), debugstr_guid(Filter)); + TRACE("iface %p, category %s, instance %s, clsid %s.\n", + iface, debugstr_guid(category), debugstr_w(instance), debugstr_guid(clsid));
- if (!pclsidCategory) - pclsidCategory = &CLSID_LegacyAmFilterCategory; + if (!category) + category = &CLSID_LegacyAmFilterCategory;
- hr = StringFromCLSID(pclsidCategory, &wClsidCategory); - - if (SUCCEEDED(hr)) - { - lstrcpyW(wszKeyName, wszClsidSlash); - lstrcatW(wszKeyName, wClsidCategory); - lstrcatW(wszKeyName, wszSlashInstance); - if (szInstance) - lstrcatW(wszKeyName, szInstance); - else - { - hr = StringFromCLSID(Filter, &wFilter); - if (SUCCEEDED(hr)) - lstrcatW(wszKeyName, wFilter); - } - } - - if (SUCCEEDED(hr)) - { - LONG lRet = RegDeleteKeyW(HKEY_CLASSES_ROOT, wszKeyName); - hr = HRESULT_FROM_WIN32(lRet); - } - - CoTaskMemFree(wClsidCategory); - CoTaskMemFree(wFilter); + wcscpy(keypath, L"CLSID\"); + StringFromGUID2(category, keypath + wcslen(keypath), ARRAY_SIZE(keypath) - wcslen(keypath)); + wcscat(keypath, L"\Instance\"); + if (instance) + wcscat(keypath, instance); + else + StringFromGUID2(clsid, keypath + wcslen(keypath), ARRAY_SIZE(keypath) - wcslen(keypath));
- return hr; + return HRESULT_FROM_WIN32(RegDeleteKeyW(HKEY_CLASSES_ROOT, keypath)); }
static HRESULT FM2_WriteFriendlyName(IPropertyBag * pPropBag, LPCWSTR szName)
Avoid some unnecessary allocations.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/filtermapper.c | 230 +++++++++++-------------------------- 1 file changed, 66 insertions(+), 164 deletions(-)
diff --git a/dlls/quartz/filtermapper.c b/dlls/quartz/filtermapper.c index 4bbc96f774..763e378b21 100644 --- a/dlls/quartz/filtermapper.c +++ b/dlls/quartz/filtermapper.c @@ -314,39 +314,6 @@ static HRESULT WINAPI FilterMapper3_UnregisterFilter(IFilterMapper3 *iface, return HRESULT_FROM_WIN32(RegDeleteKeyW(HKEY_CLASSES_ROOT, keypath)); }
-static HRESULT FM2_WriteFriendlyName(IPropertyBag * pPropBag, LPCWSTR szName) -{ - VARIANT var; - HRESULT ret; - BSTR value; - - V_VT(&var) = VT_BSTR; - V_BSTR(&var) = value = SysAllocString(szName); - - ret = IPropertyBag_Write(pPropBag, wszFriendlyName, &var); - SysFreeString(value); - - return ret; -} - -static HRESULT FM2_WriteClsid(IPropertyBag * pPropBag, REFCLSID clsid) -{ - LPWSTR wszClsid = NULL; - VARIANT var; - HRESULT hr; - - hr = StringFromCLSID(clsid, &wszClsid); - - if (SUCCEEDED(hr)) - { - V_VT(&var) = VT_BSTR; - V_BSTR(&var) = wszClsid; - hr = IPropertyBag_Write(pPropBag, wszClsidName, &var); - } - CoTaskMemFree(wszClsid); - return hr; -} - static HRESULT FM2_WriteFilterData(const REGFILTER2 * prf2, BYTE **ppData, ULONG *pcbData) { int size = sizeof(struct REG_RF); @@ -577,36 +544,26 @@ static void FM2_DeleteRegFilter(REGFILTER2 * prf2) CoTaskMemFree((LPVOID)prf2->u.s2.rgPins2); }
-static HRESULT WINAPI FilterMapper3_RegisterFilter( - IFilterMapper3 * iface, - REFCLSID clsidFilter, - LPCWSTR szName, - IMoniker **ppMoniker, - const CLSID *pclsidCategory, - const OLECHAR *szInstance, - const REGFILTER2 *prf2) +static HRESULT WINAPI FilterMapper3_RegisterFilter(IFilterMapper3 *iface, + REFCLSID clsid, const WCHAR *name, IMoniker **ret_moniker, + const CLSID *category, const WCHAR *instance, const REGFILTER2 *prf2) { - IParseDisplayName * pParser = NULL; - IBindCtx * pBindCtx = NULL; - IMoniker * pMoniker = NULL; - IPropertyBag * pPropBag = NULL; + WCHAR *display_name, clsid_string[39]; + IParseDisplayName *parser; + IPropertyBag *prop_bag; + ULONG filter_data_len; + IMoniker *moniker; + BYTE *filter_data; + VARIANT var; + ULONG eaten; HRESULT hr; - LPWSTR pwszParseName = NULL; - LPWSTR pCurrent; - static const WCHAR wszDevice[] = {'@','d','e','v','i','c','e',':','s','w',':',0}; - int nameLen; - ULONG ulEaten; - LPWSTR szClsidTemp = NULL; + size_t len; REGFILTER2 regfilter2; REGFILTERPINS2* pregfp2 = NULL;
- TRACE("(%s, %s, %p, %s, %s, %p)\n", - debugstr_guid(clsidFilter), - debugstr_w(szName), - ppMoniker, - debugstr_guid(pclsidCategory), - debugstr_w(szInstance), - prf2); + TRACE("iface %p, clsid %s, name %s, ret_moniker %p, category %s, instance %s, prf2 %p.\n", + iface, debugstr_guid(clsid), debugstr_w(name), ret_moniker, + debugstr_guid(category), debugstr_w(instance), prf2);
if (prf2->dwVersion == 2) { @@ -648,135 +605,80 @@ static HRESULT WINAPI FilterMapper3_RegisterFilter( return E_NOTIMPL; }
- if (ppMoniker) - *ppMoniker = NULL; + if (ret_moniker) + *ret_moniker = NULL;
- if (!pclsidCategory) - /* MSDN mentions the inexistent CLSID_ActiveMovieFilters GUID. - * In fact this is the CLSID_LegacyAmFilterCategory one */ - pclsidCategory = &CLSID_LegacyAmFilterCategory; - - /* sizeof... will include the null terminator and - * the + 1 is for the separator ('\'). The -1 is - * because CHARS_IN_GUID includes the null terminator - */ - nameLen = ARRAY_SIZE(wszDevice) + CHARS_IN_GUID - 1 + 1; + if (!category) + category = &CLSID_LegacyAmFilterCategory;
- if (szInstance) - nameLen += lstrlenW(szInstance); - else - nameLen += CHARS_IN_GUID - 1; /* CHARS_IN_GUID includes null terminator */ + StringFromGUID2(clsid, clsid_string, ARRAY_SIZE(clsid_string));
- pCurrent = pwszParseName = CoTaskMemAlloc(nameLen*sizeof(WCHAR)); - if (!pwszParseName) + len = 50 + (instance ? wcslen(instance) : 38) + 1; + if (!(display_name = malloc(len * sizeof(WCHAR)))) return E_OUTOFMEMORY;
- lstrcpyW(pwszParseName, wszDevice); - pCurrent += lstrlenW(wszDevice); + wcscpy(display_name, L"@device:sw:"); + StringFromGUID2(category, display_name + wcslen(display_name), len - wcslen(display_name)); + wcscat(display_name, L"\"); + wcscat(display_name, instance ? instance : clsid_string);
- hr = StringFromCLSID(pclsidCategory, &szClsidTemp); + if (FAILED(hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, + &IID_IParseDisplayName, (void **)&parser))) + return hr;
- if (SUCCEEDED(hr)) + if (FAILED(hr = IParseDisplayName_ParseDisplayName(parser, NULL, display_name, &eaten, &moniker))) { - memcpy(pCurrent, szClsidTemp, CHARS_IN_GUID * sizeof(WCHAR)); - pCurrent += CHARS_IN_GUID - 1; - pCurrent[0] = '\'; - - if (szInstance) - lstrcpyW(pCurrent+1, szInstance); - else - { - CoTaskMemFree(szClsidTemp); - szClsidTemp = NULL; - - hr = StringFromCLSID(clsidFilter, &szClsidTemp); - if (SUCCEEDED(hr)) - lstrcpyW(pCurrent+1, szClsidTemp); - } + ERR("Failed to parse display name, hr %#x.\n", hr); + IParseDisplayName_Release(parser); + return hr; }
- if (SUCCEEDED(hr)) - hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (LPVOID *)&pParser); + IParseDisplayName_Release(parser);
- if (SUCCEEDED(hr)) - hr = CreateBindCtx(0, &pBindCtx); - - if (SUCCEEDED(hr)) - hr = IParseDisplayName_ParseDisplayName(pParser, pBindCtx, pwszParseName, &ulEaten, &pMoniker); - - if (pBindCtx) - IBindCtx_Release(pBindCtx); - if (pParser) - IParseDisplayName_Release(pParser); - - if (SUCCEEDED(hr)) - hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID)&pPropBag); + if (FAILED(hr = IMoniker_BindToStorage(moniker, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag))) + { + ERR("Failed to get property bag, hr %#x.\n", hr); + IMoniker_Release(moniker); + return hr; + }
- if (SUCCEEDED(hr)) - hr = FM2_WriteFriendlyName(pPropBag, szName); + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocString(name); + if (FAILED(hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var))) + ERR("Failed to write friendly name, hr %#x.\n", hr); + VariantClear(&var);
- if (SUCCEEDED(hr)) - hr = FM2_WriteClsid(pPropBag, clsidFilter); + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocString(clsid_string); + if (FAILED(hr = IPropertyBag_Write(prop_bag, L"CLSID", &var))) + ERR("Failed to write class ID, hr %#x.\n", hr); + VariantClear(&var);
- if (SUCCEEDED(hr)) + if (SUCCEEDED(FM2_WriteFilterData(®filter2, &filter_data, &filter_data_len))) { - BYTE *pData; - ULONG cbData; - - hr = FM2_WriteFilterData(®filter2, &pData, &cbData); - if (SUCCEEDED(hr)) + V_VT(&var) = VT_ARRAY | VT_UI1; + if ((V_ARRAY(&var) = SafeArrayCreateVector(VT_UI1, 0, filter_data_len))) { - VARIANT var; - SAFEARRAY *psa; - SAFEARRAYBOUND saBound; - - saBound.lLbound = 0; - saBound.cElements = cbData; - psa = SafeArrayCreate(VT_UI1, 1, &saBound); - if (!psa) - { - ERR("Couldn't create SAFEARRAY\n"); - hr = E_FAIL; - } - - if (SUCCEEDED(hr)) - { - LPBYTE pbSAData; - hr = SafeArrayAccessData(psa, (LPVOID *)&pbSAData); - if (SUCCEEDED(hr)) - { - memcpy(pbSAData, pData, cbData); - hr = SafeArrayUnaccessData(psa); - } - } - - V_VT(&var) = VT_ARRAY | VT_UI1; - V_ARRAY(&var) = psa; - - if (SUCCEEDED(hr)) - hr = IPropertyBag_Write(pPropBag, wszFilterDataName, &var); - - if (psa) - SafeArrayDestroy(psa); - CoTaskMemFree(pData); + memcpy(V_ARRAY(&var)->pvData, filter_data, filter_data_len); + if (FAILED(hr = IPropertyBag_Write(prop_bag, L"FilterData", &var))) + ERR("Failed to write filter data, hr %#x.\n", hr); + VariantClear(&var); } + + CoTaskMemFree(filter_data); }
- if (pPropBag) - IPropertyBag_Release(pPropBag); - CoTaskMemFree(szClsidTemp); - CoTaskMemFree(pwszParseName); + IPropertyBag_Release(prop_bag); + free(display_name);
- if (SUCCEEDED(hr) && ppMoniker) - *ppMoniker = pMoniker; - else if (pMoniker) - IMoniker_Release(pMoniker); + if (ret_moniker) + *ret_moniker = moniker; + else + IMoniker_Release(moniker);
CoTaskMemFree(pregfp2);
- TRACE("-- returning %x\n", hr); - - return hr; + return S_OK; }
/* internal helper function */
Avoid some unnecessary allocations.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/filtermapper.c | 62 +++++++++++++++----------------------- 1 file changed, 24 insertions(+), 38 deletions(-)
diff --git a/dlls/quartz/filtermapper.c b/dlls/quartz/filtermapper.c index 763e378b21..357c9c61f2 100644 --- a/dlls/quartz/filtermapper.c +++ b/dlls/quartz/filtermapper.c @@ -1119,53 +1119,39 @@ static HRESULT WINAPI FilterMapper_EnumMatchingFilters( }
-static HRESULT WINAPI FilterMapper_RegisterFilter(IFilterMapper * iface, CLSID clsid, LPCWSTR szName, DWORD dwMerit) +static HRESULT WINAPI FilterMapper_RegisterFilter(IFilterMapper * iface, + CLSID clsid, const WCHAR *name, DWORD merit) { - HRESULT hr; - LPWSTR wszClsid = NULL; - HKEY hKey; - LONG lRet; - WCHAR wszKeyName[ARRAY_SIZE(wszFilterSlash)-1 + (CHARS_IN_GUID-1) + 1]; - - TRACE("(%p)->(%s, %s, %x)\n", iface, debugstr_guid(&clsid), debugstr_w(szName), dwMerit); + WCHAR keypath[46], guidstr[39]; + HKEY key; + LONG ret;
- hr = StringFromCLSID(&clsid, &wszClsid); + TRACE("iface %p, clsid %s, name %s, merit %#x.\n", + iface, debugstr_guid(&clsid), debugstr_w(name), merit);
- if (SUCCEEDED(hr)) - { - lstrcpyW(wszKeyName, wszFilterSlash); - lstrcatW(wszKeyName, wszClsid); - - lRet = RegCreateKeyExW(HKEY_CLASSES_ROOT, wszKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL); - hr = HRESULT_FROM_WIN32(lRet); - } + StringFromGUID2(&clsid, guidstr, ARRAY_SIZE(guidstr));
- if (SUCCEEDED(hr)) - { - lRet = RegSetValueExW(hKey, NULL, 0, REG_SZ, (const BYTE*)szName, (lstrlenW(szName) + 1) * sizeof(WCHAR)); - hr = HRESULT_FROM_WIN32(lRet); - RegCloseKey(hKey); - } + wcscpy(keypath, L"Filter\"); + wcscat(keypath, guidstr); + if ((ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, keypath, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL))) + return HRESULT_FROM_WIN32(ret);
- if (SUCCEEDED(hr)) - { - lstrcpyW(wszKeyName, wszClsidSlash); - lstrcatW(wszKeyName, wszClsid); - - lRet = RegCreateKeyExW(HKEY_CLASSES_ROOT, wszKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL); - hr = HRESULT_FROM_WIN32(lRet); - } + if ((ret = RegSetValueExW(key, NULL, 0, REG_SZ, (const BYTE *)name, (wcslen(name) + 1) * sizeof(WCHAR)))) + ERR("Failed to set filter name, error %u.\n", ret); + RegCloseKey(key);
- if (SUCCEEDED(hr)) + wcscpy(keypath, L"CLSID\"); + wcscat(keypath, guidstr); + if (!(ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, keypath, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL))) { - lRet = RegSetValueExW(hKey, wszMeritName, 0, REG_DWORD, (LPBYTE)&dwMerit, sizeof(dwMerit)); - hr = HRESULT_FROM_WIN32(lRet); - RegCloseKey(hKey); + if ((ret = RegSetValueExW(key, L"Merit", 0, REG_DWORD, (const BYTE *)&merit, sizeof(DWORD)))) + ERR("Failed to set merit, error %u.\n", ret); + RegCloseKey(key); } - - CoTaskMemFree(wszClsid); + else + ERR("Failed to create CLSID key, error %u.\n", ret);
- return hr; + return S_OK; }
static HRESULT WINAPI FilterMapper_RegisterFilterInstance(IFilterMapper * iface, CLSID clsid, LPCWSTR szName, CLSID *MRId)