strmbase: Get rid of the "filterVtbl" parameter to TransformFilter_Construct().

Reordering some functions to avoid forward declarations.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-05-14 19:42:00 -05:00 committed by Alexandre Julliard
parent 38726831c4
commit 0f9e4cd660
6 changed files with 127 additions and 189 deletions

View File

@ -51,8 +51,6 @@ typedef struct ACMWrapperImpl
LONGLONG lasttime_sent;
} ACMWrapperImpl;
static const IBaseFilterVtbl ACMWrapper_Vtbl;
static inline ACMWrapperImpl *impl_from_TransformFilter( TransformFilter *iface )
{
return CONTAINING_RECORD(iface, ACMWrapperImpl, tf);
@ -389,7 +387,8 @@ HRESULT ACMWrapper_create(IUnknown * pUnkOuter, LPVOID * ppv)
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
hr = TransformFilter_Construct(&ACMWrapper_Vtbl, sizeof(ACMWrapperImpl), &CLSID_ACMWrapper, &ACMWrapper_FuncsTable, (IBaseFilter**)&This);
hr = strmbase_transform_create(sizeof(ACMWrapperImpl), &CLSID_ACMWrapper,
&ACMWrapper_FuncsTable, (IBaseFilter **)&This);
if (FAILED(hr))
return hr;
@ -399,22 +398,3 @@ HRESULT ACMWrapper_create(IUnknown * pUnkOuter, LPVOID * ppv)
return hr;
}
static const IBaseFilterVtbl ACMWrapper_Vtbl =
{
TransformFilterImpl_QueryInterface,
BaseFilterImpl_AddRef,
TransformFilterImpl_Release,
BaseFilterImpl_GetClassID,
TransformFilterImpl_Stop,
TransformFilterImpl_Pause,
TransformFilterImpl_Run,
BaseFilterImpl_GetState,
BaseFilterImpl_SetSyncSource,
BaseFilterImpl_GetSyncSource,
BaseFilterImpl_EnumPins,
BaseFilterImpl_FindPin,
BaseFilterImpl_QueryFilterInfo,
BaseFilterImpl_JoinFilterGraph,
BaseFilterImpl_QueryVendorInfo
};

View File

@ -50,8 +50,6 @@ typedef struct AVIDecImpl
REFERENCE_TIME late;
} AVIDecImpl;
static const IBaseFilterVtbl AVIDec_Vtbl;
static inline AVIDecImpl *impl_from_TransformFilter( TransformFilter *iface )
{
return CONTAINING_RECORD(iface, AVIDecImpl, tf);
@ -404,7 +402,8 @@ HRESULT AVIDec_create(IUnknown * pUnkOuter, LPVOID * ppv)
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
hr = TransformFilter_Construct(&AVIDec_Vtbl, sizeof(AVIDecImpl), &CLSID_AVIDec, &AVIDec_FuncsTable, (IBaseFilter**)&This);
hr = strmbase_transform_create(sizeof(AVIDecImpl), &CLSID_AVIDec,
&AVIDec_FuncsTable, (IBaseFilter **)&This);
if (FAILED(hr))
return hr;
@ -417,22 +416,3 @@ HRESULT AVIDec_create(IUnknown * pUnkOuter, LPVOID * ppv)
return hr;
}
static const IBaseFilterVtbl AVIDec_Vtbl =
{
TransformFilterImpl_QueryInterface,
BaseFilterImpl_AddRef,
TransformFilterImpl_Release,
BaseFilterImpl_GetClassID,
TransformFilterImpl_Stop,
TransformFilterImpl_Pause,
TransformFilterImpl_Run,
BaseFilterImpl_GetState,
BaseFilterImpl_SetSyncSource,
BaseFilterImpl_GetSyncSource,
BaseFilterImpl_EnumPins,
BaseFilterImpl_FindPin,
BaseFilterImpl_QueryFilterInfo,
BaseFilterImpl_JoinFilterGraph,
BaseFilterImpl_QueryVendorInfo
};

View File

