quartz/parser: Share sink pin and filter reference counts.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5f08add0b3
commit
5b612c3045
|
@ -155,7 +155,6 @@ ULONG WINAPI Parser_AddRef(IBaseFilter * iface)
|
||||||
void Parser_Destroy(ParserImpl *This)
|
void Parser_Destroy(ParserImpl *This)
|
||||||
{
|
{
|
||||||
IPin *connected = NULL;
|
IPin *connected = NULL;
|
||||||
ULONG pinref;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
PullPin_WaitForStateChange(This->pInputPin, INFINITE);
|
PullPin_WaitForStateChange(This->pInputPin, INFINITE);
|
||||||
|
@ -170,16 +169,8 @@ void Parser_Destroy(ParserImpl *This)
|
||||||
hr = IPin_Disconnect(&This->pInputPin->pin.IPin_iface);
|
hr = IPin_Disconnect(&This->pInputPin->pin.IPin_iface);
|
||||||
assert(hr == S_OK);
|
assert(hr == S_OK);
|
||||||
}
|
}
|
||||||
pinref = IPin_Release(&This->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)
|
PullPin_destroy(This->pInputPin);
|
||||||
pinref = IPin_Release(&This->pInputPin->pin.IPin_iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
CoTaskMemFree(This->ppPins);
|
CoTaskMemFree(This->ppPins);
|
||||||
strmbase_filter_cleanup(&This->filter);
|
strmbase_filter_cleanup(&This->filter);
|
||||||
|
@ -734,7 +725,7 @@ static HRESULT WINAPI Parser_PullPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes
|
||||||
static const IPinVtbl Parser_InputPin_Vtbl =
|
static const IPinVtbl Parser_InputPin_Vtbl =
|
||||||
{
|
{
|
||||||
Parser_PullPin_QueryInterface,
|
Parser_PullPin_QueryInterface,
|
||||||
BasePinImpl_AddRef,
|
PullPin_AddRef,
|
||||||
PullPin_Release,
|
PullPin_Release,
|
||||||
BaseInputPinImpl_Connect,
|
BaseInputPinImpl_Connect,
|
||||||
Parser_PullPin_ReceiveConnection,
|
Parser_PullPin_ReceiveConnection,
|
||||||
|
|
|
@ -364,32 +364,34 @@ HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PullPin_destroy(PullPin *pin)
|
||||||
|
{
|
||||||
|
WaitForSingleObject(pin->hEventStateChanged, INFINITE);
|
||||||
|
assert(!pin->hThread);
|
||||||
|
|
||||||
|
if (pin->prefAlloc)
|
||||||
|
IMemAllocator_Release(pin->prefAlloc);
|
||||||
|
if (pin->pAlloc)
|
||||||
|
IMemAllocator_Release(pin->pAlloc);
|
||||||
|
if (pin->pReader)
|
||||||
|
IAsyncReader_Release(pin->pReader);
|
||||||
|
CloseHandle(pin->thread_sleepy);
|
||||||
|
CloseHandle(pin->hEventStateChanged);
|
||||||
|
pin->thread_lock.DebugInfo->Spare[0] = 0;
|
||||||
|
DeleteCriticalSection(&pin->thread_lock);
|
||||||
|
CoTaskMemFree(pin);
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI PullPin_AddRef(IPin *iface)
|
||||||
|
{
|
||||||
|
PullPin *pin = impl_PullPin_from_IPin(iface);
|
||||||
|
return IBaseFilter_AddRef(pin->pin.pinInfo.pFilter);
|
||||||
|
}
|
||||||
|
|
||||||
ULONG WINAPI PullPin_Release(IPin *iface)
|
ULONG WINAPI PullPin_Release(IPin *iface)
|
||||||
{
|
{
|
||||||
PullPin *This = impl_PullPin_from_IPin(iface);
|
PullPin *pin = impl_PullPin_from_IPin(iface);
|
||||||
ULONG refCount = InterlockedDecrement(&This->pin.refCount);
|
return IBaseFilter_Release(pin->pin.pinInfo.pFilter);
|
||||||
|
|
||||||
TRACE("(%p)->() Release from %d\n", This, refCount + 1);
|
|
||||||
|
|
||||||
if (!refCount)
|
|
||||||
{
|
|
||||||
WaitForSingleObject(This->hEventStateChanged, INFINITE);
|
|
||||||
assert(!This->hThread);
|
|
||||||
|
|
||||||
if(This->prefAlloc)
|
|
||||||
IMemAllocator_Release(This->prefAlloc);
|
|
||||||
if(This->pAlloc)
|
|
||||||
IMemAllocator_Release(This->pAlloc);
|
|
||||||
if(This->pReader)
|
|
||||||
IAsyncReader_Release(This->pReader);
|
|
||||||
CloseHandle(This->thread_sleepy);
|
|
||||||
CloseHandle(This->hEventStateChanged);
|
|
||||||
This->thread_lock.DebugInfo->Spare[0] = 0;
|
|
||||||
DeleteCriticalSection(&This->thread_lock);
|
|
||||||
CoTaskMemFree(This);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return refCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PullPin_Flush(PullPin *This)
|
static void PullPin_Flush(PullPin *This)
|
||||||
|
|
|
@ -106,6 +106,7 @@ HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInf
|
||||||
SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept,
|
SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept,
|
||||||
CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone,
|
CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone,
|
||||||
LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
|
LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
|
||||||
|
void PullPin_destroy(PullPin *pin) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/**************************/
|
/**************************/
|
||||||
/*** Pin Implementation ***/
|
/*** Pin Implementation ***/
|
||||||
|
@ -114,7 +115,8 @@ HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInf
|
||||||
HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
|
HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
|
||||||
HRESULT WINAPI PullPin_Disconnect(IPin * iface);
|
HRESULT WINAPI PullPin_Disconnect(IPin * iface);
|
||||||
HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
|
HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
|
||||||
ULONG WINAPI PullPin_Release(IPin * iface);
|
ULONG WINAPI PullPin_AddRef(IPin *iface) DECLSPEC_HIDDEN;
|
||||||
|
ULONG WINAPI PullPin_Release(IPin *iface) DECLSPEC_HIDDEN;
|
||||||
HRESULT WINAPI PullPin_EndOfStream(IPin * iface);
|
HRESULT WINAPI PullPin_EndOfStream(IPin * iface);
|
||||||
HRESULT WINAPI PullPin_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt);
|
HRESULT WINAPI PullPin_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt);
|
||||||
HRESULT WINAPI PullPin_BeginFlush(IPin * iface);
|
HRESULT WINAPI PullPin_BeginFlush(IPin * iface);
|
||||||
|
|
|
@ -296,10 +296,8 @@ static void test_enum_pins(void)
|
||||||
hr = IEnumPins_Next(enum1, 1, pins, NULL);
|
hr = IEnumPins_Next(enum1, 1, pins, NULL);
|
||||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
ref = get_refcount(filter);
|
ref = get_refcount(filter);
|
||||||
todo_wine
|
|
||||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||||
ref = get_refcount(pins[0]);
|
ref = get_refcount(pins[0]);
|
||||||
todo_wine
|
|
||||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||||
ref = get_refcount(enum1);
|
ref = get_refcount(enum1);
|
||||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||||
|
@ -487,7 +485,6 @@ static void test_pin_info(void)
|
||||||
ref = get_refcount(filter);
|
ref = get_refcount(filter);
|
||||||
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||||
ref = get_refcount(pin);
|
ref = get_refcount(pin);
|
||||||
todo_wine
|
|
||||||
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||||
IBaseFilter_Release(info.pFilter);
|
IBaseFilter_Release(info.pFilter);
|
||||||
|
|
||||||
|
|
|
@ -293,10 +293,8 @@ static void test_enum_pins(void)
|
||||||
hr = IEnumPins_Next(enum1, 1, pins, NULL);
|
hr = IEnumPins_Next(enum1, 1, pins, NULL);
|
||||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
ref = get_refcount(filter);
|
ref = get_refcount(filter);
|
||||||
todo_wine
|
|
||||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||||
ref = get_refcount(pins[0]);
|
ref = get_refcount(pins[0]);
|
||||||
todo_wine
|
|
||||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||||
ref = get_refcount(enum1);
|
ref = get_refcount(enum1);
|
||||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||||
|
@ -480,7 +478,7 @@ static void test_pin_info(void)
|
||||||
ref = get_refcount(filter);
|
ref = get_refcount(filter);
|
||||||
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||||
ref = get_refcount(pin);
|
ref = get_refcount(pin);
|
||||||
todo_wine ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||||
IBaseFilter_Release(info.pFilter);
|
IBaseFilter_Release(info.pFilter);
|
||||||
|
|
||||||
hr = IPin_QueryDirection(pin, &dir);
|
hr = IPin_QueryDirection(pin, &dir);
|
||||||
|
|
|
@ -293,10 +293,8 @@ static void test_enum_pins(void)
|
||||||
hr = IEnumPins_Next(enum1, 1, pins, NULL);
|
hr = IEnumPins_Next(enum1, 1, pins, NULL);
|
||||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
ref = get_refcount(filter);
|
ref = get_refcount(filter);
|
||||||
todo_wine
|
|
||||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||||
ref = get_refcount(pins[0]);
|
ref = get_refcount(pins[0]);
|
||||||
todo_wine
|
|
||||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||||
ref = get_refcount(enum1);
|
ref = get_refcount(enum1);
|
||||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||||
|
@ -480,7 +478,6 @@ static void test_pin_info(void)
|
||||||
ref = get_refcount(filter);
|
ref = get_refcount(filter);
|
||||||
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||||
ref = get_refcount(pin);
|
ref = get_refcount(pin);
|
||||||
todo_wine
|
|
||||||
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||||
IBaseFilter_Release(info.pFilter);
|
IBaseFilter_Release(info.pFilter);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue