Commit 55620f09 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msdmo: Added a helper to duplicate partial media type arrays.

parent 0b7b8e3d
...@@ -360,6 +360,21 @@ HRESULT WINAPI DMOGetName(REFCLSID clsidDMO, WCHAR name[]) ...@@ -360,6 +360,21 @@ HRESULT WINAPI DMOGetName(REFCLSID clsidDMO, WCHAR name[])
return S_FALSE; return S_FALSE;
} }
static HRESULT dup_partial_mediatype(const DMO_PARTIAL_MEDIATYPE *types, DWORD count, DMO_PARTIAL_MEDIATYPE **ret)
{
*ret = NULL;
if (count == 0)
return S_OK;
*ret = HeapAlloc(GetProcessHeap(), 0, count*sizeof(*types));
if (!*ret)
return E_OUTOFMEMORY;
memcpy(*ret, types, count*sizeof(*types));
return S_OK;
}
/************************************************************************** /**************************************************************************
* IEnumDMO_Constructor * IEnumDMO_Constructor
*/ */
...@@ -373,8 +388,7 @@ static HRESULT IEnumDMO_Constructor( ...@@ -373,8 +388,7 @@ static HRESULT IEnumDMO_Constructor(
IEnumDMO **obj) IEnumDMO **obj)
{ {
IEnumDMOImpl* lpedmo; IEnumDMOImpl* lpedmo;
HRESULT hr = S_OK; HRESULT hr;
UINT size;
LONG ret; LONG ret;
*obj = NULL; *obj = NULL;
...@@ -388,32 +402,16 @@ static HRESULT IEnumDMO_Constructor( ...@@ -388,32 +402,16 @@ static HRESULT IEnumDMO_Constructor(
lpedmo->index = -1; lpedmo->index = -1;
lpedmo->category = *guidCategory; lpedmo->category = *guidCategory;
lpedmo->dwFlags = dwFlags; lpedmo->dwFlags = dwFlags;
lpedmo->cInTypes = cInTypes;
lpedmo->cOutTypes = cOutTypes;
if (cInTypes > 0) hr = dup_partial_mediatype(pInTypes, cInTypes, &lpedmo->pInTypes);
{ if (FAILED(hr))
size = cInTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
lpedmo->pInTypes = HeapAlloc(GetProcessHeap(), 0, size);
if (!lpedmo->pInTypes)
{
hr = E_OUTOFMEMORY;
goto lerr; goto lerr;
}
memcpy(lpedmo->pInTypes, pInTypes, size);
lpedmo->cInTypes = cInTypes;
}
if (cOutTypes > 0) hr = dup_partial_mediatype(pOutTypes, cOutTypes, &lpedmo->pOutTypes);
{ if (FAILED(hr))
size = cOutTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
lpedmo->pOutTypes = HeapAlloc(GetProcessHeap(), 0, size);
if (!lpedmo->pOutTypes)
{
hr = E_OUTOFMEMORY;
goto lerr; goto lerr;
}
memcpy(lpedmo->pOutTypes, pOutTypes, size);
lpedmo->cOutTypes = cOutTypes;
}
/* If not filtering by category enum from media objects root */ /* If not filtering by category enum from media objects root */
if (IsEqualGUID(guidCategory, &GUID_NULL)) if (IsEqualGUID(guidCategory, &GUID_NULL))
...@@ -426,8 +424,7 @@ static HRESULT IEnumDMO_Constructor( ...@@ -426,8 +424,7 @@ static HRESULT IEnumDMO_Constructor(
WCHAR szguid[64]; WCHAR szguid[64];
WCHAR szKey[MAX_PATH]; WCHAR szKey[MAX_PATH];
wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories, wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories, GUIDToString(szguid, guidCategory));
GUIDToString(szguid, guidCategory));
if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey))) if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey)))
hr = HRESULT_FROM_WIN32(ret); hr = HRESULT_FROM_WIN32(ret);
} }
......
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