Commit 8ad97c1c authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

mf/session: Introduce new (allocate|release)_output_samples helpers.

parent acfa237c
...@@ -3172,45 +3172,59 @@ static HRESULT transform_get_external_output_sample(const struct media_session * ...@@ -3172,45 +3172,59 @@ static HRESULT transform_get_external_output_sample(const struct media_session *
return hr; return hr;
} }
static HRESULT transform_node_pull_samples(const struct media_session *session, struct topo_node *node) static HRESULT allocate_output_samples(const struct media_session *session, struct topo_node *node,
MFT_OUTPUT_DATA_BUFFER *buffers)
{ {
MFT_OUTPUT_STREAM_INFO stream_info; HRESULT hr;
MFT_OUTPUT_DATA_BUFFER *buffers; UINT i;
HRESULT hr = E_UNEXPECTED;
DWORD status = 0;
unsigned int i;
if (!(buffers = calloc(node->u.transform.output_count, sizeof(*buffers))))
return E_OUTOFMEMORY;
for (i = 0; i < node->u.transform.output_count; ++i) for (i = 0; i < node->u.transform.output_count; ++i)
{ {
MFT_OUTPUT_STREAM_INFO stream_info = {0};
buffers[i].dwStreamID = transform_node_get_stream_id(node, TRUE, i); buffers[i].dwStreamID = transform_node_get_stream_id(node, TRUE, i);
buffers[i].pSample = NULL;
buffers[i].dwStatus = 0;
buffers[i].pEvents = NULL;
memset(&stream_info, 0, sizeof(stream_info));
if (FAILED(hr = IMFTransform_GetOutputStreamInfo(node->object.transform, buffers[i].dwStreamID, &stream_info))) if (FAILED(hr = IMFTransform_GetOutputStreamInfo(node->object.transform, buffers[i].dwStreamID, &stream_info)))
break; return hr;
if (!(stream_info.dwFlags & (MFT_OUTPUT_STREAM_PROVIDES_SAMPLES | MFT_OUTPUT_STREAM_CAN_PROVIDE_SAMPLES))
if (!(stream_info.dwFlags & (MFT_OUTPUT_STREAM_PROVIDES_SAMPLES | MFT_OUTPUT_STREAM_CAN_PROVIDE_SAMPLES))) && FAILED(hr = transform_get_external_output_sample(session, node, i, &stream_info, &buffers[i].pSample)))
{ return hr;
if (FAILED(hr = transform_get_external_output_sample(session, node, i, &stream_info, &buffers[i].pSample)))
break;
}
} }
if (SUCCEEDED(hr)) return S_OK;
hr = IMFTransform_ProcessOutput(node->object.transform, 0, node->u.transform.output_count, buffers, &status); }
static void release_output_samples(struct topo_node *node, MFT_OUTPUT_DATA_BUFFER *buffers)
{
UINT i;
/* Collect returned samples for all streams. */
for (i = 0; i < node->u.transform.output_count; ++i) for (i = 0; i < node->u.transform.output_count; ++i)
{ {
struct transform_stream *stream = &node->u.transform.outputs[i]; if (buffers[i].pSample)
IMFSample_Release(buffers[i].pSample);
if (buffers[i].pEvents) if (buffers[i].pEvents)
IMFCollection_Release(buffers[i].pEvents); IMFCollection_Release(buffers[i].pEvents);
}
}
static HRESULT transform_node_pull_samples(const struct media_session *session, struct topo_node *node)
{
MFT_OUTPUT_DATA_BUFFER *buffers;
DWORD status;
HRESULT hr;
UINT i;
if (!(buffers = calloc(node->u.transform.output_count, sizeof(*buffers))))
return E_OUTOFMEMORY;
if (FAILED(hr = allocate_output_samples(session, node, buffers)))
goto done;
status = 0;
hr = IMFTransform_ProcessOutput(node->object.transform, 0, node->u.transform.output_count, buffers, &status);
for (i = 0; i < node->u.transform.output_count; ++i)
{
struct transform_stream *stream = &node->u.transform.outputs[i];
if (SUCCEEDED(hr) && !(buffers[i].dwStatus & MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE)) if (SUCCEEDED(hr) && !(buffers[i].dwStatus & MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE))
{ {
...@@ -3219,11 +3233,10 @@ static HRESULT transform_node_pull_samples(const struct media_session *session, ...@@ -3219,11 +3233,10 @@ static HRESULT transform_node_pull_samples(const struct media_session *session,
if (FAILED(hr = transform_stream_push_sample(stream, buffers[i].pSample))) if (FAILED(hr = transform_stream_push_sample(stream, buffers[i].pSample)))
WARN("Failed to queue output sample, hr %#lx\n", hr); WARN("Failed to queue output sample, hr %#lx\n", hr);
} }
if (buffers[i].pSample)
IMFSample_Release(buffers[i].pSample);
} }
done:
release_output_samples(node, buffers);
free(buffers); free(buffers);
return hr; return hr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment