From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/strmbase/pin.c | 68 +++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 42 deletions(-)
diff --git a/dlls/strmbase/pin.c b/dlls/strmbase/pin.c index 2fa0b9a4ec9..c60deede50e 100644 --- a/dlls/strmbase/pin.c +++ b/dlls/strmbase/pin.c @@ -728,26 +728,24 @@ HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(BaseOutputPin *This, IPin *pR return hr; }
-static HRESULT OutputPin_Init(const IPinVtbl *OutputPin_Vtbl, const PIN_INFO * pPinInfo, const BaseOutputPinFuncTable* vtbl, LPCRITICAL_SECTION pCritSec, BaseOutputPin * pPinImpl) +static void strmbase_pin_init(BasePin *pin, const IPinVtbl *vtbl, + const BasePinFuncTable *func_table, const PIN_INFO *info, CRITICAL_SECTION *cs) { - TRACE("(%p)\n", pPinImpl); + memset(pin, 0, sizeof(*pin)); + pin->IPin_iface.lpVtbl = vtbl; + pin->refCount = 1; + pin->pCritSec = cs; + pin->dRate = 1.0; + Copy_PinInfo(&pin->pinInfo, info); + pin->pFuncsTable = func_table; +}
- /* Common attributes */ - pPinImpl->pin.IPin_iface.lpVtbl = OutputPin_Vtbl; - pPinImpl->pin.refCount = 1; - pPinImpl->pin.pConnectedTo = NULL; - pPinImpl->pin.pCritSec = pCritSec; - pPinImpl->pin.tStart = 0; - pPinImpl->pin.tStop = 0; - pPinImpl->pin.dRate = 1.0; - Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo); - pPinImpl->pin.pFuncsTable = &vtbl->base; - ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE)); - - /* Output pin attributes */ - pPinImpl->pMemInputPin = NULL; - pPinImpl->pAllocator = NULL; - pPinImpl->pFuncsTable = vtbl; +static HRESULT OutputPin_Init(const IPinVtbl *vtbl, const PIN_INFO *info, + const BaseOutputPinFuncTable *func_table, CRITICAL_SECTION *cs, BaseOutputPin *pin) +{ + memset(pin, 0, sizeof(*pin)); + strmbase_pin_init(&pin->pin, vtbl, &func_table->base, info, cs); + pin->pFuncsTable = func_table;
return S_OK; } @@ -1111,31 +1109,17 @@ static const IMemInputPinVtbl MemInputPin_Vtbl = MemInputPin_ReceiveCanBlock };
-static HRESULT InputPin_Init(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, - const BaseInputPinFuncTable* vtbl, - LPCRITICAL_SECTION pCritSec, IMemAllocator *allocator, BaseInputPin * pPinImpl) +static HRESULT InputPin_Init(const IPinVtbl *vtbl, const PIN_INFO *info, + const BaseInputPinFuncTable *func_table, CRITICAL_SECTION *cs, + IMemAllocator *allocator, BaseInputPin *pin) { - TRACE("(%p)\n", pPinImpl); - - /* Common attributes */ - pPinImpl->pin.refCount = 1; - pPinImpl->pin.pConnectedTo = NULL; - pPinImpl->pin.pCritSec = pCritSec; - pPinImpl->pin.tStart = 0; - pPinImpl->pin.tStop = 0; - pPinImpl->pin.dRate = 1.0; - Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo); - ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE)); - pPinImpl->pin.pFuncsTable = &vtbl->base; - - /* Input pin attributes */ - pPinImpl->pFuncsTable = vtbl; - pPinImpl->pAllocator = pPinImpl->preferred_allocator = allocator; - if (pPinImpl->preferred_allocator) - IMemAllocator_AddRef(pPinImpl->preferred_allocator); - pPinImpl->pin.IPin_iface.lpVtbl = InputPin_Vtbl; - pPinImpl->IMemInputPin_iface.lpVtbl = &MemInputPin_Vtbl; - pPinImpl->flushing = pPinImpl->end_of_stream = FALSE; + memset(pin, 0, sizeof(*pin)); + strmbase_pin_init(&pin->pin, vtbl, &func_table->base, info, cs); + pin->pFuncsTable = func_table; + pin->pAllocator = pin->preferred_allocator = allocator; + if (pin->preferred_allocator) + IMemAllocator_AddRef(pin->preferred_allocator); + pin->IMemInputPin_iface.lpVtbl = &MemInputPin_Vtbl;
return S_OK; }
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/strmbase/pin.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/dlls/strmbase/pin.c b/dlls/strmbase/pin.c index c60deede50e..6bc9927f69a 100644 --- a/dlls/strmbase/pin.c +++ b/dlls/strmbase/pin.c @@ -1109,9 +1109,9 @@ static const IMemInputPinVtbl MemInputPin_Vtbl = MemInputPin_ReceiveCanBlock };
-static HRESULT InputPin_Init(const IPinVtbl *vtbl, const PIN_INFO *info, - const BaseInputPinFuncTable *func_table, CRITICAL_SECTION *cs, - IMemAllocator *allocator, BaseInputPin *pin) +static void strmbase_sink_init(BaseInputPin *pin, const IPinVtbl *vtbl, + const PIN_INFO *info, const BaseInputPinFuncTable *func_table, CRITICAL_SECTION *cs, + IMemAllocator *allocator) { memset(pin, 0, sizeof(*pin)); strmbase_pin_init(&pin->pin, vtbl, &func_table->base, info, cs); @@ -1120,8 +1120,6 @@ static HRESULT InputPin_Init(const IPinVtbl *vtbl, const PIN_INFO *info, if (pin->preferred_allocator) IMemAllocator_AddRef(pin->preferred_allocator); pin->IMemInputPin_iface.lpVtbl = &MemInputPin_Vtbl; - - return S_OK; }
HRESULT BaseInputPin_Construct(const IPinVtbl *InputPin_Vtbl, LONG inputpin_size, const PIN_INFO * pPinInfo, @@ -1146,14 +1144,10 @@ HRESULT BaseInputPin_Construct(const IPinVtbl *InputPin_Vtbl, LONG inputpin_size if (!pPinImpl) return E_OUTOFMEMORY;
- if (SUCCEEDED(InputPin_Init(InputPin_Vtbl, pPinInfo, vtbl, pCritSec, allocator, pPinImpl))) - { - *ppPin = &pPinImpl->pin.IPin_iface; - return S_OK; - } + strmbase_sink_init(pPinImpl, InputPin_Vtbl, pPinInfo, vtbl, pCritSec, allocator);
- CoTaskMemFree(pPinImpl); - return E_FAIL; + *ppPin = &pPinImpl->pin.IPin_iface; + return S_OK; }
HRESULT WINAPI BaseInputPin_Destroy(BaseInputPin *This)
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/strmbase/pin.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/strmbase/pin.c b/dlls/strmbase/pin.c index 6bc9927f69a..688a5bcc186 100644 --- a/dlls/strmbase/pin.c +++ b/dlls/strmbase/pin.c @@ -1150,13 +1150,18 @@ HRESULT BaseInputPin_Construct(const IPinVtbl *InputPin_Vtbl, LONG inputpin_size return S_OK; }
+static void strmbase_sink_cleanup(BaseInputPin *pin) +{ + FreeMediaType(&pin->pin.mtCurrent); + if (pin->pAllocator) + IMemAllocator_Release(pin->pAllocator); + pin->pAllocator = NULL; + pin->pin.IPin_iface.lpVtbl = NULL; +} + HRESULT WINAPI BaseInputPin_Destroy(BaseInputPin *This) { - FreeMediaType(&This->pin.mtCurrent); - if (This->pAllocator) - IMemAllocator_Release(This->pAllocator); - This->pAllocator = NULL; - This->pin.IPin_iface.lpVtbl = NULL; + strmbase_sink_cleanup(This); CoTaskMemFree(This); return S_OK; }
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qcap/avico.c | 20 +++++++------------- dlls/strmbase/pin.c | 4 ++-- include/wine/strmbase.h | 3 +++ 3 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/dlls/qcap/avico.c b/dlls/qcap/avico.c index d257051b1ca..841db700d63 100644 --- a/dlls/qcap/avico.c +++ b/dlls/qcap/avico.c @@ -37,7 +37,7 @@ typedef struct { BaseFilter filter; IPersistPropertyBag IPersistPropertyBag_iface;
- BaseInputPin *in; + BaseInputPin sink; BaseOutputPin *out;
DWORD fcc_handler; @@ -183,7 +183,7 @@ static IPin *avi_compressor_get_pin(BaseFilter *iface, unsigned int index) AVICompressor *filter = impl_from_BaseFilter(iface);
if (index == 0) - return &filter->in->pin.IPin_iface; + return &filter->sink.pin.IPin_iface; else if (index == 1) return &filter->out->pin.IPin_iface; return NULL; @@ -196,8 +196,7 @@ static void avi_compressor_destroy(BaseFilter *iface) if (filter->hic) ICClose(filter->hic); heap_free(filter->videoinfo); - if (filter->in) - BaseInputPinImpl_Release(&filter->in->pin.IPin_iface); + strmbase_sink_cleanup(&filter->sink); if (filter->out) BaseOutputPinImpl_Release(&filter->out->pin.IPin_iface); strmbase_filter_cleanup(&filter->filter); @@ -484,7 +483,7 @@ static HRESULT WINAPI AVICompressorIn_Receive(BaseInputPin *base, IMediaSample * if((This->driver_flags & VIDCF_TEMPORAL) && !(This->driver_flags & VIDCF_FASTTEMPORALC)) FIXME("Unsupported temporal compression\n");
- src_videoinfo = (VIDEOINFOHEADER*)This->in->pin.mtCurrent.pbFormat; + src_videoinfo = (VIDEOINFOHEADER *)This->sink.pin.mtCurrent.pbFormat; This->videoinfo->bmiHeader.biSizeImage = This->max_frame_size; res = ICCompress(This->hic, sync_point ? ICCOMPRESS_KEYFRAME : 0, &This->videoinfo->bmiHeader, buf, &src_videoinfo->bmiHeader, ptr, 0, &comp_flags, This->frame_cnt, 0, 0, NULL, NULL); @@ -572,7 +571,7 @@ static HRESULT WINAPI AVICompressorOut_GetMediaType(BasePin *base, int iPosition amt->subtype = MEDIASUBTYPE_PCM; amt->bFixedSizeSamples = FALSE; amt->bTemporalCompression = (This->driver_flags & VIDCF_TEMPORAL) != 0; - amt->lSampleSize = This->in->pin.mtCurrent.lSampleSize; + amt->lSampleSize = This->sink.pin.mtCurrent.lSampleSize; amt->formattype = FORMAT_VideoInfo; amt->pUnk = NULL; amt->cbFormat = This->videoinfo_size; @@ -633,13 +632,8 @@ IUnknown* WINAPI QCAP_createAVICompressor(IUnknown *outer, HRESULT *phr) compressor->IPersistPropertyBag_iface.lpVtbl = &PersistPropertyBagVtbl;
in_pin_info.pFilter = &compressor->filter.IBaseFilter_iface; - hres = BaseInputPin_Construct(&AVICompressorInputPinVtbl, sizeof(BaseInputPin), &in_pin_info, - &AVICompressorBaseInputPinVtbl, &compressor->filter.csFilter, NULL, (IPin**)&compressor->in); - if(FAILED(hres)) { - strmbase_filter_cleanup(&compressor->filter); - *phr = hres; - return NULL; - } + strmbase_sink_init(&compressor->sink, &AVICompressorInputPinVtbl, &in_pin_info, + &AVICompressorBaseInputPinVtbl, &compressor->filter.csFilter, NULL);
out_pin_info.pFilter = &compressor->filter.IBaseFilter_iface; hres = BaseOutputPin_Construct(&AVICompressorOutputPinVtbl, sizeof(BaseOutputPin), &out_pin_info, diff --git a/dlls/strmbase/pin.c b/dlls/strmbase/pin.c index 688a5bcc186..aa195c3dd2c 100644 --- a/dlls/strmbase/pin.c +++ b/dlls/strmbase/pin.c @@ -1109,7 +1109,7 @@ static const IMemInputPinVtbl MemInputPin_Vtbl = MemInputPin_ReceiveCanBlock };
-static void strmbase_sink_init(BaseInputPin *pin, const IPinVtbl *vtbl, +void strmbase_sink_init(BaseInputPin *pin, const IPinVtbl *vtbl, const PIN_INFO *info, const BaseInputPinFuncTable *func_table, CRITICAL_SECTION *cs, IMemAllocator *allocator) { @@ -1150,7 +1150,7 @@ HRESULT BaseInputPin_Construct(const IPinVtbl *InputPin_Vtbl, LONG inputpin_size return S_OK; }
-static void strmbase_sink_cleanup(BaseInputPin *pin) +void strmbase_sink_cleanup(BaseInputPin *pin) { FreeMediaType(&pin->pin.mtCurrent); if (pin->pAllocator) diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h index 2833f5e941f..8c6123c16b6 100644 --- a/include/wine/strmbase.h +++ b/include/wine/strmbase.h @@ -151,6 +151,9 @@ HRESULT BaseInputPin_Construct(const IPinVtbl *InputPin_Vtbl, LONG inputpin_size const BaseInputPinFuncTable* pBaseInputFuncsTable, LPCRITICAL_SECTION pCritSec, IMemAllocator *, IPin ** ppPin); HRESULT WINAPI BaseInputPin_Destroy(BaseInputPin *This); +void strmbase_sink_init(BaseInputPin *pin, const IPinVtbl *vtbl, const PIN_INFO *info, + const BaseInputPinFuncTable *func_table, CRITICAL_SECTION *cs, IMemAllocator *allocator); +void strmbase_sink_cleanup(BaseInputPin *pin);
typedef struct BaseFilter {
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qcap/smartteefilter.c | 49 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-)
diff --git a/dlls/qcap/smartteefilter.c b/dlls/qcap/smartteefilter.c index 02503ecb789..69341af8fdd 100644 --- a/dlls/qcap/smartteefilter.c +++ b/dlls/qcap/smartteefilter.c @@ -37,7 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(qcap);
typedef struct { BaseFilter filter; - BaseInputPin *input; + BaseInputPin sink; BaseOutputPin *capture; BaseOutputPin *preview; } SmartTeeFilter; @@ -91,7 +91,7 @@ static HRESULT WINAPI SmartTeeFilter_Run(IBaseFilter *iface, REFERENCE_TIME tSta /* We share an allocator among all pins, an allocator can only get committed * once, state transitions occur in upstream order, and only output pins * commit allocators, so let the filter attached to the input pin worry about it. */ - if (This->input->pin.pConnectedTo) + if (This->sink.pin.pConnectedTo) This->filter.state = State_Running; else hr = VFW_E_NOT_CONNECTED; @@ -123,7 +123,7 @@ static IPin *smart_tee_get_pin(BaseFilter *iface, unsigned int index) SmartTeeFilter *filter = impl_from_BaseFilter(iface);
if (index == 0) - return &filter->input->pin.IPin_iface; + return &filter->sink.pin.IPin_iface; else if (index == 1) return &filter->capture->pin.IPin_iface; else if (index == 2) @@ -135,8 +135,7 @@ static void smart_tee_destroy(BaseFilter *iface) { SmartTeeFilter *filter = impl_from_BaseFilter(iface);
- if (filter->input) - BaseInputPinImpl_Release(&filter->input->pin.IPin_iface); + strmbase_sink_cleanup(&filter->sink); if (filter->capture) BaseOutputPinImpl_Release(&filter->capture->pin.IPin_iface); if (filter->preview) @@ -204,10 +203,12 @@ static HRESULT WINAPI SmartTeeFilterInput_GetMediaType(BasePin *base, int iPosit if (iPosition) return S_FALSE; EnterCriticalSection(&This->filter.csFilter); - if (This->input->pin.pConnectedTo) { - CopyMediaType(amt, &This->input->pin.mtCurrent); + if (This->sink.pin.pConnectedTo) + { + CopyMediaType(amt, &This->sink.pin.mtCurrent); hr = S_OK; - } else + } + else hr = S_FALSE; LeaveCriticalSection(&This->filter.csFilter); return hr; @@ -360,9 +361,9 @@ static HRESULT WINAPI SmartTeeFilterCapture_EnumMediaTypes(IPin *iface, IEnumMed HRESULT hr; TRACE("(%p)->(%p)\n", This, ppEnum); EnterCriticalSection(&This->filter.csFilter); - if (This->input->pin.pConnectedTo) { + if (This->sink.pin.pConnectedTo) hr = BasePinImpl_EnumMediaTypes(iface, ppEnum); - } else + else hr = VFW_E_NOT_CONNECTED; LeaveCriticalSection(&This->filter.csFilter); return hr; @@ -400,7 +401,7 @@ static HRESULT WINAPI SmartTeeFilterCapture_GetMediaType(BasePin *base, int iPos SmartTeeFilter *This = impl_from_BasePin(base); TRACE("(%p, %d, %p)\n", This, iPosition, amt); if (iPosition == 0) { - CopyMediaType(amt, &This->input->pin.mtCurrent); + CopyMediaType(amt, &This->sink.pin.mtCurrent); return S_OK; } else return S_FALSE; @@ -410,9 +411,9 @@ static HRESULT WINAPI SmartTeeFilterCapture_DecideAllocator(BaseOutputPin *base, { SmartTeeFilter *This = impl_from_BasePin(&base->pin); TRACE("(%p, %p, %p)\n", This, pPin, pAlloc); - *pAlloc = This->input->pAllocator; - IMemAllocator_AddRef(This->input->pAllocator); - return IMemInputPin_NotifyAllocator(pPin, This->input->pAllocator, TRUE); + *pAlloc = This->sink.pAllocator; + IMemAllocator_AddRef(This->sink.pAllocator); + return IMemInputPin_NotifyAllocator(pPin, This->sink.pAllocator, TRUE); }
static const BaseOutputPinFuncTable SmartTeeFilterCaptureFuncs = { @@ -443,9 +444,9 @@ static HRESULT WINAPI SmartTeeFilterPreview_EnumMediaTypes(IPin *iface, IEnumMed HRESULT hr; TRACE("(%p)->(%p)\n", This, ppEnum); EnterCriticalSection(&This->filter.csFilter); - if (This->input->pin.pConnectedTo) { + if (This->sink.pin.pConnectedTo) hr = BasePinImpl_EnumMediaTypes(iface, ppEnum); - } else + else hr = VFW_E_NOT_CONNECTED; LeaveCriticalSection(&This->filter.csFilter); return hr; @@ -483,7 +484,7 @@ static HRESULT WINAPI SmartTeeFilterPreview_GetMediaType(BasePin *base, int iPos SmartTeeFilter *This = impl_from_BasePin(base); TRACE("(%p, %d, %p)\n", This, iPosition, amt); if (iPosition == 0) { - CopyMediaType(amt, &This->input->pin.mtCurrent); + CopyMediaType(amt, &This->sink.pin.mtCurrent); return S_OK; } else return S_FALSE; @@ -493,9 +494,9 @@ static HRESULT WINAPI SmartTeeFilterPreview_DecideAllocator(BaseOutputPin *base, { SmartTeeFilter *This = impl_from_BasePin(&base->pin); TRACE("(%p, %p, %p)\n", This, pPin, pAlloc); - *pAlloc = This->input->pAllocator; - IMemAllocator_AddRef(This->input->pAllocator); - return IMemInputPin_NotifyAllocator(pPin, This->input->pAllocator, TRUE); + *pAlloc = This->sink.pAllocator; + IMemAllocator_AddRef(This->sink.pAllocator); + return IMemInputPin_NotifyAllocator(pPin, This->sink.pAllocator, TRUE); }
static const BaseOutputPinFuncTable SmartTeeFilterPreviewFuncs = { @@ -526,12 +527,10 @@ IUnknown* WINAPI QCAP_createSmartTeeFilter(IUnknown *outer, HRESULT *phr) (DWORD_PTR)(__FILE__ ": SmartTeeFilter.csFilter"), &SmartTeeFilterFuncs);
inputPinInfo.pFilter = &This->filter.IBaseFilter_iface; - hr = BaseInputPin_Construct(&SmartTeeFilterInputVtbl, sizeof(BaseInputPin), &inputPinInfo, - &SmartTeeFilterInputFuncs, &This->filter.csFilter, NULL, (IPin**)&This->input); - if (FAILED(hr)) - goto end; + strmbase_sink_init(&This->sink, &SmartTeeFilterInputVtbl, &inputPinInfo, + &SmartTeeFilterInputFuncs, &This->filter.csFilter, NULL); hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER, - &IID_IMemAllocator, (void**)&This->input->pAllocator); + &IID_IMemAllocator, (void**)&This->sink.pAllocator); if (FAILED(hr)) goto end;