From 7f3d463b4578a33a983fbc693c7f429f608f0a09 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sun, 16 Jun 2019 19:35:03 -0500 Subject: [PATCH] strmbase/transform: Share pin and filter reference counts. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/quartz/tests/acmwrapper.c | 10 +++------- dlls/quartz/tests/avidec.c | 10 +++------- dlls/strmbase/transform.c | 36 ++++++++++++++++++++++++++++------ 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/dlls/quartz/tests/acmwrapper.c b/dlls/quartz/tests/acmwrapper.c index 1c418723df7..1f07e507830 100644 --- a/dlls/quartz/tests/acmwrapper.c +++ b/dlls/quartz/tests/acmwrapper.c @@ -229,10 +229,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); @@ -243,10 +241,8 @@ todo_wine 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); @@ -383,7 +379,7 @@ static void test_pin_info(void) hr = IBaseFilter_FindPin(filter, sink_id, &pin); ok(hr == S_OK, "Got hr %#x.\n", hr); ref = get_refcount(filter); - todo_wine ok(ref == 2, "Got unexpected refcount %d.\n", ref); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); ref = get_refcount(pin); ok(ref == 2, "Got unexpected refcount %d.\n", ref); @@ -394,9 +390,9 @@ static void test_pin_info(void) todo_wine ok(!lstrcmpW(info.achName, sink_name), "Got name %s.\n", wine_dbgstr_w(info.achName)); 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(pin); - todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); IBaseFilter_Release(info.pFilter); hr = IPin_QueryDirection(pin, &dir); diff --git a/dlls/quartz/tests/avidec.c b/dlls/quartz/tests/avidec.c index 0183e0bea80..3f92876c84c 100644 --- a/dlls/quartz/tests/avidec.c +++ b/dlls/quartz/tests/avidec.c @@ -254,10 +254,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); @@ -268,10 +266,8 @@ todo_wine 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); @@ -408,7 +404,7 @@ static void test_pin_info(void) hr = IBaseFilter_FindPin(filter, sink_id, &pin); ok(hr == S_OK, "Got hr %#x.\n", hr); ref = get_refcount(filter); - todo_wine ok(ref == 2, "Got unexpected refcount %d.\n", ref); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); ref = get_refcount(pin); ok(ref == 2, "Got unexpected refcount %d.\n", ref); @@ -418,9 +414,9 @@ static void test_pin_info(void) ok(info.dir == PINDIR_INPUT, "Got direction %d.\n", info.dir); todo_wine ok(!lstrcmpW(info.achName, sink_name), "Got name %s.\n", wine_dbgstr_w(info.achName)); 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(pin); - todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); IBaseFilter_Release(info.pFilter); hr = IPin_QueryDirection(pin, &dir); diff --git a/dlls/strmbase/transform.c b/dlls/strmbase/transform.c index fe54ebe861f..4c32d673253 100644 --- a/dlls/strmbase/transform.c +++ b/dlls/strmbase/transform.c @@ -153,9 +153,11 @@ static void transform_destroy(BaseFilter *iface) IPin_Release(peer); } IPin_Disconnect(filter->ppPins[i]); - IPin_Release(filter->ppPins[i]); } + BaseInputPin_Destroy(impl_BaseInputPin_from_IPin(filter->ppPins[0])); + BaseOutputPin_Destroy(impl_BaseOutputPin_from_IPin(filter->ppPins[1])); + CoTaskMemFree(filter->ppPins); filter->csReceive.DebugInfo->Spare[0] = 0; @@ -379,7 +381,17 @@ HRESULT WINAPI TransformFilterImpl_Notify(TransformFilter *iface, IBaseFilter *s return QualityControlImpl_Notify((IQualityControl*)iface->qcimpl, sender, qm); } -/** IBaseFilter implementation **/ +static ULONG WINAPI TransformFilter_InputPin_AddRef(IPin *iface) +{ + BaseInputPin *pin = impl_BaseInputPin_from_IPin(iface); + return IBaseFilter_AddRef(pin->pin.pinInfo.pFilter); +} + +static ULONG WINAPI TransformFilter_InputPin_Release(IPin *iface) +{ + BaseInputPin *pin = impl_BaseInputPin_from_IPin(iface); + return IBaseFilter_Release(pin->pin.pinInfo.pFilter); +} static HRESULT WINAPI TransformFilter_InputPin_EndOfStream(IPin * iface) { @@ -504,8 +516,8 @@ static HRESULT WINAPI TransformFilter_InputPin_NewSegment(IPin * iface, REFERENC static const IPinVtbl TransformFilter_InputPin_Vtbl = { BaseInputPinImpl_QueryInterface, - BasePinImpl_AddRef, - BaseInputPinImpl_Release, + TransformFilter_InputPin_AddRef, + TransformFilter_InputPin_Release, BaseInputPinImpl_Connect, TransformFilter_InputPin_ReceiveConnection, TransformFilter_InputPin_Disconnect, @@ -543,11 +555,23 @@ static HRESULT WINAPI transform_source_QueryInterface(IPin *iface, REFIID iid, v return S_OK; } +static ULONG WINAPI transform_source_AddRef(IPin *iface) +{ + BaseOutputPin *pin = impl_BaseOutputPin_from_IPin(iface); + return IBaseFilter_AddRef(pin->pin.pinInfo.pFilter); +} + +static ULONG WINAPI transform_source_Release(IPin *iface) +{ + BaseOutputPin *pin = impl_BaseOutputPin_from_IPin(iface); + return IBaseFilter_Release(pin->pin.pinInfo.pFilter); +} + static const IPinVtbl TransformFilter_OutputPin_Vtbl = { transform_source_QueryInterface, - BasePinImpl_AddRef, - BaseOutputPinImpl_Release, + transform_source_AddRef, + transform_source_Release, BaseOutputPinImpl_Connect, BaseOutputPinImpl_ReceiveConnection, BaseOutputPinImpl_Disconnect,