quartz/parser: Share source pin and filter reference counts.
Uniquely, native quartz doesn't do this. But it doesn't make much sense to follow native quartz in this case, and it leads to simpler code on our part. Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5b612c3045
commit
08473519e9
|
@ -383,26 +383,27 @@ HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PR
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI break_connection(IPin *iface)
|
static void free_source_pin(IPin *iface)
|
||||||
{
|
{
|
||||||
Parser_OutputPin *pin = unsafe_impl_Parser_OutputPin_from_IPin(iface);
|
Parser_OutputPin *pin = unsafe_impl_Parser_OutputPin_from_IPin(iface);
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
if (!pin->pin.pin.pConnectedTo || !pin->pin.pMemInputPin)
|
if (pin->pin.pin.pConnectedTo)
|
||||||
hr = VFW_E_NOT_CONNECTED;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
hr = IPin_Disconnect(pin->pin.pin.pConnectedTo);
|
IPin_Disconnect(pin->pin.pin.pConnectedTo);
|
||||||
IPin_Disconnect(iface);
|
IPin_Disconnect(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hr;
|
FreeMediaType(pin->pmt);
|
||||||
|
CoTaskMemFree(pin->pmt);
|
||||||
|
FreeMediaType(&pin->pin.pin.mtCurrent);
|
||||||
|
if (pin->pin.pAllocator)
|
||||||
|
IMemAllocator_Release(pin->pin.pAllocator);
|
||||||
|
CoTaskMemFree(pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
|
static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
|
||||||
{
|
{
|
||||||
/* NOTE: should be in critical section when calling this function */
|
/* NOTE: should be in critical section when calling this function */
|
||||||
HRESULT hr;
|
|
||||||
ULONG i;
|
ULONG i;
|
||||||
IPin ** ppOldPins = This->ppPins;
|
IPin ** ppOldPins = This->ppPins;
|
||||||
|
|
||||||
|
@ -413,11 +414,7 @@ static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
|
||||||
memcpy(This->ppPins, ppOldPins, sizeof(IPin *) * 1);
|
memcpy(This->ppPins, ppOldPins, sizeof(IPin *) * 1);
|
||||||
|
|
||||||
for (i = 0; i < This->cStreams; i++)
|
for (i = 0; i < This->cStreams; i++)
|
||||||
{
|
free_source_pin(ppOldPins[i + 1]);
|
||||||
hr = break_connection(ppOldPins[i + 1]);
|
|
||||||
TRACE("Disconnect: %08x\n", hr);
|
|
||||||
IPin_Release(ppOldPins[i + 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseFilterImpl_IncrementPinVersion(&This->filter);
|
BaseFilterImpl_IncrementPinVersion(&This->filter);
|
||||||
This->cStreams = 0;
|
This->cStreams = 0;
|
||||||
|
@ -567,24 +564,16 @@ static HRESULT WINAPI Parser_OutputPin_QueryInterface(IPin * iface, REFIID riid,
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI Parser_OutputPin_AddRef(IPin *iface)
|
||||||
|
{
|
||||||
|
Parser_OutputPin *pin = unsafe_impl_Parser_OutputPin_from_IPin(iface);
|
||||||
|
return IBaseFilter_AddRef(pin->pin.pin.pinInfo.pFilter);
|
||||||
|
}
|
||||||
|
|
||||||
static ULONG WINAPI Parser_OutputPin_Release(IPin * iface)
|
static ULONG WINAPI Parser_OutputPin_Release(IPin * iface)
|
||||||
{
|
{
|
||||||
Parser_OutputPin *This = unsafe_impl_Parser_OutputPin_from_IPin(iface);
|
Parser_OutputPin *pin = unsafe_impl_Parser_OutputPin_from_IPin(iface);
|
||||||
ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount);
|
return IBaseFilter_Release(pin->pin.pin.pinInfo.pFilter);
|
||||||
|
|
||||||
TRACE("(%p)->() Release from %d\n", iface, refCount + 1);
|
|
||||||
|
|
||||||
if (!refCount)
|
|
||||||
{
|
|
||||||
FreeMediaType(This->pmt);
|
|
||||||
CoTaskMemFree(This->pmt);
|
|
||||||
FreeMediaType(&This->pin.pin.mtCurrent);
|
|
||||||
if (This->pin.pAllocator)
|
|
||||||
IMemAllocator_Release(This->pin.pAllocator);
|
|
||||||
CoTaskMemFree(This);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return refCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI Parser_OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
|
static HRESULT WINAPI Parser_OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
|
||||||
|
@ -612,7 +601,7 @@ static HRESULT WINAPI Parser_OutputPin_CheckMediaType(BasePin *pin, const AM_MED
|
||||||
static const IPinVtbl Parser_OutputPin_Vtbl =
|
static const IPinVtbl Parser_OutputPin_Vtbl =
|
||||||
{
|
{
|
||||||
Parser_OutputPin_QueryInterface,
|
Parser_OutputPin_QueryInterface,
|
||||||
BasePinImpl_AddRef,
|
Parser_OutputPin_AddRef,
|
||||||
Parser_OutputPin_Release,
|
Parser_OutputPin_Release,
|
||||||
Parser_OutputPin_Connect,
|
Parser_OutputPin_Connect,
|
||||||
BaseOutputPinImpl_ReceiveConnection,
|
BaseOutputPinImpl_ReceiveConnection,
|
||||||
|
|
Loading…
Reference in New Issue