strmbase: Don't increment the pin reference count in filter_get_pin().

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-06-11 10:42:16 -04:00 committed by Alexandre Julliard
parent 6edee72560
commit 690838a0e0
13 changed files with 38 additions and 97 deletions

View File

@ -180,18 +180,13 @@ static const IBaseFilterVtbl AVICompressorVtbl = {
static IPin *avi_compressor_get_pin(BaseFilter *iface, unsigned int index)
{
AVICompressor *This = impl_from_BaseFilter(iface);
IPin *ret;
AVICompressor *filter = impl_from_BaseFilter(iface);
if (index == 0)
ret = &This->in->pin.IPin_iface;
return &filter->in->pin.IPin_iface;
else if (index == 1)
ret = &This->out->pin.IPin_iface;
else
return NULL;
IPin_AddRef(ret);
return ret;
return &filter->out->pin.IPin_iface;
return NULL;
}
static void avi_compressor_destroy(BaseFilter *iface)

View File

@ -118,19 +118,12 @@ static inline AviMux* impl_from_BaseFilter(BaseFilter *filter)
static IPin *avi_mux_get_pin(BaseFilter *iface, unsigned int index)
{
AviMux *This = impl_from_BaseFilter(iface);
AviMux *filter = impl_from_BaseFilter(iface);
if (!index)
{
IPin_AddRef(&This->out->pin.pin.IPin_iface);
return &This->out->pin.pin.IPin_iface;
}
else if (index <= This->input_pin_no)
{
IPin_AddRef(&This->in[index - 1]->pin.pin.IPin_iface);
return &This->in[index - 1]->pin.pin.IPin_iface;
}
return &filter->out->pin.pin.IPin_iface;
else if (index <= filter->input_pin_no)
return &filter->in[index - 1]->pin.pin.IPin_iface;
return NULL;
}

View File

@ -120,20 +120,15 @@ static const IBaseFilterVtbl SmartTeeFilterVtbl = {
static IPin *smart_tee_get_pin(BaseFilter *iface, unsigned int index)
{
SmartTeeFilter *This = impl_from_BaseFilter(iface);
IPin *ret;
SmartTeeFilter *filter = impl_from_BaseFilter(iface);
if (index == 0)
ret = &This->input->pin.IPin_iface;
return &filter->input->pin.IPin_iface;
else if (index == 1)
ret = &This->capture->pin.IPin_iface;
return &filter->capture->pin.IPin_iface;
else if (index == 2)
ret = &This->preview->pin.IPin_iface;
else
return NULL;
IPin_AddRef(ret);
return ret;
return &filter->preview->pin.IPin_iface;
return NULL;
}
static void smart_tee_destroy(BaseFilter *iface)

View File

@ -104,7 +104,6 @@ static IPin *vfw_capture_get_pin(BaseFilter *iface, unsigned int index)
if (index >= 1)
return NULL;
IPin_AddRef(This->pOutputPin);
return This->pOutputPin;
}

View File

@ -275,18 +275,13 @@ static void SampleGrabber_cleanup(SG_Impl *This)
static IPin *sample_grabber_get_pin(BaseFilter *iface, unsigned int index)
{
SG_Impl *This = impl_from_BaseFilter(iface);
IPin *pin;
SG_Impl *filter = impl_from_BaseFilter(iface);
if (index == 0)
pin = &This->pin_in.IPin_iface;
return &filter->pin_in.IPin_iface;
else if (index == 1)
pin = &This->pin_out.IPin_iface;
else
return NULL;
IPin_AddRef(pin);
return pin;
return &filter->pin_out.IPin_iface;
return NULL;
}
static void sample_grabber_destroy(BaseFilter *iface)

View File

@ -394,13 +394,11 @@ HRESULT GetClassMediaFile(IAsyncReader * pReader, LPCOLESTR pszFileName, GUID *
static IPin *async_reader_get_pin(BaseFilter *iface, unsigned int index)
{
AsyncReader *This = impl_from_BaseFilter(iface);
AsyncReader *filter = impl_from_BaseFilter(iface);
if (index >= 1 || !This->pOutputPin)
return NULL;
IPin_AddRef(This->pOutputPin);
return This->pOutputPin;
if (!index && filter->pOutputPin)
return filter->pOutputPin;
return NULL;
}
static void async_reader_destroy(BaseFilter *iface)

View File

@ -66,11 +66,9 @@ IPin *parser_get_pin(BaseFilter *iface, unsigned int index)
{
ParserImpl *filter = impl_from_BaseFilter(iface);
if (index > filter->cStreams)
return NULL;
IPin_AddRef(filter->ppPins[index]);
return filter->ppPins[index];
if (index <= filter->cStreams)
return filter->ppPins[index];
return NULL;
}
HRESULT Parser_Create(ParserImpl *pParser, const IBaseFilterVtbl *vtbl, IUnknown *outer,

View File

@ -60,10 +60,7 @@ HRESULT enum_pins_create(BaseFilter *base, IEnumPins **out)
object->Version = base->pin_version;
while ((pin = base->pFuncsTable->filter_get_pin(base, object->count)))
{
IPin_Release(pin);
++object->count;
}
TRACE("Created enumerator %p.\n", object);
*out = &object->IEnumPins_iface;
@ -122,7 +119,7 @@ static ULONG WINAPI IEnumPinsImpl_Release(IEnumPins * iface)
static HRESULT WINAPI IEnumPinsImpl_Next(IEnumPins * iface, ULONG cPins, IPin ** ppPins, ULONG * pcFetched)
{
IEnumPinsImpl *This = impl_from_IEnumPins(iface);
ULONG i = 0;
ULONG i;
TRACE("(%p)->(%u, %p, %p)\n", iface, cPins, ppPins, pcFetched);
@ -138,16 +135,14 @@ static HRESULT WINAPI IEnumPinsImpl_Next(IEnumPins * iface, ULONG cPins, IPin **
if (This->Version != This->base->pin_version)
return VFW_E_ENUM_OUT_OF_SYNC;
while (i < cPins)
for (i = 0; i < cPins; ++i)
{
IPin *pin;
pin = This->base->pFuncsTable->filter_get_pin(This->base, This->uIndex + i);
IPin *pin = This->base->pFuncsTable->filter_get_pin(This->base, This->uIndex + i);
if (!pin)
break;
else
ppPins[i] = pin;
++i;
if (!pin)
break;
IPin_AddRef(ppPins[i] = pin);
}
if (pcFetched)
@ -186,10 +181,7 @@ static HRESULT WINAPI IEnumPinsImpl_Reset(IEnumPins *iface)
{
enum_pins->count = 0;
while ((pin = enum_pins->base->pFuncsTable->filter_get_pin(enum_pins->base, enum_pins->count)))
{
IPin_Release(pin);
++enum_pins->count;
}
}
enum_pins->Version = enum_pins->base->pin_version;

View File

@ -194,19 +194,15 @@ HRESULT WINAPI BaseFilterImpl_FindPin(IBaseFilter *iface, const WCHAR *id, IPin
{
hr = IPin_QueryPinInfo(pin, &info);
if (FAILED(hr))
{
IPin_Release(pin);
return hr;
}
if (info.pFilter) IBaseFilter_Release(info.pFilter);
if (!lstrcmpW(id, info.achName))
{
*ret = pin;
IPin_AddRef(*ret = pin);
return S_OK;
}
IPin_Release(pin);
}
return VFW_E_NOT_FOUND;

View File

@ -190,7 +190,6 @@ static IPin *renderer_get_pin(BaseFilter *iface, unsigned int index)
if (index >= 1)
return NULL;
IPin_AddRef(&This->pInputPin->pin.IPin_iface);
return &This->pInputPin->pin.IPin_iface;
}

View File

@ -135,7 +135,6 @@ static IPin *transform_get_pin(BaseFilter *iface, unsigned int index)
if (index >= 2)
return NULL;
IPin_AddRef(filter->ppPins[index]);
return filter->ppPins[index];
}

View File

@ -1198,19 +1198,13 @@ static inline GSTOutPin *impl_from_IMediaSeeking( IMediaSeeking *iface )
static IPin *gstdemux_get_pin(BaseFilter *base, unsigned int index)
{
GSTImpl *This = impl_from_IBaseFilter(&base->IBaseFilter_iface);
IPin *pin;
if (index > This->cStreams)
return NULL;
GSTImpl *filter = impl_from_IBaseFilter(&base->IBaseFilter_iface);
if (!index)
pin = &This->pInputPin.pin.IPin_iface;
else
pin = &This->ppPins[index - 1]->pin.pin.IPin_iface;
IPin_AddRef(pin);
return pin;
return &filter->pInputPin.pin.IPin_iface;
else if (index <= filter->cStreams)
return &filter->ppPins[index - 1]->pin.pin.IPin_iface;
return NULL;
}
static void gstdemux_destroy(BaseFilter *iface)

View File

@ -207,28 +207,16 @@ static IPin *qt_splitter_get_pin(BaseFilter *base, unsigned int index)
QTSplitter *filter = impl_from_BaseFilter(base);
if (index == 0)
{
IPin_AddRef(&filter->pInputPin.pin.IPin_iface);
return &filter->pInputPin.pin.IPin_iface;
}
else if (index == 1)
{
if (filter->pVideo_Pin)
{
IPin_AddRef(&filter->pVideo_Pin->pin.pin.IPin_iface);
return &filter->pVideo_Pin->pin.pin.IPin_iface;
}
else if (filter->pAudio_Pin)
{
IPin_AddRef(&filter->pAudio_Pin->pin.pin.IPin_iface);
return &filter->pAudio_Pin->pin.pin.IPin_iface;
}
}
else if (index == 2 && filter->pVideo_Pin && filter->pAudio_Pin)
{
IPin_AddRef(&filter->pAudio_Pin->pin.pin.IPin_iface);
return &filter->pAudio_Pin->pin.pin.IPin_iface;
}
return NULL;
}