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)
|
||||
{
|
||||
IPin *connected = NULL;
|
||||
ULONG pinref;
|
||||
HRESULT hr;
|
||||
|
||||
PullPin_WaitForStateChange(This->pInputPin, INFINITE);
|
||||
|
@ -170,16 +169,8 @@ void Parser_Destroy(ParserImpl *This)
|
|||
hr = IPin_Disconnect(&This->pInputPin->pin.IPin_iface);
|
||||
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)
|
||||
pinref = IPin_Release(&This->pInputPin->pin.IPin_iface);
|
||||
}
|
||||
PullPin_destroy(This->pInputPin);
|
||||
|
||||
CoTaskMemFree(This->ppPins);
|
||||
strmbase_filter_cleanup(&This->filter);
|
||||
|
@ -734,7 +725,7 @@ static HRESULT WINAPI Parser_PullPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes
|
|||
static const IPinVtbl Parser_InputPin_Vtbl =
|
||||
{
|
||||
Parser_PullPin_QueryInterface,
|
||||
BasePinImpl_AddRef,
|
||||
PullPin_AddRef,
|
||||
PullPin_Release,
|
||||
BaseInputPinImpl_Connect,
|
||||
Parser_PullPin_ReceiveConnection,
|
||||
|
|
|
@ -364,32 +364,34 @@ HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
|
|||
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)
|
||||
{
|
||||
PullPin *This = impl_PullPin_from_IPin(iface);
|
||||
ULONG refCount = InterlockedDecrement(&This->pin.refCount);
|
||||
|
||||
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;
|
||||
PullPin *pin = impl_PullPin_from_IPin(iface);
|
||||
return IBaseFilter_Release(pin->pin.pinInfo.pFilter);
|
||||
}
|
||||
|
||||
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,
|
||||
CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone,
|
||||
LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
|
||||
void PullPin_destroy(PullPin *pin) DECLSPEC_HIDDEN;
|
||||
|
||||
/**************************/
|
||||
/*** 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_Disconnect(IPin * iface);
|
||||
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_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt);
|
||||
HRESULT WINAPI PullPin_BeginFlush(IPin * iface);
|
||||
|
|
|
@ -296,10 +296,8 @@ static void test_enum_pins(void)
|
|||
hr = IEnumPins_Next(enum1, 1, pins, NULL);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ref = get_refcount(filter);
|
||||
todo_wine
|
||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||
ref = get_refcount(pins[0]);
|
||||
todo_wine
|
||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||
ref = get_refcount(enum1);
|
||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||
|
@ -487,7 +485,6 @@ static void test_pin_info(void)
|
|||
ref = get_refcount(filter);
|
||||
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||
ref = get_refcount(pin);
|
||||
todo_wine
|
||||
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||
IBaseFilter_Release(info.pFilter);
|
||||
|
||||
|
|
|
@ -293,10 +293,8 @@ static void test_enum_pins(void)
|
|||
hr = IEnumPins_Next(enum1, 1, pins, NULL);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ref = get_refcount(filter);
|
||||
todo_wine
|
||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||
ref = get_refcount(pins[0]);
|
||||
todo_wine
|
||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||
ref = get_refcount(enum1);
|
||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||
|
@ -480,7 +478,7 @@ static void test_pin_info(void)
|
|||
ref = get_refcount(filter);
|
||||
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||
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);
|
||||
|
||||
hr = IPin_QueryDirection(pin, &dir);
|
||||
|
|
|
@ -293,10 +293,8 @@ static void test_enum_pins(void)
|
|||
hr = IEnumPins_Next(enum1, 1, pins, NULL);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ref = get_refcount(filter);
|
||||
todo_wine
|
||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||
ref = get_refcount(pins[0]);
|
||||
todo_wine
|
||||
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
|
||||
ref = get_refcount(enum1);
|
||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||
|
@ -480,7 +478,6 @@ static void test_pin_info(void)
|
|||
ref = get_refcount(filter);
|
||||
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||
ref = get_refcount(pin);
|
||||
todo_wine
|
||||
ok(ref == expect_ref + 1, "Got unexpected refcount %d.\n", ref);
|
||||
IBaseFilter_Release(info.pFilter);
|
||||
|
||||
|
|
Loading…
Reference in New Issue