Commit 8d249e18 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winegstreamer: Share sink pin and filter reference counts.

parent dae86f1e
...@@ -1211,7 +1211,6 @@ static void gstdemux_destroy(BaseFilter *iface) ...@@ -1211,7 +1211,6 @@ static void gstdemux_destroy(BaseFilter *iface)
{ {
GSTImpl *filter = impl_from_IBaseFilter(&iface->IBaseFilter_iface); GSTImpl *filter = impl_from_IBaseFilter(&iface->IBaseFilter_iface);
IPin *connected = NULL; IPin *connected = NULL;
ULONG pinref;
HRESULT hr; HRESULT hr;
CloseHandle(filter->no_more_pads_event); CloseHandle(filter->no_more_pads_event);
...@@ -1227,16 +1226,16 @@ static void gstdemux_destroy(BaseFilter *iface) ...@@ -1227,16 +1226,16 @@ static void gstdemux_destroy(BaseFilter *iface)
hr = IPin_Disconnect(&filter->pInputPin.pin.IPin_iface); hr = IPin_Disconnect(&filter->pInputPin.pin.IPin_iface);
assert(hr == S_OK); assert(hr == S_OK);
} }
pinref = IPin_Release(&filter->pInputPin.pin.IPin_iface);
if (pinref)
{
/* Valgrind could find this, if I kill it here */
ERR("pinref should be null, is %u, destroying anyway\n", pinref);
assert((LONG)pinref > 0);
while (pinref) FreeMediaType(&filter->pInputPin.pin.mtCurrent);
pinref = IPin_Release(&filter->pInputPin.pin.IPin_iface); if (filter->pInputPin.pAlloc)
} IMemAllocator_Release(filter->pInputPin.pAlloc);
filter->pInputPin.pAlloc = NULL;
if (filter->pInputPin.pReader)
IAsyncReader_Release(filter->pInputPin.pReader);
filter->pInputPin.pReader = NULL;
filter->pInputPin.pin.IPin_iface.lpVtbl = NULL;
if (filter->bus) if (filter->bus)
{ {
gst_bus_set_sync_handler(filter->bus, NULL, NULL, NULL); gst_bus_set_sync_handler(filter->bus, NULL, NULL, NULL);
...@@ -1892,24 +1891,16 @@ static inline GSTInPin *impl_sink_from_IPin(IPin *iface) ...@@ -1892,24 +1891,16 @@ static inline GSTInPin *impl_sink_from_IPin(IPin *iface)
return CONTAINING_RECORD(iface, GSTInPin, pin.IPin_iface); return CONTAINING_RECORD(iface, GSTInPin, pin.IPin_iface);
} }
static ULONG WINAPI GSTInPin_Release(IPin *iface) static ULONG WINAPI GSTInPin_AddRef(IPin *iface)
{ {
GSTInPin *This = impl_sink_from_IPin(iface); GSTInPin *pin = impl_sink_from_IPin(iface);
ULONG refCount = InterlockedDecrement(&This->pin.refCount); return IBaseFilter_AddRef(pin->pin.pinInfo.pFilter);
}
TRACE("(%p)->() Release from %d\n", iface, refCount + 1); static ULONG WINAPI GSTInPin_Release(IPin *iface)
if (!refCount) { {
FreeMediaType(&This->pin.mtCurrent); GSTInPin *pin = impl_sink_from_IPin(iface);
if (This->pAlloc) return IBaseFilter_Release(pin->pin.pinInfo.pFilter);
IMemAllocator_Release(This->pAlloc);
This->pAlloc = NULL;
if (This->pReader)
IAsyncReader_Release(This->pReader);
This->pReader = NULL;
This->pin.IPin_iface.lpVtbl = NULL;
return 0;
} else
return refCount;
} }
static HRESULT WINAPI GSTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) static HRESULT WINAPI GSTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
...@@ -2094,7 +2085,7 @@ static HRESULT WINAPI GSTInPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **ppE ...@@ -2094,7 +2085,7 @@ static HRESULT WINAPI GSTInPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **ppE
static const IPinVtbl GST_InputPin_Vtbl = { static const IPinVtbl GST_InputPin_Vtbl = {
GSTInPin_QueryInterface, GSTInPin_QueryInterface,
BasePinImpl_AddRef, GSTInPin_AddRef,
GSTInPin_Release, GSTInPin_Release,
BaseInputPinImpl_Connect, BaseInputPinImpl_Connect,
GSTInPin_ReceiveConnection, GSTInPin_ReceiveConnection,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment