diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c index 872b355cd35..b3aebabbdad 100644 --- a/dlls/quartz/filtergraph.c +++ b/dlls/quartz/filtergraph.c @@ -704,14 +704,11 @@ static HRESULT WINAPI FilterGraph2_RemoveFilter(IFilterGraph2 *iface, IBaseFilte TRACE("(%p/%p)->(%p)\n", This, iface, pFilter); - /* FIXME: check graph is stopped */ - LIST_FOR_EACH_ENTRY(entry, &This->filters, struct filter, entry) { if (entry->filter == pFilter) { IEnumPins *penumpins = NULL; - FILTER_STATE state; if (This->defaultclock && This->refClockProvider == pFilter) { @@ -726,31 +723,30 @@ static HRESULT WINAPI FilterGraph2_RemoveFilter(IFilterGraph2 *iface, IBaseFilte IPin *ppin; while(IEnumPins_Next(penumpins, 1, &ppin, NULL) == S_OK) { - IPin *victim = NULL; - HRESULT h; - IPin_ConnectedTo(ppin, &victim); - if (victim) + IPin *peer = NULL; + HRESULT hr; + + IPin_ConnectedTo(ppin, &peer); + if (peer) { - h = IPin_Disconnect(victim); - TRACE("Disconnect other side: %08x\n", h); - if (h == VFW_E_NOT_STOPPED) + if (FAILED(hr = IPin_Disconnect(peer))) { - PIN_INFO pinfo; - IPin_QueryPinInfo(victim, &pinfo); - - IBaseFilter_GetState(pinfo.pFilter, 0, &state); - if (state == State_Running) - IBaseFilter_Pause(pinfo.pFilter); - IBaseFilter_Stop(pinfo.pFilter); - IBaseFilter_Release(pinfo.pFilter); - h = IPin_Disconnect(victim); - TRACE("Disconnect retry: %08x\n", h); + WARN("Failed to disconnect peer %p, hr %#x.\n", peer, hr); + IPin_Release(peer); + IPin_Release(ppin); + IEnumPins_Release(penumpins); + return hr; } - IPin_Release(victim); - } - h = IPin_Disconnect(ppin); - TRACE("Disconnect 2: %08x\n", h); + IPin_Release(peer); + if (FAILED(hr = IPin_Disconnect(ppin))) + { + WARN("Failed to disconnect pin %p, hr %#x.\n", ppin, hr); + IPin_Release(ppin); + IEnumPins_Release(penumpins); + return hr; + } + } IPin_Release(ppin); } IEnumPins_Release(penumpins); diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c index 7b2aa25a932..e7ee4e5c446 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -3130,7 +3130,7 @@ todo_wine source_pin.require_stopped_disconnect = TRUE; hr = IFilterGraph2_RemoveFilter(graph, &source.IBaseFilter_iface); - todo_wine ok(hr == VFW_E_NOT_STOPPED, "Got hr %#x.\n", hr); + ok(hr == VFW_E_NOT_STOPPED, "Got hr %#x.\n", hr); ok(source_pin.peer == &sink_pin.IPin_iface, "Got peer %p.\n", source_pin.peer); ok(!sink_pin.peer, "Got peer %p.\n", sink_pin.peer); @@ -3139,7 +3139,7 @@ todo_wine source_pin.require_stopped_disconnect = FALSE; sink_pin.require_stopped_disconnect = TRUE; hr = IFilterGraph2_RemoveFilter(graph, &source.IBaseFilter_iface); - todo_wine ok(hr == VFW_E_NOT_STOPPED, "Got hr %#x.\n", hr); + ok(hr == VFW_E_NOT_STOPPED, "Got hr %#x.\n", hr); ok(source_pin.peer == &sink_pin.IPin_iface, "Got peer %p.\n", source_pin.peer); ok(sink_pin.peer == &source_pin.IPin_iface, "Got peer %p.\n", sink_pin.peer);