[PATCH v5 2/5] quartz/filtergraph: Implement IFilterGraph2::ReconnectEx().

Zebediah Figura z.figura12 at gmail.com
Mon Feb 3 14:15:48 CST 2020


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/quartz/filtergraph.c       | 54 +++++++++++++++------------------
 dlls/quartz/tests/filtergraph.c | 25 +++++++++++++++
 2 files changed, 49 insertions(+), 30 deletions(-)

diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index cd4e7f40e0d..60bea5542ff 100644
--- a/dlls/quartz/filtergraph.c
+++ b/dlls/quartz/filtergraph.c
@@ -872,33 +872,13 @@ static HRESULT WINAPI FilterGraph2_ConnectDirect(IFilterGraph2 *iface, IPin *ppi
     return hr;
 }
 
-static HRESULT WINAPI FilterGraph2_Reconnect(IFilterGraph2 *iface, IPin *ppin)
+static HRESULT WINAPI FilterGraph2_Reconnect(IFilterGraph2 *iface, IPin *pin)
 {
-    IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
-    IPin *pConnectedTo = NULL;
-    HRESULT hr;
-    PIN_DIRECTION pindir;
-
-    IPin_QueryDirection(ppin, &pindir);
-    hr = IPin_ConnectedTo(ppin, &pConnectedTo);
+    IFilterGraphImpl *graph = impl_from_IFilterGraph2(iface);
 
-    TRACE("(%p/%p)->(%p) -- %p\n", This, iface, ppin, pConnectedTo);
+    TRACE("graph %p, pin %p.\n", graph, pin);
 
-    if (FAILED(hr)) {
-        TRACE("Querying connected to failed: %x\n", hr);
-        return hr; 
-    }
-    IPin_Disconnect(ppin);
-    IPin_Disconnect(pConnectedTo);
-    if (pindir == PINDIR_INPUT)
-        hr = IPin_Connect(pConnectedTo, ppin, NULL);
-    else
-        hr = IPin_Connect(ppin, pConnectedTo, NULL);
-    IPin_Release(pConnectedTo);
-    if (FAILED(hr))
-        WARN("Reconnecting pins failed, pins are not connected now..\n");
-    TRACE("-> %08x\n", hr);
-    return hr;
+    return IFilterGraph2_ReconnectEx(iface, pin, NULL);
 }
 
 static HRESULT WINAPI FilterGraph2_Disconnect(IFilterGraph2 *iface, IPin *ppin)
@@ -1830,15 +1810,29 @@ static HRESULT WINAPI FilterGraph2_AddSourceFilterForMoniker(IFilterGraph2 *ifac
     return S_OK;
 }
 
-static HRESULT WINAPI FilterGraph2_ReconnectEx(IFilterGraph2 *iface, IPin *ppin,
-        const AM_MEDIA_TYPE *pmt)
+static HRESULT WINAPI FilterGraph2_ReconnectEx(IFilterGraph2 *iface, IPin *pin, const AM_MEDIA_TYPE *mt)
 {
-    IFilterGraphImpl *This = impl_from_IFilterGraph2(iface);
+    IFilterGraphImpl *graph = impl_from_IFilterGraph2(iface);
+    PIN_DIRECTION dir;
+    HRESULT hr;
+    IPin *peer;
 
-    TRACE("(%p/%p)->(%p %p): stub !!!\n", This, iface, ppin, pmt);
-    strmbase_dump_media_type(pmt);
+    TRACE("graph %p, pin %p, mt %p.\n", graph, pin, mt);
 
-    return S_OK;
+    if (FAILED(hr = IPin_ConnectedTo(pin, &peer)))
+        return hr;
+
+    IPin_QueryDirection(pin, &dir);
+    IFilterGraph2_Disconnect(iface, peer);
+    IFilterGraph2_Disconnect(iface, pin);
+
+    if (dir == PINDIR_INPUT)
+        hr = IFilterGraph2_ConnectDirect(iface, peer, pin, mt);
+    else
+        hr = IFilterGraph2_ConnectDirect(iface, pin, peer, mt);
+
+    IPin_Release(peer);
+    return hr;
 }
 
 static HRESULT WINAPI FilterGraph2_RenderEx(IFilterGraph2 *iface, IPin *pPinOut, DWORD dwFlags,
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c
index 2483c502f45..b36605f3963 100644
--- a/dlls/quartz/tests/filtergraph.c
+++ b/dlls/quartz/tests/filtergraph.c
@@ -2910,6 +2910,31 @@ todo_wine
     hr = IFilterGraph2_Disconnect(graph, &source_pin.IPin_iface);
     ok(hr == S_OK, "Got hr %#x.\n", hr);
 
+    hr = IFilterGraph2_ReconnectEx(graph, &source_pin.IPin_iface, NULL);
+    ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr);
+    hr = IFilterGraph2_ReconnectEx(graph, &sink_pin.IPin_iface, NULL);
+    ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr);
+
+    hr = IFilterGraph2_ConnectDirect(graph, &source_pin.IPin_iface, &sink_pin.IPin_iface, &mt);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    hr = IFilterGraph2_ReconnectEx(graph, &source_pin.IPin_iface, NULL);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(source_pin.peer == &sink_pin.IPin_iface, "Got peer %p.\n", source_pin.peer);
+    ok(!source_pin.mt, "Got mt %p.\n", source_pin.mt);
+    ok(!sink_pin.peer, "Got peer %p.\n", sink_pin.peer);
+    hr = IFilterGraph2_Disconnect(graph, &source_pin.IPin_iface);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+    hr = IFilterGraph2_ConnectDirect(graph, &source_pin.IPin_iface, &sink_pin.IPin_iface, &mt);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    hr = IFilterGraph2_ReconnectEx(graph, &source_pin.IPin_iface, &mt);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(source_pin.peer == &sink_pin.IPin_iface, "Got peer %p.\n", source_pin.peer);
+    ok(source_pin.mt == &mt, "Got mt %p.\n", source_pin.mt);
+    ok(!sink_pin.peer, "Got peer %p.\n", sink_pin.peer);
+    hr = IFilterGraph2_Disconnect(graph, &source_pin.IPin_iface);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+
     /* Both pins are disconnected when a filter is removed. */
     hr = IFilterGraph2_ConnectDirect(graph, &source_pin.IPin_iface, &sink_pin.IPin_iface, &mt);
     ok(hr == S_OK, "Got hr %#x.\n", hr);
-- 
2.25.0




More information about the wine-devel mailing list