filter-graph: add NULL data support per port

It would be good to define NULL support per port in e.g. LV2
plugins where sidechains are usually defined optional.
This commit is contained in:
Niklas Carlsson 2025-08-06 11:52:47 +02:00
parent 97a1609b29
commit 2ac708d916
2 changed files with 14 additions and 6 deletions

View file

@ -27,10 +27,11 @@ struct spa_fga_plugin_methods {
struct spa_fga_port {
uint32_t index;
const char *name;
#define SPA_FGA_PORT_INPUT (1ULL << 0)
#define SPA_FGA_PORT_OUTPUT (1ULL << 1)
#define SPA_FGA_PORT_CONTROL (1ULL << 2)
#define SPA_FGA_PORT_AUDIO (1ULL << 3)
#define SPA_FGA_PORT_INPUT (1ULL << 0)
#define SPA_FGA_PORT_OUTPUT (1ULL << 1)
#define SPA_FGA_PORT_CONTROL (1ULL << 2)
#define SPA_FGA_PORT_AUDIO (1ULL << 3)
#define SPA_FGA_PORT_SUPPORTS_NULL_DATA (1ULL << 4)
uint64_t flags;
#define SPA_FGA_HINT_BOOLEAN (1ULL << 0)
@ -47,6 +48,7 @@ struct spa_fga_port {
#define SPA_FGA_IS_PORT_OUTPUT(x) ((x) & SPA_FGA_PORT_OUTPUT)
#define SPA_FGA_IS_PORT_CONTROL(x) ((x) & SPA_FGA_PORT_CONTROL)
#define SPA_FGA_IS_PORT_AUDIO(x) ((x) & SPA_FGA_PORT_AUDIO)
#define SPA_FGA_SUPPORTS_NULL_DATA(x) ((x) & SPA_FGA_PORT_SUPPORTS_NULL_DATA)
struct spa_fga_descriptor {
const char *name;

View file

@ -1619,6 +1619,8 @@ static int impl_activate(void *object, const struct spa_dict *props)
if ((res = port_ensure_data(link->output, i, max_samples)) < 0)
goto error;
data = link->output->audio_data[i];
} else if (SPA_FGA_SUPPORTS_NULL_DATA(d->ports[port->p].flags)) {
data = NULL;
} else {
data = sd;
}
@ -1629,9 +1631,13 @@ static int impl_activate(void *object, const struct spa_dict *props)
for (j = 0; j < desc->n_output; j++) {
port = &node->output_port[j];
if (port->audio_data[i] == NULL) {
if (SPA_FGA_SUPPORTS_NULL_DATA(d->ports[port->p].flags))
data = NULL;
else
data = dd;
spa_log_info(impl->log, "connect output port %s[%d]:%s %p",
node->name, i, d->ports[port->p].name, dd);
d->connect_port(node->hndl[i], port->p, dd);
node->name, i, d->ports[port->p].name, data);
d->connect_port(node->hndl[i], port->p, data);
}
}
for (j = 0; j < desc->n_control; j++) {