[PATCH 2/5] strmbase: Share pin and filter reference counts in base pin reference counting methods.

Zebediah Figura z.figura12 at gmail.com
Tue Jun 18 20:17:34 CDT 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/quartz/pin.c               |  1 -
 dlls/strmbase/pin.c             | 41 +++++++--------------------------
 dlls/winegstreamer/gstdemux.c   |  1 -
 dlls/wineqtdecoder/qtsplitter.c |  1 -
 include/wine/strmbase.h         |  6 ++---
 5 files changed, 10 insertions(+), 40 deletions(-)

diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c
index 5c1fcdcb6f3..e99a493d0b5 100644
--- a/dlls/quartz/pin.c
+++ b/dlls/quartz/pin.c
@@ -174,7 +174,6 @@ static HRESULT PullPin_Init(const IPinVtbl *PullPin_Vtbl, const PIN_INFO *info,
 {
     /* Common attributes */
     pPinImpl->pin.IPin_iface.lpVtbl = PullPin_Vtbl;
-    pPinImpl->pin.refCount = 1;
     pPinImpl->pin.pConnectedTo = NULL;
     pPinImpl->pin.pCritSec = pCritSec;
     /* avoid copying uninitialized data */
diff --git a/dlls/strmbase/pin.c b/dlls/strmbase/pin.c
index f57875133a0..ebc7a1c16b0 100644
--- a/dlls/strmbase/pin.c
+++ b/dlls/strmbase/pin.c
@@ -173,14 +173,16 @@ LONG WINAPI BasePinImpl_GetMediaTypeVersion(BasePin *iface)
     return 1;
 }
 
-ULONG WINAPI BasePinImpl_AddRef(IPin * iface)
+ULONG WINAPI BasePinImpl_AddRef(IPin *iface)
 {
-    BasePin *This = impl_from_IPin(iface);
-    ULONG refCount = InterlockedIncrement(&This->refCount);
-
-    TRACE("(%p)->() AddRef from %d\n", iface, refCount - 1);
+    BasePin *pin = impl_from_IPin(iface);
+    return IBaseFilter_AddRef(pin->pinInfo.pFilter);
+}
 
-    return refCount;
+ULONG WINAPI BasePinImpl_Release(IPin *iface)
+{
+    BasePin *pin = impl_from_IPin(iface);
+    return IBaseFilter_Release(pin->pinInfo.pFilter);
 }
 
 HRESULT WINAPI BasePinImpl_Disconnect(IPin * iface)
@@ -379,19 +381,6 @@ HRESULT WINAPI BaseOutputPinImpl_QueryInterface(IPin * iface, REFIID riid, LPVOI
     return E_NOINTERFACE;
 }
 
-ULONG WINAPI BaseOutputPinImpl_Release(IPin * iface)
-{
-    BaseOutputPin *This = impl_BaseOutputPin_from_IPin(iface);
-    ULONG refCount = InterlockedDecrement(&This->pin.refCount);
-
-    TRACE("(%p)->() Release from %d\n", iface, refCount + 1);
-
-    if (!refCount)
-        BaseOutputPin_Destroy(This);
-
-    return refCount;
-}
-
 HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
 {
     HRESULT hr;
@@ -733,7 +722,6 @@ static void strmbase_pin_init(BasePin *pin, const IPinVtbl *vtbl,
 {
     memset(pin, 0, sizeof(*pin));
     pin->IPin_iface.lpVtbl = vtbl;
-    pin->refCount = 1;
     pin->pCritSec = cs;
     pin->dRate = 1.0;
     Copy_PinInfo(&pin->pinInfo, info);
@@ -825,19 +813,6 @@ HRESULT WINAPI BaseInputPinImpl_QueryInterface(IPin * iface, REFIID riid, LPVOID
     return E_NOINTERFACE;
 }
 
-ULONG WINAPI BaseInputPinImpl_Release(IPin * iface)
-{
-    BaseInputPin *This = impl_BaseInputPin_from_IPin(iface);
-    ULONG refCount = InterlockedDecrement(&This->pin.refCount);
-
-    TRACE("(%p)->() Release from %d\n", iface, refCount + 1);
-
-    if (!refCount)
-        BaseInputPin_Destroy(This);
-
-    return refCount;
-}
-
 HRESULT WINAPI BaseInputPinImpl_Connect(IPin *iface, IPin *pin, const AM_MEDIA_TYPE *pmt)
 {
     ERR("(%p)->(%p, %p) outgoing connection on an input pin!\n", iface, pin, pmt);
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index 38d1b9ec138..67cfbc02c2c 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -1282,7 +1282,6 @@ IUnknown * CALLBACK Gstreamer_Splitter_create(IUnknown *outer, HRESULT *phr)
     piInput->pFilter = &This->filter.IBaseFilter_iface;
     lstrcpynW(piInput->achName, wcsInputPinName, ARRAY_SIZE(piInput->achName));
     This->pInputPin.pin.IPin_iface.lpVtbl = &GST_InputPin_Vtbl;
-    This->pInputPin.pin.refCount = 1;
     This->pInputPin.pin.pConnectedTo = NULL;
     This->pInputPin.pin.pCritSec = &This->filter.csFilter;
     ZeroMemory(&This->pInputPin.pin.mtCurrent, sizeof(AM_MEDIA_TYPE));
diff --git a/dlls/wineqtdecoder/qtsplitter.c b/dlls/wineqtdecoder/qtsplitter.c
index 8298406c2ed..8b271d2c8c7 100644
--- a/dlls/wineqtdecoder/qtsplitter.c
+++ b/dlls/wineqtdecoder/qtsplitter.c
@@ -318,7 +318,6 @@ IUnknown * CALLBACK QTSplitter_create(IUnknown *outer, HRESULT *phr)
     piInput->pFilter = &This->filter.IBaseFilter_iface;
     lstrcpynW(piInput->achName, wcsInputPinName, ARRAY_SIZE(piInput->achName));
     This->pInputPin.pin.IPin_iface.lpVtbl = &QT_InputPin_Vtbl;
-    This->pInputPin.pin.refCount = 1;
     This->pInputPin.pin.pConnectedTo = NULL;
     This->pInputPin.pin.pCritSec = &This->filter.csFilter;
 
diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h
index 1a8b8aa43e0..c19bc6ca06c 100644
--- a/include/wine/strmbase.h
+++ b/include/wine/strmbase.h
@@ -31,7 +31,6 @@ void WINAPI DeleteMediaType(AM_MEDIA_TYPE * pMediaType);
 typedef struct BasePin
 {
 	IPin IPin_iface;
-	LONG refCount;
 	LPCRITICAL_SECTION pCritSec;
 	PIN_INFO pinInfo;
 	IPin * pConnectedTo;
@@ -103,7 +102,8 @@ typedef struct BaseInputPinFuncTable {
 /* Base Pin */
 HRESULT WINAPI BasePinImpl_GetMediaType(BasePin *This, int iPosition, AM_MEDIA_TYPE *pmt);
 LONG WINAPI BasePinImpl_GetMediaTypeVersion(BasePin *This);
-ULONG WINAPI BasePinImpl_AddRef(IPin * iface);
+ULONG WINAPI BasePinImpl_AddRef(IPin *iface);
+ULONG WINAPI BasePinImpl_Release(IPin *iface);
 HRESULT WINAPI BasePinImpl_Disconnect(IPin * iface);
 HRESULT WINAPI BasePinImpl_ConnectedTo(IPin * iface, IPin ** ppPin);
 HRESULT WINAPI BasePinImpl_ConnectionMediaType(IPin * iface, AM_MEDIA_TYPE * pmt);
@@ -117,7 +117,6 @@ HRESULT WINAPI BasePinImpl_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFER
 
 /* Base Output Pin */
 HRESULT WINAPI BaseOutputPinImpl_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
-ULONG WINAPI BaseOutputPinImpl_Release(IPin * iface);
 HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
 HRESULT WINAPI BaseOutputPinImpl_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
 HRESULT WINAPI BaseOutputPinImpl_Disconnect(IPin * iface);
@@ -141,7 +140,6 @@ void strmbase_source_init(BaseOutputPin *pin, const IPinVtbl *vtbl, const PIN_IN
 
 /* Base Input Pin */
 HRESULT WINAPI BaseInputPinImpl_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
-ULONG   WINAPI BaseInputPinImpl_Release(IPin * iface);
 HRESULT WINAPI BaseInputPinImpl_Connect(IPin * iface, IPin * pConnector, const AM_MEDIA_TYPE * pmt);
 HRESULT WINAPI BaseInputPinImpl_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
 HRESULT WINAPI BaseInputPinImpl_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt);
-- 
2.21.0




More information about the wine-devel mailing list