Fixed clock release in transform template.

AddRef pUnk in CopyMediaType.
Added CreateMediaType helper function and use it.
Replaced some DeleteMediaType calls to FreeMediaType to be in line
with recent changes.
Fixed IEnumMediaTypesImpl_Next.
Clear media type when initializing pins.
Added some AddRef/Release traces.
This commit is contained in:
Christian Costa 2005-06-05 19:18:34 +00:00 committed by Alexandre Julliard
parent 2f5aee99f1
commit 623fb34acc
6 changed files with 42 additions and 19 deletions

View File

@ -211,7 +211,7 @@ static HRESULT ACMWrapper_ConnectInput(TransformFilterImpl* pTransformFilter, co
}
else
FIXME("acmStreamOpen returned %d\n", res);
DeleteMediaType(outpmt);
FreeMediaType(outpmt);
TRACE("Unable to find a suitable ACM decompressor\n");
}

View File

@ -31,6 +31,8 @@ HRESULT CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc)
if (!(pDest->pbFormat = CoTaskMemAlloc(pSrc->cbFormat)))
return E_OUTOFMEMORY;
memcpy(pDest->pbFormat, pSrc->pbFormat, pSrc->cbFormat);
if (pDest->pUnk)
IUnknown_AddRef(pDest->pUnk);
return S_OK;
}
@ -48,13 +50,29 @@ void FreeMediaType(AM_MEDIA_TYPE * pMediaType)
}
}
AM_MEDIA_TYPE * CreateMediaType(AM_MEDIA_TYPE const * pSrc)
{
AM_MEDIA_TYPE * pDest;
pDest = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
if (!pDest)
return NULL;
if (FAILED(CopyMediaType(pDest, pSrc)))
{
CoTaskMemFree(pDest);
return NULL;
}
return pDest;
}
void DeleteMediaType(AM_MEDIA_TYPE * pMediaType)
{
FreeMediaType(pMediaType);
CoTaskMemFree(pMediaType);
}
BOOL CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, BOOL bWildcards)
{
TRACE("pmt1: ");
@ -98,7 +116,8 @@ HRESULT IEnumMediaTypesImpl_Construct(const ENUMMEDIADETAILS * pDetails, IEnumMe
pEnumMediaTypes->enumMediaDetails.cMediaTypes = pDetails->cMediaTypes;
pEnumMediaTypes->enumMediaDetails.pMediaTypes = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * pDetails->cMediaTypes);
for (i = 0; i < pDetails->cMediaTypes; i++)
if (FAILED(CopyMediaType(&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);
@ -135,7 +154,7 @@ static ULONG WINAPI IEnumMediaTypesImpl_AddRef(IEnumMediaTypes * iface)
IEnumMediaTypesImpl *This = (IEnumMediaTypesImpl *)iface;
ULONG refCount = InterlockedIncrement(&This->refCount);
TRACE("()\n");
TRACE("(%p)->() AddRef from %ld\n", iface, refCount - 1);
return refCount;
}
@ -145,7 +164,7 @@ static ULONG WINAPI IEnumMediaTypesImpl_Release(IEnumMediaTypes * iface)
IEnumMediaTypesImpl *This = (IEnumMediaTypesImpl *)iface;
ULONG refCount = InterlockedDecrement(&This->refCount);
TRACE("()\n");
TRACE("(%p)->() Release from %ld\n", iface, refCount + 1);
if (!refCount)
{
@ -172,13 +191,12 @@ static HRESULT WINAPI IEnumMediaTypesImpl_Next(IEnumMediaTypes * iface, ULONG cM
if (cFetched > 0)
{
ULONG i;
*ppMediaTypes = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * cFetched);
for (i = 0; i < cFetched; i++)
if (FAILED(CopyMediaType(&(*ppMediaTypes)[i], &This->enumMediaDetails.pMediaTypes[This->uIndex + i]))) {
if (!(ppMediaTypes[i] = CreateMediaType(&This->enumMediaDetails.pMediaTypes[This->uIndex + i])))
{
while (i--)
CoTaskMemFree((*ppMediaTypes)[i].pbFormat);
CoTaskMemFree(*ppMediaTypes);
*ppMediaTypes = NULL;
DeleteMediaType(ppMediaTypes[i]);
*pcFetched = 0;
return E_OUTOFMEMORY;
}
}

View File

@ -821,7 +821,7 @@ static HRESULT FileAsyncReaderPin_ConnectSpecific(IPin * iface, IPin * pReceiveP
{
IPin_Release(This->pin.pConnectedTo);
This->pin.pConnectedTo = NULL;
DeleteMediaType(&This->pin.mtCurrent);
FreeMediaType(&This->pin.mtCurrent);
}
TRACE(" -- %lx\n", hr);

View File

@ -596,13 +596,13 @@ static ULONG WINAPI Parser_OutputPin_Release(IPin * iface)
Parser_OutputPin *This = (Parser_OutputPin *)iface;
ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount);
TRACE("()\n");
TRACE("(%p)->() Release from %ld\n", iface, refCount + 1);
if (!refCount)
{
DeleteMediaType(This->pmt);
FreeMediaType(This->pmt);
CoTaskMemFree(This->pmt);
DeleteMediaType(&This->pin.pin.mtCurrent);
FreeMediaType(&This->pin.pin.mtCurrent);
CoTaskMemFree(This);
return 0;
}

View File

@ -107,7 +107,7 @@ static HRESULT OutputPin_ConnectSpecific(IPin * iface, IPin * pReceivePin, const
{
IPin_Release(This->pin.pConnectedTo);
This->pin.pConnectedTo = NULL;
DeleteMediaType(&This->pin.mtCurrent);
FreeMediaType(&This->pin.mtCurrent);
}
TRACE(" -- %lx\n", hr);
@ -154,6 +154,7 @@ HRESULT InputPin_Init(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPVOID
pPinImpl->pin.pUserData = pUserData;
pPinImpl->pin.pCritSec = pCritSec;
Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo);
ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE));
/* Input pin attributes */
pPinImpl->fnSampleProc = pSampleProc;
@ -177,6 +178,7 @@ HRESULT OutputPin_Init(const PIN_INFO * pPinInfo, ALLOCATOR_PROPERTIES * props,
pPinImpl->pin.pUserData = pUserData;
pPinImpl->pin.pCritSec = pCritSec;
Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo);
ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE));
/* Output pin attributes */
pPinImpl->pMemInputPin = NULL;
@ -410,7 +412,7 @@ ULONG WINAPI InputPin_Release(IPin * iface)
if (!refCount)
{
DeleteMediaType(&This->pin.mtCurrent);
FreeMediaType(&This->pin.mtCurrent);
if (This->pAllocator)
IMemAllocator_Release(This->pAllocator);
CoTaskMemFree(This);
@ -665,11 +667,11 @@ ULONG WINAPI OutputPin_Release(IPin * iface)
OutputPin *This = (OutputPin *)iface;
ULONG refCount = InterlockedDecrement(&This->pin.refCount);
TRACE("(%p/%p)->()\n", This, iface);
TRACE("(%p)->() Release from %ld\n", iface, refCount + 1);
if (!refCount)
{
DeleteMediaType(&This->pin.mtCurrent);
FreeMediaType(&This->pin.mtCurrent);
CoTaskMemFree(This);
return 0;
}
@ -1015,6 +1017,7 @@ HRESULT PullPin_Init(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPVOID p
pPinImpl->pin.pUserData = pUserData;
pPinImpl->pin.pCritSec = pCritSec;
Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo);
ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE));
/* Input pin attributes */
pPinImpl->fnSampleProc = pSampleProc;

View File

@ -275,6 +275,8 @@ static ULONG WINAPI TransformFilter_Release(IBaseFilter * iface)
ULONG i;
DeleteCriticalSection(&This->csFilter);
if (This->pClock)
IReferenceClock_Release(This->pClock);
for (i = 0; i < 2; i++)