mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
filter-chain: alloc port data per handle.
This commit is contained in:
parent
9b6e504c19
commit
94a857550b
1 changed files with 25 additions and 10 deletions
|
|
@ -1501,7 +1501,6 @@ static int load_node(struct graph *graph, struct spa_json *json)
|
||||||
bool have_config = false;
|
bool have_config = false;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
int res;
|
int res;
|
||||||
float *data;
|
|
||||||
|
|
||||||
while (spa_json_get_string(json, key, sizeof(key)) > 0) {
|
while (spa_json_get_string(json, key, sizeof(key)) > 0) {
|
||||||
if (spa_streq("type", key)) {
|
if (spa_streq("type", key)) {
|
||||||
|
|
@ -1576,14 +1575,6 @@ static int load_node(struct graph *graph, struct spa_json *json)
|
||||||
port->idx = i;
|
port->idx = i;
|
||||||
port->external = SPA_ID_INVALID;
|
port->external = SPA_ID_INVALID;
|
||||||
port->p = desc->output[i];
|
port->p = desc->output[i];
|
||||||
if ((data = port->audio_data[i]) == NULL) {
|
|
||||||
data = calloc(1, MAX_SAMPLES * sizeof(float));
|
|
||||||
if (data == NULL) {
|
|
||||||
pw_log_error("cannot create port data: %m");
|
|
||||||
return -errno;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
port->audio_data[i] = data;
|
|
||||||
spa_list_init(&port->link_list);
|
spa_list_init(&port->link_list);
|
||||||
}
|
}
|
||||||
for (i = 0; i < desc->n_control; i++) {
|
for (i = 0; i < desc->n_control; i++) {
|
||||||
|
|
@ -1629,6 +1620,26 @@ static void node_cleanup(struct node *node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int port_ensure_data(struct port *port, uint32_t i)
|
||||||
|
{
|
||||||
|
float *data;
|
||||||
|
if ((data = port->audio_data[i]) == NULL) {
|
||||||
|
data = calloc(1, MAX_SAMPLES * sizeof(float));
|
||||||
|
if (data == NULL) {
|
||||||
|
pw_log_error("cannot create port data: %m");
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
port->audio_data[i] = data;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void port_free_data(struct port *port, uint32_t i)
|
||||||
|
{
|
||||||
|
free(port->audio_data[i]);
|
||||||
|
port->audio_data[i] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void node_free(struct node *node)
|
static void node_free(struct node *node)
|
||||||
{
|
{
|
||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
|
|
@ -1636,7 +1647,7 @@ static void node_free(struct node *node)
|
||||||
spa_list_remove(&node->link);
|
spa_list_remove(&node->link);
|
||||||
for (i = 0; i < node->n_hndl; i++) {
|
for (i = 0; i < node->n_hndl; i++) {
|
||||||
for (j = 0; j < node->desc->n_output; j++)
|
for (j = 0; j < node->desc->n_output; j++)
|
||||||
free(node->output_port[j].audio_data[i]);
|
port_free_data(&node->output_port[j], i);
|
||||||
}
|
}
|
||||||
node_cleanup(node);
|
node_cleanup(node);
|
||||||
descriptor_unref(node->desc);
|
descriptor_unref(node->desc);
|
||||||
|
|
@ -1688,6 +1699,8 @@ static int graph_instantiate(struct graph *graph)
|
||||||
|
|
||||||
spa_list_for_each(link, &port->link_list, input_link) {
|
spa_list_for_each(link, &port->link_list, input_link) {
|
||||||
struct port *peer = link->output;
|
struct port *peer = link->output;
|
||||||
|
if ((res = port_ensure_data(peer, i)) < 0)
|
||||||
|
goto error;
|
||||||
pw_log_info("connect input port %s[%d]:%s %p",
|
pw_log_info("connect input port %s[%d]:%s %p",
|
||||||
node->name, i, d->ports[port->p].name,
|
node->name, i, d->ports[port->p].name,
|
||||||
peer->audio_data[i]);
|
peer->audio_data[i]);
|
||||||
|
|
@ -1696,6 +1709,8 @@ static int graph_instantiate(struct graph *graph)
|
||||||
}
|
}
|
||||||
for (j = 0; j < desc->n_output; j++) {
|
for (j = 0; j < desc->n_output; j++) {
|
||||||
port = &node->output_port[j];
|
port = &node->output_port[j];
|
||||||
|
if ((res = port_ensure_data(port, i)) < 0)
|
||||||
|
goto error;
|
||||||
pw_log_info("connect output port %s[%d]:%s %p",
|
pw_log_info("connect output port %s[%d]:%s %p",
|
||||||
node->name, i, d->ports[port->p].name,
|
node->name, i, d->ports[port->p].name,
|
||||||
port->audio_data[i]);
|
port->audio_data[i]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue