filter-chain: improve output data

When we allocate data on an output port, always set it immediately on
the plugin. We let output nodes allocate data and input ports consume
it.

When we have no data on an output port, use discard data or NULL.

This ensure that the ports only have data when they are used by an input
port and otherwise use discards or NULL data.
This commit is contained in:
Wim Taymans 2024-10-14 16:36:04 +02:00
parent a589bfc277
commit b30ff4eca3

View file

@ -2357,14 +2357,20 @@ static void node_cleanup(struct node *node)
static int port_ensure_data(struct port *port, uint32_t i, uint32_t max_samples)
{
float *data;
struct node *node = port->node;
const struct fc_descriptor *d = node->desc->desc;
if ((data = port->audio_data[i]) == NULL) {
data = calloc(max_samples, sizeof(float));
if (data == NULL) {
pw_log_error("cannot create port data: %m");
return -errno;
}
}
port->audio_data[i] = data;
}
pw_log_info("connect output port %s[%d]:%s %p",
node->name, i, d->ports[port->p].name, data);
d->connect_port(port->node->hndl[i], port->p, data);
return 0;
}
@ -2453,12 +2459,11 @@ static int graph_instantiate(struct graph *graph)
}
for (j = 0; j < desc->n_output; j++) {
port = &node->output_port[j];
if ((res = port_ensure_data(port, i, max_samples)) < 0)
goto error;
if (port->audio_data[i] == NULL) {
pw_log_info("connect output port %s[%d]:%s %p",
node->name, i, d->ports[port->p].name,
port->audio_data[i]);
d->connect_port(node->hndl[i], port->p, port->audio_data[i]);
node->name, i, d->ports[port->p].name, dd);
d->connect_port(node->hndl[i], port->p, dd);
}
}
for (j = 0; j < desc->n_control; j++) {
port = &node->control_port[j];