When an upstream node has not given enough samples to the transform, we need to request more samples from it to avoid stalling the pipeline.
From: Shaun Ren sren@codeweavers.com
When an upstream node has not given enough samples to the transform, we need to request more samples from it to avoid stalling the pipeline. --- dlls/mf/session.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index b2371763150..f8c00fbb4e7 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -3142,8 +3142,8 @@ static void session_deliver_sample_to_node(struct media_session *session, IMFTop IMFSample *sample) { struct sample *sample_entry, *sample_entry2; - DWORD stream_id, downstream_input; - IMFTopologyNode *downstream_node; + DWORD stream_id, downstream_input, upstream_output; + IMFTopologyNode *downstream_node, *upstream_node; struct topo_node *topo_node; MF_TOPOLOGY_TYPE node_type; BOOL drain = FALSE; @@ -3213,7 +3213,15 @@ static void session_deliver_sample_to_node(struct media_session *session, IMFTop WARN("Drain command failed for transform, hr %#lx.\n", hr); }
- transform_node_pull_samples(session, topo_node); + hr = transform_node_pull_samples(session, topo_node); + if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT && !drain) + { + if (SUCCEEDED(IMFTopologyNode_GetInput(node, input, &upstream_node, &upstream_output))) + { + session_request_sample_from_node(session, upstream_node, upstream_output); + IMFTopologyNode_Release(upstream_node); + } + }
/* Remaining unprocessed input has been discarded, now queue markers for every output. */ if (drain)
Nikolay Sivov (@nsivov) commented about dlls/mf/session.c:
WARN("Drain command failed for transform, hr %#lx.\n", hr); }
transform_node_pull_samples(session, topo_node);
hr = transform_node_pull_samples(session, topo_node);
if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT && !drain)
{
if (SUCCEEDED(IMFTopologyNode_GetInput(node, input, &upstream_node, &upstream_output)))
{
session_request_sample_from_node(session, upstream_node, upstream_output);
IMFTopologyNode_Release(upstream_node);
}
}
In general we don't really know which input branch to request from. That's why there is a fixme in session_request_sample_from_node() in similar logic. When ProcessOutput() returns need-more-input it means currently accumulated input samples across all inputs are not enough to produce any output. I suspect it could be caching per-input MF_E_NOTACCEPTING status, and trying to balance requests. Anyway, my point is that, I suspect, logic here should be the same as logic in session_request_sample_from_node(). Probably another helper would be in order.
Also, please add new request call under else branch of the following 'drain' check.