Zebediah Figura : quartz/parser: Share sink pin and filter reference counts.
Alexandre Julliard
julliard at winehq.org
Mon Jun 17 15:54:19 CDT 2019
Module: wine
Branch: master
Commit: 5b612c3045f767a32488d7e151eca18b5bee7516
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5b612c3045f767a32488d7e151eca18b5bee7516
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Sun Jun 16 19:35:01 2019 -0500
quartz/parser: Share sink pin and filter reference counts.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/quartz/parser.c | 13 ++----------
dlls/quartz/pin.c | 48 ++++++++++++++++++++++--------------------
dlls/quartz/pin.h | 4 +++-
dlls/quartz/tests/avisplit.c | 3 ---
dlls/quartz/tests/mpegsplit.c | 4 +---
dlls/quartz/tests/waveparser.c | 3 ---
6 files changed, 31 insertions(+), 44 deletions(-)
diff --git a/dlls/quartz/parser.c b/dlls/quartz/parser.c
index 2666eb7..7e705cc 100644
--- a/dlls/quartz/parser.c
+++ b/dlls/quartz/parser.c
@@ -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,
diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c
index a3674f2..5c1fcdc 100644
--- a/dlls/quartz/pin.c
+++ b/dlls/quartz/pin.c
@@ -364,32 +364,34 @@ HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
return E_NOINTERFACE;
}
-ULONG WINAPI PullPin_Release(IPin *iface)
+void PullPin_destroy(PullPin *pin)
{
- PullPin *This = impl_PullPin_from_IPin(iface);
- ULONG refCount = InterlockedDecrement(&This->pin.refCount);
-
- TRACE("(%p)->() Release from %d\n", This, refCount + 1);
+ 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);
+}
- if (!refCount)
- {
- WaitForSingleObject(This->hEventStateChanged, INFINITE);
- assert(!This->hThread);
+ULONG WINAPI PullPin_AddRef(IPin *iface)
+{
+ PullPin *pin = impl_PullPin_from_IPin(iface);
+ return IBaseFilter_AddRef(pin->pin.pinInfo.pFilter);
+}
- 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;
+ULONG WINAPI PullPin_Release(IPin *iface)
+{
+ PullPin *pin = impl_PullPin_from_IPin(iface);
+ return IBaseFilter_Release(pin->pin.pinInfo.pFilter);
}
static void PullPin_Flush(PullPin *This)
diff --git a/dlls/quartz/pin.h b/dlls/quartz/pin.h
index 2f29c92..b65d223 100644
--- a/dlls/quartz/pin.h
+++ b/dlls/quartz/pin.h
@@ -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);
diff --git a/dlls/quartz/tests/avisplit.c b/dlls/quartz/tests/avisplit.c
index 59edb38..fb42783 100644
--- a/dlls/quartz/tests/avisplit.c
+++ b/dlls/quartz/tests/avisplit.c
@@ -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);
diff --git a/dlls/quartz/tests/mpegsplit.c b/dlls/quartz/tests/mpegsplit.c
index c82c5b6..9853a19 100644
--- a/dlls/quartz/tests/mpegsplit.c
+++ b/dlls/quartz/tests/mpegsplit.c
@@ -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);
diff --git a/dlls/quartz/tests/waveparser.c b/dlls/quartz/tests/waveparser.c
index fd65099..84288c4 100644
--- a/dlls/quartz/tests/waveparser.c
+++ b/dlls/quartz/tests/waveparser.c
@@ -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);
More information about the wine-cvs
mailing list