@ -161,95 +161,7 @@ static const BaseOutputPinFuncTable tf_output_BaseOutputFuncTable = {
BaseOutputPinImpl_DecideAllocator,
};
static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* pClsid, const TransformFilterFuncTable* pFuncsTable, TransformFilter* pTransformFilter)
{
HRESULT hr;
PIN_INFO piInput;
PIN_INFO piOutput;
BaseFilter_Init(&pTransformFilter->filter, pVtbl, pClsid, (DWORD_PTR)(__FILE__ ": TransformFilter.csFilter"), &tfBaseFuncTable);
InitializeCriticalSection(&pTransformFilter->csReceive);
pTransformFilter->csReceive.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": TransformFilter.csReceive");
/* pTransformFilter is already allocated */
pTransformFilter->pFuncsTable = pFuncsTable;
ZeroMemory(&pTransformFilter->pmt, sizeof(pTransformFilter->pmt));
pTransformFilter->ppPins = CoTaskMemAlloc(2 * sizeof(IPin *));
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = &pTransformFilter->filter.IBaseFilter_iface;
lstrcpynW(piInput.achName, wcsInputPinName, ARRAY_SIZE(piInput.achName));
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = &pTransformFilter->filter.IBaseFilter_iface;
lstrcpynW(piOutput.achName, wcsOutputPinName, ARRAY_SIZE(piOutput.achName));
hr = BaseInputPin_Construct(&TransformFilter_InputPin_Vtbl, sizeof(BaseInputPin), &piInput,
&tf_input_BaseInputFuncTable, &pTransformFilter->filter.csFilter, NULL, &pTransformFilter->ppPins[0]);
if (SUCCEEDED(hr))
{
hr = BaseOutputPin_Construct(&TransformFilter_OutputPin_Vtbl, sizeof(BaseOutputPin), &piOutput, &tf_output_BaseOutputFuncTable, &pTransformFilter->filter.csFilter, &pTransformFilter->ppPins[1]);
if (FAILED(hr))
ERR("Cannot create output pin (%x)\n", hr);
else {
QualityControlImpl_Create( pTransformFilter->ppPins[0], &pTransformFilter->filter.IBaseFilter_iface, &pTransformFilter->qcimpl);
pTransformFilter->qcimpl->IQualityControl_iface.lpVtbl = &TransformFilter_QualityControl_Vtbl;
}
}
if (SUCCEEDED(hr))
{
ISeekingPassThru *passthru;
pTransformFilter->seekthru_unk = NULL;
hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown *)&pTransformFilter->filter.IBaseFilter_iface, CLSCTX_INPROC_SERVER,
&IID_IUnknown, (void **)&pTransformFilter->seekthru_unk);
if (SUCCEEDED(hr))
{
IUnknown_QueryInterface(pTransformFilter->seekthru_unk, &IID_ISeekingPassThru, (void**)&passthru);
ISeekingPassThru_Init(passthru, FALSE, pTransformFilter->ppPins[0]);
ISeekingPassThru_Release(passthru);
}
}
if (FAILED(hr))
{
CoTaskMemFree(pTransformFilter->ppPins);
BaseFilterImpl_Release(&pTransformFilter->filter.IBaseFilter_iface);
}
return hr;
}
HRESULT TransformFilter_Construct(const IBaseFilterVtbl *pVtbl, LONG filter_size, const CLSID* pClsid, const TransformFilterFuncTable* pFuncsTable, IBaseFilter ** ppTransformFilter)
{
TransformFilter* pTf;
*ppTransformFilter = NULL;
assert(filter_size >= sizeof(TransformFilter));
pTf = CoTaskMemAlloc(filter_size);
if (!pTf)
return E_OUTOFMEMORY;
ZeroMemory(pTf, filter_size);
if (SUCCEEDED(TransformFilter_Init(pVtbl, pClsid, pFuncsTable, pTf)))
{
*ppTransformFilter = &pTf->filter.IBaseFilter_iface;
return S_OK;
}
CoTaskMemFree(pTf);
return E_FAIL;
}
HRESULT WINAPI TransformFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
static HRESULT WINAPI TransformFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
{
HRESULT hr;
TransformFilter *This = impl_from_IBaseFilter(iface);
@ -274,7 +186,7 @@ HRESULT WINAPI TransformFilterImpl_QueryInterface(IBaseFilter * iface, REFIID ri
return hr;
}
ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface)
static ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface)
{
TransformFilter *This = impl_from_IBaseFilter(iface);
ULONG refCount = InterlockedDecrement(&This->filter.refCount);
@ -313,9 +225,7 @@ ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface)
return refCount;
}
/** IMediaFilter methods **/
HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface)
static HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter *iface)
{
TransformFilter *This = impl_from_IBaseFilter(iface);
HRESULT hr = S_OK;
@ -335,7 +245,7 @@ HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface)
return hr;
}
HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface)
static HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter *iface)
{
TransformFilter *This = impl_from_IBaseFilter(iface);
HRESULT hr;
@ -357,7 +267,7 @@ HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface)
return hr;
}
HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
static HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter *iface, REFERENCE_TIME tStart)
{
HRESULT hr = S_OK;
TransformFilter *This = impl_from_IBaseFilter(iface);
@ -386,6 +296,119 @@ HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStar
return hr;
}
static const IBaseFilterVtbl transform_vtbl =
{
TransformFilterImpl_QueryInterface,
BaseFilterImpl_AddRef,
TransformFilterImpl_Release,
BaseFilterImpl_GetClassID,
TransformFilterImpl_Stop,
TransformFilterImpl_Pause,
TransformFilterImpl_Run,
BaseFilterImpl_GetState,
BaseFilterImpl_SetSyncSource,
BaseFilterImpl_GetSyncSource,
BaseFilterImpl_EnumPins,
BaseFilterImpl_FindPin,
BaseFilterImpl_QueryFilterInfo,
BaseFilterImpl_JoinFilterGraph,
BaseFilterImpl_QueryVendorInfo
};
static HRESULT strmbase_transform_init(const CLSID *clsid,
const TransformFilterFuncTable *func_table, TransformFilter *filter)
{
HRESULT hr;
PIN_INFO piInput;
PIN_INFO piOutput;
BaseFilter_Init(&filter->filter, &transform_vtbl, clsid,
(DWORD_PTR)(__FILE__ ": TransformFilter.csFilter"), &tfBaseFuncTable);
InitializeCriticalSection(&filter->csReceive);
filter->csReceive.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": TransformFilter.csReceive");
/* pTransformFilter is already allocated */
filter->pFuncsTable = func_table;
ZeroMemory(&filter->pmt, sizeof(filter->pmt));
filter->ppPins = CoTaskMemAlloc(2 * sizeof(IPin *));
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = &filter->filter.IBaseFilter_iface;
lstrcpynW(piInput.achName, wcsInputPinName, ARRAY_SIZE(piInput.achName));
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = &filter->filter.IBaseFilter_iface;
lstrcpynW(piOutput.achName, wcsOutputPinName, ARRAY_SIZE(piOutput.achName));
hr = BaseInputPin_Construct(&TransformFilter_InputPin_Vtbl, sizeof(BaseInputPin), &piInput,
&tf_input_BaseInputFuncTable, &filter->filter.csFilter, NULL, &filter->ppPins[0]);
if (SUCCEEDED(hr))
{
hr = BaseOutputPin_Construct(&TransformFilter_OutputPin_Vtbl, sizeof(BaseOutputPin),
&piOutput, &tf_output_BaseOutputFuncTable, &filter->filter.csFilter,
&filter->ppPins[1]);
if (FAILED(hr))
ERR("Cannot create output pin (%x)\n", hr);
else {
QualityControlImpl_Create(filter->ppPins[0],
&filter->filter.IBaseFilter_iface, &filter->qcimpl);
filter->qcimpl->IQualityControl_iface.lpVtbl = &TransformFilter_QualityControl_Vtbl;
}
}
if (SUCCEEDED(hr))
{
ISeekingPassThru *passthru;
filter->seekthru_unk = NULL;
hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown *)&filter->filter.IBaseFilter_iface,
CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&filter->seekthru_unk);
if (SUCCEEDED(hr))
{
IUnknown_QueryInterface(filter->seekthru_unk, &IID_ISeekingPassThru, (void **)&passthru);
ISeekingPassThru_Init(passthru, FALSE, filter->ppPins[0]);
ISeekingPassThru_Release(passthru);
}
}
if (FAILED(hr))
{
CoTaskMemFree(filter->ppPins);
BaseFilterImpl_Release(&filter->filter.IBaseFilter_iface);
}
return hr;
}
HRESULT strmbase_transform_create(LONG filter_size, const CLSID *pClsid,
const TransformFilterFuncTable *pFuncsTable, IBaseFilter **ppTransformFilter)
{
TransformFilter* pTf;
*ppTransformFilter = NULL;
assert(filter_size >= sizeof(TransformFilter));
pTf = CoTaskMemAlloc(filter_size);
if (!pTf)
return E_OUTOFMEMORY;
ZeroMemory(pTf, filter_size);
if (SUCCEEDED(strmbase_transform_init(pClsid, pFuncsTable, pTf)))
{
*ppTransformFilter = &pTf->filter.IBaseFilter_iface;
return S_OK;
}
CoTaskMemFree(pTf);
return E_FAIL;
}
HRESULT WINAPI TransformFilterImpl_Notify(TransformFilter *iface, IBaseFilter *sender, Quality qm)
{
return QualityControlImpl_Notify((IQualityControl*)iface->qcimpl, sender, qm);

View File

@ -57,8 +57,6 @@ struct typeinfo {
const char *type;
};
static const IBaseFilterVtbl GSTTf_Vtbl;
static gboolean match_element(GstPluginFeature *feature, gpointer gdata)
{
struct typeinfo *data = (struct typeinfo*)gdata;
@ -497,7 +495,7 @@ static HRESULT Gstreamer_transform_create(IUnknown *punkouter, const CLSID *clsi
TRACE("%p, %p, %p, %p, %p\n", punkouter, clsid, name, vtbl, obj);
if (FAILED(TransformFilter_Construct(&GSTTf_Vtbl, sizeof(GstTfImpl), clsid, vtbl, (IBaseFilter**)&This)))
if (FAILED(strmbase_transform_create(sizeof(GstTfImpl), clsid, vtbl, (IBaseFilter **)&This)))
return E_OUTOFMEMORY;
This->gstreamer_name = name;
@ -1016,22 +1014,3 @@ IUnknown * CALLBACK Gstreamer_AudioConvert_create(IUnknown *punkouter, HRESULT *
return obj;
}
static const IBaseFilterVtbl GSTTf_Vtbl =
{
TransformFilterImpl_QueryInterface,
BaseFilterImpl_AddRef,
TransformFilterImpl_Release,
BaseFilterImpl_GetClassID,
TransformFilterImpl_Stop,
TransformFilterImpl_Pause,
TransformFilterImpl_Run,
BaseFilterImpl_GetState,
BaseFilterImpl_SetSyncSource,
BaseFilterImpl_GetSyncSource,
BaseFilterImpl_EnumPins,
BaseFilterImpl_FindPin,
BaseFilterImpl_QueryFilterInfo,
BaseFilterImpl_JoinFilterGraph,
BaseFilterImpl_QueryVendorInfo
};

View File

@ -154,8 +154,6 @@ static inline QTVDecoderImpl *impl_from_TransformFilter( TransformFilter *iface
return CONTAINING_RECORD(iface, QTVDecoderImpl, tf.filter);
}
static const IBaseFilterVtbl QTVDecoder_Vtbl;
static void trackingCallback(
void *decompressionTrackingRefCon,
OSStatus result,
@ -535,7 +533,8 @@ IUnknown * CALLBACK QTVDecoder_create(IUnknown * pUnkOuter, HRESULT* phr)
return NULL;
}
hr = TransformFilter_Construct(&QTVDecoder_Vtbl, sizeof(QTVDecoderImpl), &CLSID_QTVDecoder, &QTVDecoder_FuncsTable, (IBaseFilter**)&This);
hr = TransformFilter_Construct(sizeof(QTVDecoderImpl), &CLSID_QTVDecoder,
&QTVDecoder_FuncsTable, (IBaseFilter **)&This);
if (FAILED(hr))
{
@ -546,22 +545,3 @@ IUnknown * CALLBACK QTVDecoder_create(IUnknown * pUnkOuter, HRESULT* phr)
*phr = hr;
return (IUnknown*)This;
}
static const IBaseFilterVtbl QTVDecoder_Vtbl =
{
TransformFilterImpl_QueryInterface,
BaseFilterImpl_AddRef,
TransformFilterImpl_Release,
BaseFilterImpl_GetClassID,
TransformFilterImpl_Stop,
TransformFilterImpl_Pause,
TransformFilterImpl_Run,
BaseFilterImpl_GetState,
BaseFilterImpl_SetSyncSource,
BaseFilterImpl_GetSyncSource,
BaseFilterImpl_EnumPins,
BaseFilterImpl_FindPin,
BaseFilterImpl_QueryFilterInfo,
BaseFilterImpl_JoinFilterGraph,
BaseFilterImpl_QueryVendorInfo
};

View File

@ -245,14 +245,10 @@ typedef struct TransformFilterFuncTable {
TransformFilter_Notify pfnNotify;
} TransformFilterFuncTable;
HRESULT WINAPI TransformFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv);
ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface);
HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface);
HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface);
HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStart);
HRESULT WINAPI TransformFilterImpl_Notify(TransformFilter *iface, IBaseFilter *sender, Quality qm);
HRESULT TransformFilter_Construct( const IBaseFilterVtbl *filterVtbl, LONG filter_size, const CLSID* pClsid, const TransformFilterFuncTable* pFuncsTable, IBaseFilter ** ppTransformFilter);
HRESULT strmbase_transform_create(LONG filter_size, const CLSID *clsid,
const TransformFilterFuncTable *func_table, IBaseFilter **filter);
/* Source Seeking */
typedef HRESULT (WINAPI *SourceSeeking_ChangeRate)(IMediaSeeking *iface);