Rémi Bernon (@rbernon) commented about dlls/mf/topology_loader.c:
+ { + hr = IMFMediaTypeHandler_GetCurrentMediaType(context->up_types.handler, &context->up_types.current); + if (context->up_node_type != MF_TOPOLOGY_SOURCESTREAM_NODE) + context->up_types.enumerate = FAILED(hr); + } + + if (FAILED(hr = IMFMediaTypeHandler_GetMediaTypeByIndex(context->up_types.handler, 0, &up_type))) + goto failed; + context->up_types.index0 = up_type; + + return S_OK; + +failed: + connection_context_destroy(context); + return hr; +} Fwiw I'm still reviewing the code, but I'm not completely sure to see how this context makes things simpler. It seems to me that it duplicates information that is already available otherwise. For instance up_node_type is already available from `IMFTopologyNode_GetNodeType(branch->up.node, &context->up_node_type)`, same thing for `up_types.index0`. It also adds an extra layer of indirection with more state to keep in mind when reading each function.
If we want to simplify some logic we could use extra helpers, but adding one stateful context makes it more difficult to understand the logic dependency between the various connection steps. For instance, whether down node type enumeration is dependent on up node type enumeration or not, becomes a bit blurry when they are kept together in this new context. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10009#note_133375