From: Conor McCarthy <cmccarthy@codeweavers.com> --- dlls/mf/tests/topology.c | 2 +- dlls/mf/topology_loader.c | 80 +++++++++++++++++---------------------- 2 files changed, 35 insertions(+), 47 deletions(-) diff --git a/dlls/mf/tests/topology.c b/dlls/mf/tests/topology.c index fc3fc68aa21..6c402e1e338 100644 --- a/dlls/mf/tests/topology.c +++ b/dlls/mf/tests/topology.c @@ -2651,7 +2651,7 @@ static void test_topology_loader(void) .input_types = {&audio_mp3_44100, &audio_pcm_44100}, .output_types = {&audio_pcm_44100}, .sink_method = MF_CONNECT_ALLOW_DECODER, .source_method = MF_CONNECT_RESOLVE_INDEPENDENT_OUTPUTTYPES, .expected_result = S_OK, .decoder_class = CLSID_CMP3DecMediaObject, - .flags = LOADER_NO_CURRENT_OUTPUT | LOADER_SET_MEDIA_TYPES | LOADER_SET_ENUMERATE_SOURCE_TYPES | LOADER_EXPECT_SINK_ENUMERATED_TODO, + .flags = LOADER_NO_CURRENT_OUTPUT | LOADER_SET_MEDIA_TYPES | LOADER_SET_ENUMERATE_SOURCE_TYPES | LOADER_EXPECT_SINK_ENUMERATED, }, { diff --git a/dlls/mf/topology_loader.c b/dlls/mf/topology_loader.c index 79b9f3a0184..9572a2c5407 100644 --- a/dlls/mf/topology_loader.c +++ b/dlls/mf/topology_loader.c @@ -767,61 +767,49 @@ static HRESULT topology_branch_connect_converter(IMFTopology *topology, return hr; } -static HRESULT topology_branch_connect_independent_outtypes(IMFTopology *topology, MF_CONNECT_METHOD method_mask, - struct topology_branch *branch, IMFMediaType *up_type, struct connection_context *context) +static HRESULT topology_branch_connect_independent_outtypes(IMFTopology *topology, MF_CONNECT_METHOD method, + struct topology_branch *branch, struct connection_context *context) { - IMFMediaTypeHandler *down_handler = context->down_types.handler; - IMFMediaType *down_type; - MF_TOPOLOGY_TYPE type; - UINT32 method; + IMFMediaType *up_type, *down_type; HRESULT hr; - TRACE("topology %p, method_mask %#x, branch %s, up_type %s.\n", - topology, method_mask, debugstr_topology_branch(branch), debugstr_media_subtype(up_type)); - - if (FAILED(IMFTopologyNode_GetUINT32(branch->down.node, &MF_TOPONODE_CONNECT_METHOD, &method))) - method = MF_CONNECT_ALLOW_DECODER; + connection_context_init_down_type_enumeration(context); - if (SUCCEEDED(hr = IMFMediaTypeHandler_IsMediaTypeSupported(down_handler, up_type, NULL))) + type_enumerator_reset(&context->up_types); + type_enumerator_reset(&context->down_types); + while (SUCCEEDED(hr = type_enumerator_get_next_media_type(&context->up_types, &up_type))) { - TRACE("Connected branch %s with upstream type %s.\n", debugstr_topology_branch(branch), debugstr_media_subtype(up_type)); - - if (SUCCEEDED(IMFTopologyNode_GetNodeType(branch->down.node, &type)) && type == MF_TOPOLOGY_TRANSFORM_NODE - && FAILED(hr = IMFMediaTypeHandler_SetCurrentMediaType(down_handler, up_type))) - WARN("Failed to set transform node media type, hr %#lx\n", hr); - - hr = IMFTopologyNode_ConnectOutput(branch->up.node, branch->up.stream, branch->down.node, branch->down.stream); - - goto done; - } - - connection_context_init_down_type_enumeration(context); - down_type = context->down_types.current ? context->down_types.current : context->down_types.index0; + if (SUCCEEDED(hr = IMFMediaTypeHandler_IsMediaTypeSupported(context->down_types.handler, up_type, NULL))) + { + hr = topology_branch_complete_connection(branch, context, up_type); + IMFMediaType_Release(up_type); + return hr; + } - if (FAILED(hr) && (method & method_mask & MF_CONNECT_ALLOW_CONVERTER) == MF_CONNECT_ALLOW_CONVERTER) - hr = topology_branch_connect_converter(topology, branch, context); + if (!(method & MF_CONNECT_ALLOW_DECODER)) + { + IMFMediaType_Release(up_type); + continue; + } - if (FAILED(hr) && (method & method_mask & MF_CONNECT_ALLOW_DECODER) == MF_CONNECT_ALLOW_DECODER) - hr = topology_branch_connect_indirect(topology, branch, context->up_types.enumerate, up_type, down_type); + while (SUCCEEDED(hr = type_enumerator_get_next_media_type(&context->down_types, &down_type))) + { + hr = topology_branch_connect_converter_with_types(topology, branch, up_type, down_type, context); + if (down_type) + IMFMediaType_Release(down_type); + if (SUCCEEDED(hr)) + break; + } -done: - return hr; -} + if (FAILED(hr) && (method & MF_CONNECT_ALLOW_DECODER) == MF_CONNECT_ALLOW_DECODER) + { + /* TODO: calls to IsMediaTypeSupported() on our test sink show that Windows enumerates down types + * here too, but independent out types is rarely used, and no issues are known to exist here. */ + hr = topology_branch_connect_indirect(topology, branch, context->up_types.enumerate, up_type, NULL); + } -static HRESULT topology_branch_foreach_up_types(IMFTopology *topology, MF_CONNECT_METHOD method_mask, - struct topology_branch *branch, struct connection_context *context) -{ - IMFMediaTypeHandler *handler = context->up_types.handler; - IMFMediaType *type; - DWORD index = 0; - HRESULT hr; + IMFMediaType_Release(up_type); - while (SUCCEEDED(hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, index++, &type))) - { - hr = topology_branch_connect_independent_outtypes(topology, method_mask, branch, type, context); - if (SUCCEEDED(hr)) - hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, type); - IMFMediaType_Release(type); if (SUCCEEDED(hr)) break; } @@ -882,7 +870,7 @@ static HRESULT topology_branch_connect(IMFTopology *topology, MF_CONNECT_METHOD down_method &= method_mask; if (up_method & MF_CONNECT_RESOLVE_INDEPENDENT_OUTPUTTYPES) - hr = topology_branch_foreach_up_types(topology, down_method, branch, &context); + hr = topology_branch_connect_independent_outtypes(topology, down_method, branch, &context); else hr = topology_branch_connect_down(topology, down_method, branch, &context); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10009