mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
remote-node: refactor init/create/ensure mix
Make a create_mix function that also takes the peer_id.
This commit is contained in:
parent
6806af954e
commit
001f0656d4
2 changed files with 30 additions and 14 deletions
|
|
@ -518,9 +518,10 @@ static void free_object(struct client *c, struct object *o)
|
|||
|
||||
}
|
||||
|
||||
static void init_mix(struct mix *mix, uint32_t mix_id, struct port *port)
|
||||
static void init_mix(struct mix *mix, uint32_t mix_id, struct port *port, uint32_t peer_id)
|
||||
{
|
||||
mix->id = mix_id;
|
||||
mix->peer_id = mix_id;
|
||||
mix->port = port;
|
||||
mix->io = NULL;
|
||||
mix->n_buffers = 0;
|
||||
|
|
@ -549,14 +550,12 @@ static struct mix *find_mix(struct client *c, struct port *port, uint32_t mix_id
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct mix *ensure_mix(struct client *c, struct port *port, uint32_t mix_id)
|
||||
static struct mix *create_mix(struct client *c, struct port *port,
|
||||
uint32_t mix_id, uint32_t peer_id)
|
||||
{
|
||||
struct mix *mix;
|
||||
uint32_t i;
|
||||
|
||||
if ((mix = find_mix(c, port, mix_id)) != NULL)
|
||||
return mix;
|
||||
|
||||
if (spa_list_is_empty(&c->free_mix)) {
|
||||
mix = calloc(OBJECT_CHUNK, sizeof(struct mix));
|
||||
if (mix == NULL)
|
||||
|
|
@ -570,11 +569,19 @@ static struct mix *ensure_mix(struct client *c, struct port *port, uint32_t mix_
|
|||
|
||||
spa_list_append(&port->mix, &mix->port_link);
|
||||
|
||||
init_mix(mix, mix_id, port);
|
||||
init_mix(mix, mix_id, port, peer_id);
|
||||
|
||||
return mix;
|
||||
}
|
||||
|
||||
static struct mix *ensure_mix(struct client *c, struct port *port, uint32_t mix_id)
|
||||
{
|
||||
struct mix *mix;
|
||||
if ((mix = find_mix(c, port, mix_id)) != NULL)
|
||||
return mix;
|
||||
return create_mix(c, port, mix_id, SPA_ID_INVALID);
|
||||
}
|
||||
|
||||
static int clear_buffers(struct client *c, struct mix *mix)
|
||||
{
|
||||
struct port *port = mix->port;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ struct mix {
|
|||
struct spa_list link;
|
||||
struct pw_impl_port *port;
|
||||
uint32_t mix_id;
|
||||
uint32_t peer_id;
|
||||
struct pw_impl_port_mix mix;
|
||||
struct pw_array buffers;
|
||||
};
|
||||
|
|
@ -145,11 +146,13 @@ static void clean_transport(struct node_data *data)
|
|||
data->have_transport = false;
|
||||
}
|
||||
|
||||
static void mix_init(struct mix *mix, struct pw_impl_port *port, uint32_t mix_id)
|
||||
static void mix_init(struct mix *mix, struct pw_impl_port *port,
|
||||
uint32_t mix_id, uint32_t peer_id)
|
||||
{
|
||||
pw_log_debug("port %p: mix init %d.%d", port, port->port_id, mix_id);
|
||||
mix->port = port;
|
||||
mix->mix_id = mix_id;
|
||||
mix->peer_id = peer_id;
|
||||
pw_impl_port_init_mix(port, &mix->mix);
|
||||
pw_array_init(&mix->buffers, 32);
|
||||
pw_array_ensure_size(&mix->buffers, sizeof(struct buffer) * 64);
|
||||
|
|
@ -171,15 +174,13 @@ static struct mix *find_mix(struct node_data *data,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct mix *ensure_mix(struct node_data *data,
|
||||
enum spa_direction direction, uint32_t port_id, uint32_t mix_id)
|
||||
static struct mix *create_mix(struct node_data *data,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t mix_id, uint32_t peer_id)
|
||||
{
|
||||
struct mix *mix;
|
||||
struct pw_impl_port *port;
|
||||
|
||||
if ((mix = find_mix(data, direction, port_id, mix_id)))
|
||||
return mix;
|
||||
|
||||
port = pw_impl_node_find_port(data->node, direction, port_id);
|
||||
if (port == NULL)
|
||||
return NULL;
|
||||
|
|
@ -191,13 +192,21 @@ static struct mix *ensure_mix(struct node_data *data,
|
|||
mix = spa_list_first(&data->free_mix, struct mix, link);
|
||||
spa_list_remove(&mix->link);
|
||||
}
|
||||
|
||||
mix_init(mix, port, mix_id);
|
||||
mix_init(mix, port, mix_id, peer_id);
|
||||
spa_list_append(&data->mix[direction], &mix->link);
|
||||
|
||||
return mix;
|
||||
}
|
||||
|
||||
static struct mix *ensure_mix(struct node_data *data,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t mix_id)
|
||||
{
|
||||
struct mix *mix;
|
||||
if ((mix = find_mix(data, direction, port_id, mix_id)))
|
||||
return mix;
|
||||
return create_mix(data, direction, port_id, mix_id, SPA_ID_INVALID);
|
||||
}
|
||||
|
||||
static int client_node_transport(void *_data,
|
||||
int readfd, int writefd, uint32_t mem_id, uint32_t offset, uint32_t size)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue