From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 13 ++----------- dlls/mf/topology.c | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 27596e4f527..006709f698c 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -2175,9 +2175,8 @@ static void test_topology_loader(void)
/* Source node only. */ hr = IMFTopoLoader_Load(loader, topology, &full_topology, NULL); - todo_wine_if(hr == S_OK) + todo_wine_if(hr == E_INVALIDARG) ok(hr == MF_E_TOPO_UNSUPPORTED, "Unexpected hr %#lx.\n", hr); - if (hr == S_OK) IMFTopology_Release(full_topology);
hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &sink_node); ok(hr == S_OK, "Failed to create output node, hr %#lx.\n", hr); @@ -2388,28 +2387,23 @@ todo_wine { ref = IMFTopoLoader_Release(loader); ok(ref == 0, "Release returned %ld\n", ref); ref = IMFTopologyNode_Release(src_node); - todo_wine ok(ref == 0, "Release returned %ld\n", ref); ref = IMFTopologyNode_Release(sink_node); - todo_wine ok(ref == 0, "Release returned %ld\n", ref);
ref = IMFMediaSource_Release(source); - todo_wine ok(ref == 0, "Release returned %ld\n", ref);
ref = IMFPresentationDescriptor_Release(pd); - todo_wine ok(ref == 0, "Release returned %ld\n", ref); ref = IMFStreamDescriptor_Release(sd); - todo_wine ok(ref == 0, "Release returned %ld\n", ref);
ref = IMFMediaType_Release(input_type); - todo_wine ok(ref == 0, "Release returned %ld\n", ref); /* FIXME: is native really leaking refs here, or are we? */ ref = IMFMediaType_Release(output_type); + todo_wine ok(ref != 0, "Release returned %ld\n", ref);
hr = MFShutdown(); @@ -2542,10 +2536,8 @@ static void test_topology_loader_evr(void) ref = IMFTopology_Release(topology); ok(ref == 0, "Release returned %ld\n", ref); ref = IMFTopologyNode_Release(source_node); - todo_wine ok(ref == 0, "Release returned %ld\n", ref); ref = IMFTopologyNode_Release(evr_node); - todo_wine ok(ref == 0, "Release returned %ld\n", ref);
hr = IMFActivate_ShutdownObject(activate); @@ -2556,7 +2548,6 @@ static void test_topology_loader_evr(void) ok(ref == 0, "Release returned %ld\n", ref);
ref = IMFMediaType_Release(media_type); - todo_wine ok(ref == 0, "Release returned %ld\n", ref);
DestroyWindow(window); diff --git a/dlls/mf/topology.c b/dlls/mf/topology.c index ff90bc2c8af..8d64c10b5c7 100644 --- a/dlls/mf/topology.c +++ b/dlls/mf/topology.c @@ -2359,6 +2359,7 @@ static HRESULT topology_loader_resolve_branch(struct topoloader_context *context }; MF_TOPOLOGY_TYPE u_type, d_type; IMFTopologyNode *node; + HRESULT hr; TOPOID id;
/* Downstream node might have already been cloned. */ @@ -2372,10 +2373,13 @@ static HRESULT topology_loader_resolve_branch(struct topoloader_context *context if (!connectors[u_type][d_type]) { WARN("Unsupported branch kind %d -> %d.\n", u_type, d_type); + IMFTopologyNode_Release(node); return E_FAIL; }
- return connectors[u_type][d_type](context, upstream_node, output_index, node, input_index); + hr = connectors[u_type][d_type](context, upstream_node, output_index, node, input_index); + IMFTopologyNode_Release(node); + return hr; }
static HRESULT topology_loader_resolve_nodes(struct topoloader_context *context, unsigned int *layer_size) @@ -2391,19 +2395,25 @@ static HRESULT topology_loader_resolve_nodes(struct topoloader_context *context, { ++size;
- IMFTopology_GetNodeByID(context->input_topology, id, &orig_node); - IMFTopologyNode_GetNodeType(node, &node_type); switch (node_type) { case MF_TOPOLOGY_SOURCESTREAM_NODE: - if (FAILED(IMFTopologyNode_GetOutput(orig_node, 0, &downstream_node, &input_index))) + if (SUCCEEDED(hr = IMFTopology_GetNodeByID(context->input_topology, id, &orig_node))) + { + hr = IMFTopologyNode_GetOutput(orig_node, 0, &downstream_node, &input_index); + IMFTopologyNode_Release(orig_node); + } + + if (FAILED(hr)) { IMFTopology_RemoveNode(context->output_topology, node); + IMFTopologyNode_Release(node); continue; }
hr = topology_loader_resolve_branch(context, node, 0, downstream_node, input_index); + IMFTopologyNode_Release(downstream_node); break; case MF_TOPOLOGY_TRANSFORM_NODE: case MF_TOPOLOGY_TEE_NODE: @@ -2414,6 +2424,7 @@ static HRESULT topology_loader_resolve_nodes(struct topoloader_context *context, }
IMFTopologyNode_DeleteItem(node, &context->key); + IMFTopologyNode_Release(node);
if (FAILED(hr)) break; @@ -2661,10 +2672,13 @@ static HRESULT WINAPI topology_loader_Load(IMFTopoLoader *iface, IMFTopology *in break; }
- if (SUCCEEDED(hr)) + if (FAILED(hr)) + IMFTopology_Release(output_topology); + else + { topology_loader_resolve_complete(&context); - - *ret_topology = output_topology; + *ret_topology = output_topology; + }
return hr; }