Zebediah Figura : quartz/parser: Share source pin and filter reference counts.

Alexandre Julliard julliard at winehq.org
Mon Jun 17 15:54:19 CDT 2019


Module: wine
Branch: master
Commit: 08473519e97cd18e94488d2ccf762e89b580b69e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=08473519e97cd18e94488d2ccf762e89b580b69e

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Sun Jun 16 19:35:02 2019 -0500

quartz/parser: Share source pin and filter reference counts.

Uniquely, native quartz doesn't do this. But it doesn't make much sense to
follow native quartz in this case, and it leads to simpler code on our part.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/quartz/parser.c | 49 +++++++++++++++++++------------------------------
 1 file changed, 19 insertions(+), 30 deletions(-)

diff --git a/dlls/quartz/parser.c b/dlls/quartz/parser.c
index 7e705cc..5743a53 100644
--- a/dlls/quartz/parser.c
+++ b/dlls/quartz/parser.c
@@ -383,26 +383,27 @@ HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PR
     return hr;
 }
 
-static HRESULT WINAPI break_connection(IPin *iface)
+static void free_source_pin(IPin *iface)
 {
     Parser_OutputPin *pin = unsafe_impl_Parser_OutputPin_from_IPin(iface);
-    HRESULT hr;
 
-    if (!pin->pin.pin.pConnectedTo || !pin->pin.pMemInputPin)
-        hr = VFW_E_NOT_CONNECTED;
-    else
+    if (pin->pin.pin.pConnectedTo)
     {
-        hr = IPin_Disconnect(pin->pin.pin.pConnectedTo);
+        IPin_Disconnect(pin->pin.pin.pConnectedTo);
         IPin_Disconnect(iface);
     }
 
-    return hr;
+    FreeMediaType(pin->pmt);
+    CoTaskMemFree(pin->pmt);
+    FreeMediaType(&pin->pin.pin.mtCurrent);
+    if (pin->pin.pAllocator)
+        IMemAllocator_Release(pin->pin.pAllocator);
+    CoTaskMemFree(pin);
 }
 
 static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
 {
     /* NOTE: should be in critical section when calling this function */
-    HRESULT hr;
     ULONG i;
     IPin ** ppOldPins = This->ppPins;
 
@@ -413,11 +414,7 @@ static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
     memcpy(This->ppPins, ppOldPins, sizeof(IPin *) * 1);
 
     for (i = 0; i < This->cStreams; i++)
-    {
-        hr = break_connection(ppOldPins[i + 1]);
-        TRACE("Disconnect: %08x\n", hr);
-        IPin_Release(ppOldPins[i + 1]);
-    }
+        free_source_pin(ppOldPins[i + 1]);
 
     BaseFilterImpl_IncrementPinVersion(&This->filter);
     This->cStreams = 0;
@@ -567,24 +564,16 @@ static HRESULT WINAPI Parser_OutputPin_QueryInterface(IPin * iface, REFIID riid,
     return E_NOINTERFACE;
 }
 
-static ULONG WINAPI Parser_OutputPin_Release(IPin * iface)
+static ULONG WINAPI Parser_OutputPin_AddRef(IPin *iface)
 {
-    Parser_OutputPin *This = unsafe_impl_Parser_OutputPin_from_IPin(iface);
-    ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount);
-    
-    TRACE("(%p)->() Release from %d\n", iface, refCount + 1);
+    Parser_OutputPin *pin = unsafe_impl_Parser_OutputPin_from_IPin(iface);
+    return IBaseFilter_AddRef(pin->pin.pin.pinInfo.pFilter);
+}
 
-    if (!refCount)
-    {
-        FreeMediaType(This->pmt);
-        CoTaskMemFree(This->pmt);
-        FreeMediaType(&This->pin.pin.mtCurrent);
-        if (This->pin.pAllocator)
-            IMemAllocator_Release(This->pin.pAllocator);
-        CoTaskMemFree(This);
-        return 0;
-    }
-    return refCount;
+static ULONG WINAPI Parser_OutputPin_Release(IPin * iface)
+{
+    Parser_OutputPin *pin = unsafe_impl_Parser_OutputPin_from_IPin(iface);
+    return IBaseFilter_Release(pin->pin.pin.pinInfo.pFilter);
 }
 
 static HRESULT WINAPI Parser_OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
@@ -612,7 +601,7 @@ static HRESULT WINAPI Parser_OutputPin_CheckMediaType(BasePin *pin, const AM_MED
 static const IPinVtbl Parser_OutputPin_Vtbl = 
 {
     Parser_OutputPin_QueryInterface,
-    BasePinImpl_AddRef,
+    Parser_OutputPin_AddRef,
     Parser_OutputPin_Release,
     Parser_OutputPin_Connect,
     BaseOutputPinImpl_ReceiveConnection,




More information about the wine-cvs mailing list