Commit 74014b55 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

qcap: Use separate functions when searching from a pin and filter.

Previously, if we tried to search from a matching but connected source, we would loop forever. Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 18462a2f
...@@ -499,83 +499,88 @@ end: ...@@ -499,83 +499,88 @@ end:
return hr; return hr;
} }
static HRESULT find_unconnected_pin(CaptureGraphImpl *This, static HRESULT find_unconnected_source_from_filter(CaptureGraphImpl *capture_graph,
const GUID *pCategory, const GUID *pType, IUnknown *pSource, IPin **out_pin) const GUID *category, const GUID *majortype, IBaseFilter *filter, IPin **ret);
static HRESULT find_unconnected_source_from_pin(CaptureGraphImpl *capture_graph,
const GUID *category, const GUID *majortype, IPin *pin, IPin **ret)
{ {
int index = 0; PIN_INFO info;
IPin *source_out;
HRESULT hr; HRESULT hr;
BOOL usedSmartTeePreviewPin = FALSE; IPin *peer;
/* depth-first search the graph for the first unconnected pin that matches
* the given category and type */
for(;;){
IPin *nextpin;
if (pCategory && (IsEqualIID(pCategory, &PIN_CATEGORY_CAPTURE) || IsEqualIID(pCategory, &PIN_CATEGORY_PREVIEW))){
IBaseFilter *sourceFilter = NULL;
hr = IUnknown_QueryInterface(pSource, &IID_IBaseFilter, (void**)&sourceFilter);
if (SUCCEEDED(hr)) {
hr = match_smart_tee_pin(This, pCategory, pType, pSource, &source_out);
if (hr == VFW_S_NOPREVIEWPIN)
usedSmartTeePreviewPin = TRUE;
IBaseFilter_Release(sourceFilter);
} else {
hr = ICaptureGraphBuilder2_FindPin(&This->ICaptureGraphBuilder2_iface, pSource, PINDIR_OUTPUT, pCategory, pType, FALSE, index, &source_out);
}
if (FAILED(hr))
return E_INVALIDARG;
} else {
hr = ICaptureGraphBuilder2_FindPin(&This->ICaptureGraphBuilder2_iface, pSource, PINDIR_OUTPUT, pCategory, pType, FALSE, index, &source_out);
if (FAILED(hr))
return E_INVALIDARG;
}
hr = IPin_ConnectedTo(source_out, &nextpin); if (category && (IsEqualGUID(category, &PIN_CATEGORY_CAPTURE)
if(SUCCEEDED(hr)){ || IsEqualGUID(category, &PIN_CATEGORY_PREVIEW)))
PIN_INFO info; hr = match_smart_tee_pin(capture_graph, category, majortype, (IUnknown *)pin, &pin);
else
hr = ICaptureGraphBuilder2_FindPin(&capture_graph->ICaptureGraphBuilder2_iface,
(IUnknown *)pin, PINDIR_OUTPUT, category, majortype, FALSE, -1, &pin);
if (FAILED(hr))
return hr;
IPin_Release(source_out); if (FAILED(IPin_ConnectedTo(pin, &peer)))
{
*ret = pin;
return hr;
}
hr = IPin_QueryPinInfo(nextpin, &info); IPin_QueryPinInfo(peer, &info);
if(FAILED(hr) || !info.pFilter){ hr = find_unconnected_source_from_filter(capture_graph, category, majortype, info.pFilter, ret);
WARN("QueryPinInfo failed: %08x\n", hr); IBaseFilter_Release(info.pFilter);
return hr; IPin_Release(peer);
} IPin_Release(pin);
return hr;
}
hr = find_unconnected_pin(This, pCategory, pType, (IUnknown*)info.pFilter, out_pin); static HRESULT find_unconnected_source_from_filter(CaptureGraphImpl *capture_graph,
const GUID *category, const GUID *majortype, IBaseFilter *filter, IPin **ret)
{
IPin *pin, *peer;
HRESULT hr;
int index;
IBaseFilter_Release(info.pFilter); if (category && (IsEqualGUID(category, &PIN_CATEGORY_CAPTURE)
|| IsEqualGUID(category, &PIN_CATEGORY_PREVIEW)))
{
if (FAILED(hr = match_smart_tee_pin(capture_graph, category, majortype, (IUnknown *)filter, &pin)))
return hr;
if(SUCCEEDED(hr)) if (FAILED(IPin_ConnectedTo(pin, &peer)))
return hr; {
}else{ *ret = pin;
*out_pin = source_out; return hr;
if(usedSmartTeePreviewPin)
return VFW_S_NOPREVIEWPIN;
return S_OK;
} }
index++; IPin_Release(peer);
IPin_Release(pin);
return E_INVALIDARG;
} }
for (index = 0; SUCCEEDED(ICaptureGraphBuilder2_FindPin(&capture_graph->ICaptureGraphBuilder2_iface,
(IUnknown *)filter, PINDIR_OUTPUT, category, majortype, FALSE, index, &pin)); ++index)
{
hr = find_unconnected_source_from_pin(capture_graph, category, majortype, pin, ret);
IPin_Release(pin);
if (SUCCEEDED(hr))
return hr;
}
return E_INVALIDARG;
} }
static HRESULT WINAPI static HRESULT WINAPI fnCaptureGraphBuilder2_RenderStream(ICaptureGraphBuilder2 *iface,
fnCaptureGraphBuilder2_RenderStream(ICaptureGraphBuilder2 * iface, const GUID *category, const GUID *majortype, IUnknown *source,
const GUID *pCategory, IBaseFilter *pfCompressor, IBaseFilter *pfRenderer)
const GUID *pType,
IUnknown *pSource,
IBaseFilter *pfCompressor,
IBaseFilter *pfRenderer)
{ {
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface); CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
IPin *source_out = NULL, *renderer_in; IPin *source_out = NULL, *renderer_in;
BOOL rendererNeedsRelease = FALSE; BOOL rendererNeedsRelease = FALSE;
HRESULT hr, return_hr = S_OK; HRESULT hr, return_hr = S_OK;
IBaseFilter *filter;
IPin *pin;
FIXME("(%p/%p)->(%s, %s, %p, %p, %p) semi-stub!\n", This, iface, TRACE("graph %p, category %s, majortype %s, source %p, intermediate %p, sink %p.\n",
debugstr_guid(pCategory), debugstr_guid(pType), This, debugstr_guid(category), debugstr_guid(majortype), source, pfCompressor, pfRenderer);
pSource, pfCompressor, pfRenderer);
if (!This->mygraph) if (!This->mygraph)
{ {
...@@ -583,12 +588,27 @@ fnCaptureGraphBuilder2_RenderStream(ICaptureGraphBuilder2 * iface, ...@@ -583,12 +588,27 @@ fnCaptureGraphBuilder2_RenderStream(ICaptureGraphBuilder2 * iface,
return E_UNEXPECTED; return E_UNEXPECTED;
} }
if (pCategory && IsEqualIID(pCategory, &PIN_CATEGORY_VBI)) { if (category && IsEqualGUID(category, &PIN_CATEGORY_VBI))
{
FIXME("Tee/Sink-to-Sink filter not supported\n"); FIXME("Tee/Sink-to-Sink filter not supported\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
hr = find_unconnected_pin(This, pCategory, pType, pSource, &source_out); if (IUnknown_QueryInterface(source, &IID_IPin, (void **)&pin) == S_OK)
{
hr = find_unconnected_source_from_pin(This, category, majortype, pin, &source_out);
IPin_Release(pin);
}
else if (IUnknown_QueryInterface(source, &IID_IBaseFilter, (void **)&filter) == S_OK)
{
hr = find_unconnected_source_from_filter(This, category, majortype, filter, &source_out);
IBaseFilter_Release(filter);
}
else
{
WARN("Source object does not expose IBaseFilter or IPin.\n");
return E_INVALIDARG;
}
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
return_hr = hr; return_hr = hr;
......
...@@ -929,12 +929,9 @@ static void test_render_stream(void) ...@@ -929,12 +929,9 @@ static void test_render_stream(void)
todo_wine ok(!transform.source1.pin.pin.peer, "Pin should not be connected.\n"); todo_wine ok(!transform.source1.pin.pin.peer, "Pin should not be connected.\n");
todo_wine ok(!sink.sink1.pin.pin.peer, "Pin should not be connected.\n"); todo_wine ok(!sink.sink1.pin.pin.peer, "Pin should not be connected.\n");
if (0) hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_CC, NULL,
{ (IUnknown *)&source.source1.pin.pin.IPin_iface, NULL, &sink.filter.IBaseFilter_iface);
hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_CC, NULL, ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
(IUnknown *)&source.source1.pin.pin.IPin_iface, NULL, &sink.filter.IBaseFilter_iface);
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
}
disconnect_pins(graph, &source.source1); disconnect_pins(graph, &source.source1);
...@@ -983,12 +980,9 @@ static void test_render_stream(void) ...@@ -983,12 +980,9 @@ static void test_render_stream(void)
check_smart_tee_pin(transform.sink1.pin.pin.peer, L"Capture"); check_smart_tee_pin(transform.sink1.pin.pin.peer, L"Capture");
ok(transform.source1.pin.pin.peer == &sink.sink1.pin.pin.IPin_iface, "Got wrong connection.\n"); ok(transform.source1.pin.pin.peer == &sink.sink1.pin.pin.IPin_iface, "Got wrong connection.\n");
if (0) hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_CAPTURE, NULL,
{ (IUnknown *)&source.filter.IBaseFilter_iface, NULL, &sink.filter.IBaseFilter_iface);
hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_CAPTURE, NULL, ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
(IUnknown *)&source.filter.IBaseFilter_iface, NULL, &sink.filter.IBaseFilter_iface);
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
}
hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_PREVIEW, NULL, hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_PREVIEW, NULL,
(IUnknown *)&source.filter.IBaseFilter_iface, NULL, &sink.filter.IBaseFilter_iface); (IUnknown *)&source.filter.IBaseFilter_iface, NULL, &sink.filter.IBaseFilter_iface);
...@@ -1014,12 +1008,9 @@ static void test_render_stream(void) ...@@ -1014,12 +1008,9 @@ static void test_render_stream(void)
check_smart_tee_pin(transform.sink1.pin.pin.peer, L"Preview"); check_smart_tee_pin(transform.sink1.pin.pin.peer, L"Preview");
ok(transform.source1.pin.pin.peer == &sink.sink1.pin.pin.IPin_iface, "Got wrong connection.\n"); ok(transform.source1.pin.pin.peer == &sink.sink1.pin.pin.IPin_iface, "Got wrong connection.\n");
if (0) hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_PREVIEW, NULL,
{ (IUnknown *)&source.filter.IBaseFilter_iface, NULL, &sink.filter.IBaseFilter_iface);
hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_PREVIEW, NULL, ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
(IUnknown *)&source.filter.IBaseFilter_iface, NULL, &sink.filter.IBaseFilter_iface);
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
}
disconnect_pins(graph, &source.source1); disconnect_pins(graph, &source.source1);
IGraphBuilder_RemoveFilter(graph, &transform.filter.IBaseFilter_iface); IGraphBuilder_RemoveFilter(graph, &transform.filter.IBaseFilter_iface);
...@@ -1031,8 +1022,8 @@ static void test_render_stream(void) ...@@ -1031,8 +1022,8 @@ static void test_render_stream(void)
hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_CAPTURE, NULL, hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_CAPTURE, NULL,
(IUnknown *)&source.source1.pin.pin.IPin_iface, NULL, &sink.filter.IBaseFilter_iface); (IUnknown *)&source.source1.pin.pin.IPin_iface, NULL, &sink.filter.IBaseFilter_iface);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine check_smart_tee_pin(source.source1.pin.pin.peer, L"Input"); check_smart_tee_pin(source.source1.pin.pin.peer, L"Input");
todo_wine check_smart_tee_pin(transform.sink1.pin.pin.peer, L"Capture"); check_smart_tee_pin(transform.sink1.pin.pin.peer, L"Capture");
ok(transform.source1.pin.pin.peer == &sink.sink1.pin.pin.IPin_iface, "Got wrong connection.\n"); ok(transform.source1.pin.pin.peer == &sink.sink1.pin.pin.IPin_iface, "Got wrong connection.\n");
disconnect_pins(graph, &source.source1); disconnect_pins(graph, &source.source1);
IGraphBuilder_RemoveFilter(graph, &transform.filter.IBaseFilter_iface); IGraphBuilder_RemoveFilter(graph, &transform.filter.IBaseFilter_iface);
...@@ -1062,8 +1053,8 @@ static void test_render_stream(void) ...@@ -1062,8 +1053,8 @@ static void test_render_stream(void)
hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_CAPTURE, NULL, hr = ICaptureGraphBuilder2_RenderStream(capture_graph, &PIN_CATEGORY_CAPTURE, NULL,
(IUnknown *)&source.source1.pin.pin.IPin_iface, NULL, &sink.filter.IBaseFilter_iface); (IUnknown *)&source.source1.pin.pin.IPin_iface, NULL, &sink.filter.IBaseFilter_iface);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine check_smart_tee_pin(source.source1.pin.pin.peer, L"Input"); check_smart_tee_pin(source.source1.pin.pin.peer, L"Input");
todo_wine check_smart_tee_pin(transform.sink1.pin.pin.peer, L"Capture"); check_smart_tee_pin(transform.sink1.pin.pin.peer, L"Capture");
ok(transform.source1.pin.pin.peer == &sink.sink1.pin.pin.IPin_iface, "Got wrong connection.\n"); ok(transform.source1.pin.pin.peer == &sink.sink1.pin.pin.IPin_iface, "Got wrong connection.\n");
disconnect_pins(graph, &source.source1); disconnect_pins(graph, &source.source1);
disconnect_pins(graph, &transform.source1); disconnect_pins(graph, &transform.source1);
...@@ -1075,9 +1066,9 @@ static void test_render_stream(void) ...@@ -1075,9 +1066,9 @@ static void test_render_stream(void)
ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface); ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface);
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IBaseFilter_Release(&transform.filter.IBaseFilter_iface); ref = IBaseFilter_Release(&transform.filter.IBaseFilter_iface);
todo_wine ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IBaseFilter_Release(&sink.filter.IBaseFilter_iface); ref = IBaseFilter_Release(&sink.filter.IBaseFilter_iface);
todo_wine ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
} }
START_TEST(capturegraph) START_TEST(capturegraph)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment