filter-graph: handle NULL in and out

We need to pass exactly n_inputs and n_outputs pointers to the process
function but make it possible to set some to NULL so that the data is
ignored.
This commit is contained in:
Wim Taymans 2024-12-18 12:21:55 +01:00
parent 49f48a5fda
commit 3cf9ccf4a7
2 changed files with 14 additions and 2 deletions

View file

@ -246,17 +246,20 @@ static int impl_process(void *object,
for (i = 0, j = 0; i < impl->info.n_inputs; i++) {
while (j < graph->n_input) {
port = &graph->input[j++];
if (port->desc)
if (port->desc && in[i])
port->desc->connect_port(*port->hndl, port->port, (float*)in[i]);
if (!port->next)
break;
}
}
for (i = 0; i < impl->info.n_outputs; i++) {
if (out[i] == NULL)
continue;
port = i < graph->n_output ? &graph->output[i] : NULL;
if (port && port->desc)
port->desc->connect_port(*port->hndl, port->port, (float*)out[i]);
port->desc->connect_port(*port->hndl, port->port, out[i]);
else
memset(out[i], 0, n_samples * sizeof(float));
}