mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
remote-node: handle add/remove of activation
This commit is contained in:
parent
84bb897886
commit
e31f1fcdca
1 changed files with 37 additions and 4 deletions
|
|
@ -79,9 +79,10 @@ struct mix {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct link {
|
struct link {
|
||||||
|
uint32_t node_id;
|
||||||
|
uint32_t mem_id;
|
||||||
struct pw_node_target target;
|
struct pw_node_target target;
|
||||||
int signalfd;
|
int signalfd;
|
||||||
uint32_t mem_id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct node_data {
|
struct node_data {
|
||||||
|
|
@ -157,6 +158,17 @@ on_rtsocket_condition(void *user_data, int fd, enum spa_io mask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct link *find_activation(struct pw_array *links, uint32_t node_id)
|
||||||
|
{
|
||||||
|
struct link *l;
|
||||||
|
|
||||||
|
pw_array_for_each(l, links) {
|
||||||
|
if (l->node_id == node_id)
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static struct mem *find_mem(struct node_data *data, uint32_t id)
|
static struct mem *find_mem(struct node_data *data, uint32_t id)
|
||||||
{
|
{
|
||||||
struct mem *m;
|
struct mem *m;
|
||||||
|
|
@ -957,6 +969,7 @@ client_node_set_activation(void *object,
|
||||||
struct pw_node *node = data->node;
|
struct pw_node *node = data->node;
|
||||||
struct mem *m;
|
struct mem *m;
|
||||||
struct pw_node_activation *ptr;
|
struct pw_node_activation *ptr;
|
||||||
|
struct link *link;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if (memid == SPA_ID_INVALID) {
|
if (memid == SPA_ID_INVALID) {
|
||||||
|
|
@ -982,20 +995,40 @@ client_node_set_activation(void *object,
|
||||||
}
|
}
|
||||||
pw_log_debug("node %p: set activation %d", node, node_id);
|
pw_log_debug("node %p: set activation %d", node, node_id);
|
||||||
|
|
||||||
|
if (data->remote_id == node_id) {
|
||||||
|
pw_log_debug("node %p: our activation %u: %u %u %u %p", node, node_id,
|
||||||
|
memid, offset, size, ptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
struct link *link;
|
|
||||||
link = pw_array_add(&data->links, sizeof(struct link));
|
link = pw_array_add(&data->links, sizeof(struct link));
|
||||||
|
link->node_id = node_id;
|
||||||
|
link->mem_id = memid;
|
||||||
link->target.activation = ptr;
|
link->target.activation = ptr;
|
||||||
link->signalfd = signalfd;
|
link->signalfd = signalfd;
|
||||||
link->target.signal = link_signal_func;
|
link->target.signal = link_signal_func;
|
||||||
link->target.data = link;
|
link->target.data = link;
|
||||||
link->target.activation->state[0].required--;
|
link->target.node = NULL;
|
||||||
pw_log_debug("node %p: required %d, pending %d", node,
|
spa_list_append(&node->rt.target_list, &link->target.link);
|
||||||
|
|
||||||
|
pw_log_debug("node %p: state %p required %d, pending %d", node,
|
||||||
|
&link->target.activation->state[0],
|
||||||
link->target.activation->state[0].required,
|
link->target.activation->state[0].required,
|
||||||
link->target.activation->state[0].pending);
|
link->target.activation->state[0].pending);
|
||||||
} else {
|
} else {
|
||||||
|
link = find_activation(&data->links, node_id);
|
||||||
|
if (link == NULL) {
|
||||||
|
res = -EINVAL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
link->node_id = SPA_ID_INVALID;
|
||||||
|
link->target.activation = NULL;
|
||||||
|
close(link->signalfd);
|
||||||
|
spa_list_remove(&link->target.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue