Signed-off-by: Sergio Gómez Del Real sdelreal@codeweavers.com --- dlls/mf/tests/mf.c | 2 -- dlls/mf/topology.c | 50 +++++++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index c4ab17f5e9..0bcf6a268f 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -1740,7 +1740,6 @@ static void test_topology_loader(void)
/* Empty topology */ hr = IMFTopoLoader_Load(loader, topology, &full_topology, NULL); -todo_wine ok(hr == MF_E_TOPO_UNSUPPORTED, "Unexpected hr %#x.\n", hr);
hr = MFCreateMediaType(&mediatypes_pd[0]); @@ -1788,7 +1787,6 @@ todo_wine
/* Source node only. */ hr = IMFTopoLoader_Load(loader, topology, &full_topology, NULL); -todo_wine ok(hr == MF_E_TOPO_UNSUPPORTED, "Unexpected hr %#x.\n", hr);
/* Add grabber sink. */ diff --git a/dlls/mf/topology.c b/dlls/mf/topology.c index 432979206b..3090ba9bce 100644 --- a/dlls/mf/topology.c +++ b/dlls/mf/topology.c @@ -1938,8 +1938,11 @@ static ULONG WINAPI topology_loader_Release(IMFTopoLoader *iface) static HRESULT WINAPI topology_loader_Load(IMFTopoLoader *iface, IMFTopology *input_topology, IMFTopology **output_topology, IMFTopology *current_topology) { - struct topology *topology = unsafe_impl_from_IMFTopology(input_topology); + MF_TOPOLOGY_TYPE node_type; + IMFTopologyNode *node; IMFStreamSink *sink; + IUnknown *object; + WORD count; HRESULT hr; size_t i;
@@ -1948,32 +1951,39 @@ static HRESULT WINAPI topology_loader_Load(IMFTopoLoader *iface, IMFTopology *in if (current_topology) FIXME("Current topology instance is ignored.\n");
- for (i = 0; i < topology->nodes.count; ++i) + if (FAILED(IMFTopology_GetNodeCount(input_topology, &count)) + || FAILED(MFCreateTopology(output_topology)) + || count < 2) + { + hr = MF_E_TOPO_UNSUPPORTED; + return hr; + } + + i = 0; + while (SUCCEEDED(IMFTopology_GetNode(input_topology, i++, &node))) { - struct topology_node *node = topology->nodes.nodes[i]; + IMFTopologyNode_GetNodeType(node, &node_type);
- switch (node->node_type) + if (node_type == MF_TOPOLOGY_OUTPUT_NODE) { - case MF_TOPOLOGY_OUTPUT_NODE: - if (node->object) + if (SUCCEEDED(hr = IMFTopologyNode_GetObject(node, &object))) + { + /* Sinks must be bound beforehand. */ + if (FAILED(IUnknown_QueryInterface(object, &IID_IMFStreamSink, (void **)&sink))) { - /* Sinks must be bound beforehand. */ - if (FAILED(IUnknown_QueryInterface(node->object, &IID_IMFStreamSink, (void **)&sink))) - return MF_E_TOPO_SINK_ACTIVATES_UNSUPPORTED; - IMFStreamSink_Release(sink); - } - break; - case MF_TOPOLOGY_SOURCESTREAM_NODE: - if (FAILED(hr = IMFAttributes_GetItem(node->attributes, &MF_TOPONODE_STREAM_DESCRIPTOR, NULL))) + IMFTopology_Release(*output_topology); + IMFTopologyNode_Release(node); + IUnknown_Release(object); + hr = MF_E_TOPO_SINK_ACTIVATES_UNSUPPORTED; return hr; - break; - default: - ; + } + IMFStreamSink_Release(sink); + IUnknown_Release(object); + } } - }
- if (FAILED(hr = MFCreateTopology(output_topology))) - return hr; + IMFTopologyNode_Release(node); + }
return IMFTopology_CloneFrom(*output_topology, input_topology); }