strmbase: COM cleanup for TransformFilter.

This commit is contained in:
Aric Stewart 2012-03-26 14:06:13 -05:00 committed by Alexandre Julliard
parent e49e32556d
commit f1c9bd444c
1 changed files with 64 additions and 34 deletions

View File

@ -46,13 +46,43 @@ static const IPinVtbl TransformFilter_InputPin_Vtbl;
static const IPinVtbl TransformFilter_OutputPin_Vtbl;
static const IQualityControlVtbl TransformFilter_QualityControl_Vtbl;
static inline BaseInputPin *impl_BaseInputPin_from_BasePin( BasePin *iface )
{
return CONTAINING_RECORD(iface, BaseInputPin, pin);
}
static inline BasePin *impl_BasePin_from_IPin( IPin *iface )
{
return CONTAINING_RECORD(iface, BasePin, IPin_iface);
}
static inline BaseInputPin *impl_BaseInputPin_from_IPin( IPin *iface )
{
return CONTAINING_RECORD(iface, BaseInputPin, pin.IPin_iface);
}
static inline BaseOutputPin *impl_BaseOutputPin_from_IPin( IPin *iface )
{
return CONTAINING_RECORD(iface, BaseOutputPin, pin.IPin_iface);
}
static inline TransformFilter *impl_from_IBaseFilter( IBaseFilter *iface )
{
return CONTAINING_RECORD(iface, TransformFilter, filter.IBaseFilter_iface);
}
static inline TransformFilter *impl_from_BaseFilter( BaseFilter *iface )
{
return CONTAINING_RECORD(iface, TransformFilter, filter);
}
static HRESULT WINAPI TransformFilter_Input_CheckMediaType(BasePin *iface, const AM_MEDIA_TYPE * pmt)
{
BaseInputPin* This = (BaseInputPin*) iface;
BaseInputPin* This = impl_BaseInputPin_from_BasePin(iface);
TransformFilter * pTransform;
TRACE("%p\n", iface);
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
if (pTransform->pFuncsTable->pfnCheckInputType)
return pTransform->pFuncsTable->pfnCheckInputType(pTransform, pmt);
@ -66,7 +96,7 @@ static HRESULT WINAPI TransformFilter_Input_Receive(BaseInputPin *This, IMediaSa
HRESULT hr = S_FALSE;
TransformFilter * pTransform;
TRACE("%p\n", This);
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
EnterCriticalSection(&pTransform->csReceive);
if (pTransform->filter.state == State_Stopped)
@ -92,8 +122,8 @@ static HRESULT WINAPI TransformFilter_Input_Receive(BaseInputPin *This, IMediaSa
static HRESULT WINAPI TransformFilter_Output_QueryAccept(IPin *iface, const AM_MEDIA_TYPE * pmt)
{
BasePin *This = (BasePin *)iface;
TransformFilter *pTransformFilter = (TransformFilter *)This->pinInfo.pFilter;
BasePin *This = impl_BasePin_from_IPin(iface);
TransformFilter *pTransformFilter = impl_from_IBaseFilter(This->pinInfo.pFilter);
AM_MEDIA_TYPE* outpmt = &pTransformFilter->pmt;
TRACE("%p\n", iface);
@ -105,13 +135,13 @@ static HRESULT WINAPI TransformFilter_Output_QueryAccept(IPin *iface, const AM_M
static HRESULT WINAPI TransformFilter_Output_DecideBufferSize(BaseOutputPin *This, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
{
TransformFilter *pTransformFilter = (TransformFilter *)This->pin.pinInfo.pFilter;
TransformFilter *pTransformFilter = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
return pTransformFilter->pFuncsTable->pfnDecideBufferSize(pTransformFilter, pAlloc, ppropInputRequest);
}
static HRESULT WINAPI TransformFilter_Output_GetMediaType(BasePin *This, int iPosition, AM_MEDIA_TYPE *pmt)
{
TransformFilter *pTransform = (TransformFilter *)This->pinInfo.pFilter;
TransformFilter *pTransform = impl_from_IBaseFilter(This->pinInfo.pFilter);
if (iPosition < 0)
return E_INVALIDARG;
@ -123,7 +153,7 @@ static HRESULT WINAPI TransformFilter_Output_GetMediaType(BasePin *This, int iPo
static IPin* WINAPI TransformFilter_GetPin(BaseFilter *iface, int pos)
{
TransformFilter *This = (TransformFilter *)iface;
TransformFilter *This = impl_from_BaseFilter(iface);
if (pos >= This->npins || pos < 0)
return NULL;
@ -134,7 +164,7 @@ static IPin* WINAPI TransformFilter_GetPin(BaseFilter *iface, int pos)
static LONG WINAPI TransformFilter_GetPinCount(BaseFilter *iface)
{
TransformFilter *This = (TransformFilter *)iface;
TransformFilter *This = impl_from_BaseFilter(iface);
return (This->npins+1);
}
@ -188,10 +218,10 @@ static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* p
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = (IBaseFilter *)pTransformFilter;
piInput.pFilter = &pTransformFilter->filter.IBaseFilter_iface;
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = (IBaseFilter *)pTransformFilter;
piOutput.pFilter = &pTransformFilter->filter.IBaseFilter_iface;
lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
hr = BaseInputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, &tf_input_BaseFuncTable, &tf_input_BaseInputFuncTable, &pTransformFilter->filter.csFilter, NULL, &pTransformFilter->ppPins[0]);
@ -203,14 +233,14 @@ static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* p
if (FAILED(hr))
ERR("Cannot create output pin (%x)\n", hr);
else {
QualityControlImpl_init(&pTransformFilter->qcimpl, (IPin*)pTransformFilter->ppPins[0], (IBaseFilter*)pTransformFilter);
QualityControlImpl_init(&pTransformFilter->qcimpl, pTransformFilter->ppPins[0], &pTransformFilter->filter.IBaseFilter_iface);
pTransformFilter->qcimpl.lpVtbl = &TransformFilter_QualityControl_Vtbl;
}
}
if (FAILED(hr))
{
CoTaskMemFree(pTransformFilter->ppPins);
BaseFilterImpl_Release((IBaseFilter*)pTransformFilter);
BaseFilterImpl_Release(&pTransformFilter->filter.IBaseFilter_iface);
}
return hr;
@ -244,7 +274,7 @@ HRESULT TransformFilter_Construct(const IBaseFilterVtbl *pVtbl, LONG filter_size
HRESULT WINAPI TransformFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
{
HRESULT hr;
TransformFilter *This = (TransformFilter *)iface;
TransformFilter *This = impl_from_IBaseFilter(iface);
TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_guid(riid), ppv);
if (IsEqualIID(riid, &IID_IQualityControl)) {
@ -263,7 +293,7 @@ HRESULT WINAPI TransformFilterImpl_QueryInterface(IBaseFilter * iface, REFIID ri
ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface)
{
TransformFilter *This = (TransformFilter *)iface;
TransformFilter *This = impl_from_IBaseFilter(iface);
ULONG refCount = BaseFilterImpl_Release(iface);
TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
@ -304,7 +334,7 @@ ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface)
HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface)
{
TransformFilter *This = (TransformFilter *)iface;
TransformFilter *This = impl_from_IBaseFilter(iface);
HRESULT hr = S_OK;
TRACE("(%p/%p)\n", This, iface);
@ -322,7 +352,7 @@ HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface)
HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface)
{
TransformFilter *This = (TransformFilter *)iface;
TransformFilter *This = impl_from_IBaseFilter(iface);
HRESULT hr;
TRACE("(%p/%p)->()\n", This, iface);
@ -345,7 +375,7 @@ HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface)
HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
{
HRESULT hr = S_OK;
TransformFilter *This = (TransformFilter *)iface;
TransformFilter *This = impl_from_IBaseFilter(iface);
TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
@ -353,11 +383,11 @@ HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStar
{
if (This->filter.state == State_Stopped)
{
((BaseInputPin *)This->ppPins[0])->end_of_stream = 0;
impl_BaseInputPin_from_IPin(This->ppPins[0])->end_of_stream = 0;
if (This->pFuncsTable->pfnStartStreaming)
hr = This->pFuncsTable->pfnStartStreaming(This);
if (SUCCEEDED(hr))
hr = BaseOutputPinImpl_Active((BaseOutputPin *)This->ppPins[1]);
hr = BaseOutputPinImpl_Active(impl_BaseOutputPin_from_IPin(This->ppPins[1]));
}
if (SUCCEEDED(hr))
@ -375,7 +405,7 @@ HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStar
HRESULT WINAPI TransformFilterImpl_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
{
TransformFilter *This = (TransformFilter *)iface;
TransformFilter *This = impl_from_IBaseFilter(iface);
TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_w(Id), ppPin);
@ -403,7 +433,7 @@ static const IBaseFilterVtbl TransformFilter_Vtbl =
static HRESULT WINAPI TransformFilter_InputPin_EndOfStream(IPin * iface)
{
BaseInputPin* This = (BaseInputPin*) iface;
BaseInputPin* This = impl_BaseInputPin_from_IPin(iface);
TransformFilter* pTransform;
IPin* ppin;
HRESULT hr;
@ -411,7 +441,7 @@ static HRESULT WINAPI TransformFilter_InputPin_EndOfStream(IPin * iface)
TRACE("(%p)->()\n", iface);
/* Since we process samples synchronously, just forward notification downstream */
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
if (!pTransform)
hr = E_FAIL;
else
@ -429,13 +459,13 @@ static HRESULT WINAPI TransformFilter_InputPin_EndOfStream(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
{
BaseInputPin* This = (BaseInputPin*) iface;
BaseInputPin* This = impl_BaseInputPin_from_IPin(iface);
TransformFilter* pTransform;
HRESULT hr = S_OK;
TRACE("(%p)->(%p, %p)\n", iface, pReceivePin, pmt);
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
if (pTransform->pFuncsTable->pfnSetMediaType)
hr = pTransform->pFuncsTable->pfnSetMediaType(pTransform, PINDIR_INPUT, pmt);
@ -455,12 +485,12 @@ static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, I
static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface)
{
BaseInputPin* This = (BaseInputPin*) iface;
BaseInputPin* This = impl_BaseInputPin_from_IPin(iface);
TransformFilter* pTransform;
TRACE("(%p)->()\n", iface);
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
if (pTransform->pFuncsTable->pfnBreakConnect)
pTransform->pFuncsTable->pfnBreakConnect(pTransform, PINDIR_INPUT);
@ -469,13 +499,13 @@ static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_BeginFlush(IPin * iface)
{
BaseInputPin* This = (BaseInputPin*) iface;
BaseInputPin* This = impl_BaseInputPin_from_IPin(iface);
TransformFilter* pTransform;
HRESULT hr = S_OK;
TRACE("(%p)->()\n", iface);
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
EnterCriticalSection(&pTransform->filter.csFilter);
if (pTransform->pFuncsTable->pfnBeginFlush)
hr = pTransform->pFuncsTable->pfnBeginFlush(pTransform);
@ -487,13 +517,13 @@ static HRESULT WINAPI TransformFilter_InputPin_BeginFlush(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_EndFlush(IPin * iface)
{
BaseInputPin* This = (BaseInputPin*) iface;
BaseInputPin* This = impl_BaseInputPin_from_IPin(iface);
TransformFilter* pTransform;
HRESULT hr = S_OK;
TRACE("(%p)->()\n", iface);
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
EnterCriticalSection(&pTransform->filter.csFilter);
if (pTransform->pFuncsTable->pfnEndFlush)
hr = pTransform->pFuncsTable->pfnEndFlush(pTransform);
@ -505,13 +535,13 @@ static HRESULT WINAPI TransformFilter_InputPin_EndFlush(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
BaseInputPin* This = (BaseInputPin*) iface;
BaseInputPin* This = impl_BaseInputPin_from_IPin(iface);
TransformFilter* pTransform;
HRESULT hr = S_OK;
TRACE("(%p)->()\n", iface);
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
pTransform = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
EnterCriticalSection(&pTransform->filter.csFilter);
if (pTransform->pFuncsTable->pfnNewSegment)
hr = pTransform->pFuncsTable->pfnNewSegment(pTransform, tStart, tStop, dRate);
@ -567,7 +597,7 @@ static const IPinVtbl TransformFilter_OutputPin_Vtbl =
static HRESULT WINAPI TransformFilter_QualityControlImpl_Notify(IQualityControl *iface, IBaseFilter *sender, Quality qm) {
QualityControlImpl *qc = (QualityControlImpl*)iface;
TransformFilter *This = (TransformFilter *)qc->self;
TransformFilter *This = impl_from_IBaseFilter(qc->self);
if (This->pFuncsTable->pfnNotify)
return This->pFuncsTable->pfnNotify(This, sender, qm);