Commit 9ee197f2 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wineqtdecoder/qtsplitter: Share source pin and filter reference counts.

parent c4ba02aa
...@@ -779,23 +779,22 @@ static const IBaseFilterVtbl QT_Vtbl = { ...@@ -779,23 +779,22 @@ static const IBaseFilterVtbl QT_Vtbl = {
BaseFilterImpl_QueryVendorInfo BaseFilterImpl_QueryVendorInfo
}; };
static HRESULT break_source_connection(BaseOutputPin *pin) static void free_source_pin(QTOutPin *pin)
{ {
HRESULT hr; EnterCriticalSection(pin->pin.pin.pCritSec);
if (pin->pin.pin.pConnectedTo)
EnterCriticalSection(pin->pin.pCritSec);
if (!pin->pin.pConnectedTo || !pin->pMemInputPin)
hr = VFW_E_NOT_CONNECTED;
else
{ {
hr = IMemAllocator_Decommit(pin->pAllocator); if (SUCCEEDED(IMemAllocator_Decommit(pin->pin.pAllocator)))
if (SUCCEEDED(hr)) IPin_Disconnect(pin->pin.pin.pConnectedTo);
hr = IPin_Disconnect(pin->pin.pConnectedTo); IPin_Disconnect(&pin->pin.pin.IPin_iface);
IPin_Disconnect(&pin->pin.IPin_iface);
} }
LeaveCriticalSection(pin->pin.pCritSec); LeaveCriticalSection(pin->pin.pin.pCritSec);
return hr; DeleteMediaType(pin->pmt);
FreeMediaType(&pin->pin.pin.mtCurrent);
if (pin->pin.pAllocator)
IMemAllocator_Release(pin->pin.pAllocator);
CoTaskMemFree(pin);
} }
/* /*
...@@ -803,23 +802,16 @@ static HRESULT break_source_connection(BaseOutputPin *pin) ...@@ -803,23 +802,16 @@ static HRESULT break_source_connection(BaseOutputPin *pin)
*/ */
static HRESULT QT_RemoveOutputPins(QTSplitter *This) static HRESULT QT_RemoveOutputPins(QTSplitter *This)
{ {
HRESULT hr;
TRACE("(%p)\n", This);
if (This->pVideo_Pin) if (This->pVideo_Pin)
{ {
OutputQueue_Destroy(This->pVideo_Pin->queue); OutputQueue_Destroy(This->pVideo_Pin->queue);
hr = break_source_connection(&This->pVideo_Pin->pin); free_source_pin(This->pVideo_Pin);
TRACE("Disconnect: %08x\n", hr);
IPin_Release(&This->pVideo_Pin->pin.pin.IPin_iface);
This->pVideo_Pin = NULL; This->pVideo_Pin = NULL;
} }
if (This->pAudio_Pin) if (This->pAudio_Pin)
{ {
OutputQueue_Destroy(This->pAudio_Pin->queue); OutputQueue_Destroy(This->pAudio_Pin->queue);
hr = break_source_connection(&This->pAudio_Pin->pin); free_source_pin(This->pAudio_Pin);
TRACE("Disconnect: %08x\n", hr);
IPin_Release(&This->pAudio_Pin->pin.pin.IPin_iface);
This->pAudio_Pin = NULL; This->pAudio_Pin = NULL;
} }
...@@ -1340,22 +1332,16 @@ static HRESULT WINAPI QTOutPin_QueryInterface(IPin *iface, REFIID riid, void **p ...@@ -1340,22 +1332,16 @@ static HRESULT WINAPI QTOutPin_QueryInterface(IPin *iface, REFIID riid, void **p
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI QTOutPin_Release(IPin *iface) static ULONG WINAPI QTOutPin_AddRef(IPin *iface)
{ {
QTOutPin *This = impl_QTOutPin_from_IPin(iface); QTOutPin *pin = impl_QTOutPin_from_IPin(iface);
ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount); return IBaseFilter_AddRef(pin->pin.pin.pinInfo.pFilter);
TRACE("(%p)->() Release from %d\n", iface, refCount + 1); }
if (!refCount) static ULONG WINAPI QTOutPin_Release(IPin *iface)
{ {
DeleteMediaType(This->pmt); QTOutPin *pin = impl_QTOutPin_from_IPin(iface);
FreeMediaType(&This->pin.pin.mtCurrent); return IBaseFilter_Release(pin->pin.pin.pinInfo.pFilter);
if (This->pin.pAllocator)
IMemAllocator_Release(This->pin.pAllocator);
CoTaskMemFree(This);
return 0;
}
return refCount;
} }
static HRESULT WINAPI QTOutPin_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *amt) static HRESULT WINAPI QTOutPin_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *amt)
...@@ -1406,7 +1392,7 @@ static HRESULT WINAPI QTOutPin_DecideAllocator(BaseOutputPin *iface, IMemInputPi ...@@ -1406,7 +1392,7 @@ static HRESULT WINAPI QTOutPin_DecideAllocator(BaseOutputPin *iface, IMemInputPi
static const IPinVtbl QT_OutputPin_Vtbl = { static const IPinVtbl QT_OutputPin_Vtbl = {
QTOutPin_QueryInterface, QTOutPin_QueryInterface,
BasePinImpl_AddRef, QTOutPin_AddRef,
QTOutPin_Release, QTOutPin_Release,
BaseOutputPinImpl_Connect, BaseOutputPinImpl_Connect,
BaseOutputPinImpl_ReceiveConnection, BaseOutputPinImpl_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