Commit 8983528f authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winegstreamer: Share source pin and filter reference counts.

parent 8d249e18
...@@ -1688,41 +1688,16 @@ static HRESULT WINAPI GSTOutPin_QueryInterface(IPin *iface, REFIID riid, void ** ...@@ -1688,41 +1688,16 @@ static HRESULT WINAPI GSTOutPin_QueryInterface(IPin *iface, REFIID riid, void **
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI GSTOutPin_Release(IPin *iface) static ULONG WINAPI GSTOutPin_AddRef(IPin *iface)
{ {
GSTOutPin *This = impl_source_from_IPin(iface); GSTOutPin *pin = impl_source_from_IPin(iface);
ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount); return IBaseFilter_AddRef(pin->pin.pin.pinInfo.pFilter);
}
TRACE("(%p)->() Release from %d\n", This, refCount + 1);
mark_wine_thread();
if (!refCount) { static ULONG WINAPI GSTOutPin_Release(IPin *iface)
if (This->their_src) { {
if (This->flipfilter) { GSTOutPin *pin = impl_source_from_IPin(iface);
gst_pad_unlink(This->their_src, This->flip_sink); return IBaseFilter_Release(pin->pin.pin.pinInfo.pFilter);
gst_pad_unlink(This->flip_src, This->my_sink);
gst_object_unref(This->flip_src);
gst_object_unref(This->flip_sink);
This->flipfilter = NULL;
This->flip_src = This->flip_sink = NULL;
} else
gst_pad_unlink(This->their_src, This->my_sink);
gst_object_unref(This->their_src);
}
gst_object_unref(This->my_sink);
CloseHandle(This->caps_event);
DeleteMediaType(This->pmt);
FreeMediaType(&This->pin.pin.mtCurrent);
gst_segment_free(This->segment);
if(This->gstpool)
gst_object_unref(This->gstpool);
if (This->pin.pAllocator)
IMemAllocator_Release(This->pin.pAllocator);
CoTaskMemFree(This);
return 0;
}
return refCount;
} }
static HRESULT WINAPI GSTOutPin_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *amt) static HRESULT WINAPI GSTOutPin_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *amt)
...@@ -1780,30 +1755,47 @@ static HRESULT WINAPI GSTOutPin_DecideAllocator(BaseOutputPin *base, IMemInputPi ...@@ -1780,30 +1755,47 @@ static HRESULT WINAPI GSTOutPin_DecideAllocator(BaseOutputPin *base, IMemInputPi
return hr; return hr;
} }
static HRESULT break_source_connection(BaseOutputPin *This) static void free_source_pin(GSTOutPin *pin)
{ {
HRESULT hr; EnterCriticalSection(pin->pin.pin.pCritSec);
if (pin->pin.pin.pConnectedTo)
TRACE("(%p)->()\n", This);
EnterCriticalSection(This->pin.pCritSec);
if (!This->pin.pConnectedTo || !This->pMemInputPin)
hr = VFW_E_NOT_CONNECTED;
else
{ {
hr = IMemAllocator_Decommit(This->pAllocator); if (SUCCEEDED(IMemAllocator_Decommit(pin->pin.pAllocator)))
if (SUCCEEDED(hr)) IPin_Disconnect(pin->pin.pin.pConnectedTo);
hr = IPin_Disconnect(This->pin.pConnectedTo); IPin_Disconnect(&pin->pin.pin.IPin_iface);
IPin_Disconnect((IPin *)This);
} }
LeaveCriticalSection(This->pin.pCritSec); LeaveCriticalSection(pin->pin.pin.pCritSec);
return hr; if (pin->their_src)
{
if (pin->flipfilter)
{
gst_pad_unlink(pin->their_src, pin->flip_sink);
gst_pad_unlink(pin->flip_src, pin->my_sink);
gst_object_unref(pin->flip_src);
gst_object_unref(pin->flip_sink);
pin->flipfilter = NULL;
pin->flip_src = pin->flip_sink = NULL;
}
else
gst_pad_unlink(pin->their_src, pin->my_sink);
gst_object_unref(pin->their_src);
}
gst_object_unref(pin->my_sink);
CloseHandle(pin->caps_event);
DeleteMediaType(pin->pmt);
FreeMediaType(&pin->pin.pin.mtCurrent);
gst_segment_free(pin->segment);
if (pin->gstpool)
gst_object_unref(pin->gstpool);
if (pin->pin.pAllocator)
IMemAllocator_Release(pin->pin.pAllocator);
CoTaskMemFree(pin);
} }
static const IPinVtbl GST_OutputPin_Vtbl = { static const IPinVtbl GST_OutputPin_Vtbl = {
GSTOutPin_QueryInterface, GSTOutPin_QueryInterface,
BasePinImpl_AddRef, GSTOutPin_AddRef,
GSTOutPin_Release, GSTOutPin_Release,
BaseOutputPinImpl_Connect, BaseOutputPinImpl_Connect,
BaseOutputPinImpl_ReceiveConnection, BaseOutputPinImpl_ReceiveConnection,
...@@ -1857,7 +1849,6 @@ static HRESULT GST_AddPin(GSTImpl *This, const PIN_INFO *piOutput, const AM_MEDI ...@@ -1857,7 +1849,6 @@ static HRESULT GST_AddPin(GSTImpl *This, const PIN_INFO *piOutput, const AM_MEDI
static HRESULT GST_RemoveOutputPins(GSTImpl *This) static HRESULT GST_RemoveOutputPins(GSTImpl *This)
{ {
HRESULT hr;
ULONG i; ULONG i;
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
...@@ -1871,11 +1862,9 @@ static HRESULT GST_RemoveOutputPins(GSTImpl *This) ...@@ -1871,11 +1862,9 @@ static HRESULT GST_RemoveOutputPins(GSTImpl *This)
gst_object_unref(This->their_sink); gst_object_unref(This->their_sink);
This->my_src = This->their_sink = NULL; This->my_src = This->their_sink = NULL;
for (i = 0; i < This->cStreams; i++) { for (i = 0; i < This->cStreams; ++i)
hr = break_source_connection(&This->ppPins[i]->pin); free_source_pin(This->ppPins[i]);
TRACE("Disconnect: %08x\n", hr);
IPin_Release(&This->ppPins[i]->pin.pin.IPin_iface);
}
This->cStreams = 0; This->cStreams = 0;
CoTaskMemFree(This->ppPins); CoTaskMemFree(This->ppPins);
This->ppPins = NULL; This->ppPins = NULL;
......
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