Fixed qcap's inherited enummedia bugs.
This commit is contained in:
parent
ff87ad7ab1
commit
012b4538b6
|
@ -38,13 +38,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(qcap);
|
|||
HRESULT CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc)
|
||||
{
|
||||
memcpy(pDest, pSrc, sizeof(AM_MEDIA_TYPE));
|
||||
if (!pSrc->pbFormat) return S_OK;
|
||||
if (!(pDest->pbFormat = CoTaskMemAlloc(pSrc->cbFormat)))
|
||||
return E_OUTOFMEMORY;
|
||||
memcpy(pDest->pbFormat, pSrc->pbFormat, pSrc->cbFormat);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void DeleteMediaType(AM_MEDIA_TYPE * pMediaType)
|
||||
void FreeMediaType(AM_MEDIA_TYPE * pMediaType)
|
||||
{
|
||||
if (pMediaType->pbFormat)
|
||||
{
|
||||
|
@ -58,6 +59,12 @@ void DeleteMediaType(AM_MEDIA_TYPE * pMediaType)
|
|||
}
|
||||
}
|
||||
|
||||
void DeleteMediaType(AM_MEDIA_TYPE * pMediaType)
|
||||
{
|
||||
FreeMediaType(pMediaType);
|
||||
CoTaskMemFree(pMediaType);
|
||||
}
|
||||
|
||||
BOOL CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2,
|
||||
BOOL bWildcards)
|
||||
{
|
||||
|
@ -110,7 +117,11 @@ HRESULT IEnumMediaTypesImpl_Construct(const ENUMMEDIADETAILS * pDetails,
|
|||
pEnumMediaTypes->enumMediaDetails.pMediaTypes =
|
||||
CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * pDetails->cMediaTypes);
|
||||
for (i = 0; i < pDetails->cMediaTypes; i++)
|
||||
pEnumMediaTypes->enumMediaDetails.pMediaTypes[i] = pDetails->pMediaTypes[i];
|
||||
if (FAILED(CopyMediaType(&pEnumMediaTypes->enumMediaDetails.pMediaTypes[i], &pDetails->pMediaTypes[i]))) {
|
||||
while (i--) CoTaskMemFree(pEnumMediaTypes->enumMediaDetails.pMediaTypes[i].pbFormat);
|
||||
CoTaskMemFree(pEnumMediaTypes->enumMediaDetails.pMediaTypes);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
*ppEnum = (IEnumMediaTypes *)(&pEnumMediaTypes->lpVtbl);
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -158,12 +169,14 @@ static ULONG WINAPI IEnumMediaTypesImpl_Release(IEnumMediaTypes * iface)
|
|||
|
||||
if (!refCount)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < This->enumMediaDetails.cMediaTypes; i++)
|
||||
if (This->enumMediaDetails.pMediaTypes[i].pbFormat)
|
||||
CoTaskMemFree(This->enumMediaDetails.pMediaTypes[i].pbFormat);
|
||||
CoTaskMemFree(This->enumMediaDetails.pMediaTypes);
|
||||
CoTaskMemFree(This);
|
||||
ObjectRefCount(FALSE);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return refCount;
|
||||
}
|
||||
|
||||
|
@ -186,7 +199,13 @@ static HRESULT WINAPI IEnumMediaTypesImpl_Next(IEnumMediaTypes * iface,
|
|||
ULONG i;
|
||||
*ppMediaTypes = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * cFetched);
|
||||
for (i = 0; i < cFetched; i++)
|
||||
(*ppMediaTypes)[i] = This->enumMediaDetails.pMediaTypes[This->uIndex + i];
|
||||
if (FAILED(CopyMediaType(&(*ppMediaTypes)[i], &This->enumMediaDetails.pMediaTypes[This->uIndex + i]))) {
|
||||
while (i--)
|
||||
CoTaskMemFree((*ppMediaTypes)[i].pbFormat);
|
||||
CoTaskMemFree(*ppMediaTypes);
|
||||
*ppMediaTypes = NULL;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if ((cMediaTypes != 1) || pcFetched)
|
||||
|
|
Loading…
Reference in New Issue