mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
client-node: create mix explicitly
This commit is contained in:
parent
44deacbc67
commit
a9a9c72a0a
2 changed files with 26 additions and 24 deletions
|
|
@ -217,14 +217,12 @@ static void mix_init(struct mix *mix, struct port *p, uint32_t mix_id)
|
||||||
mix->n_buffers = 0;
|
mix->n_buffers = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct mix *ensure_mix(struct impl *impl, struct port *p, uint32_t mix_id)
|
static struct mix *create_mix(struct impl *impl, struct port *p, uint32_t mix_id)
|
||||||
{
|
{
|
||||||
struct mix *mix;
|
struct mix *mix;
|
||||||
|
|
||||||
if ((mix = find_mix(p, mix_id)) == NULL)
|
if ((mix = find_mix(p, mix_id)) == NULL || mix->valid)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (mix->valid)
|
|
||||||
return mix;
|
|
||||||
mix_init(mix, p, mix_id);
|
mix_init(mix, p, mix_id);
|
||||||
return mix;
|
return mix;
|
||||||
}
|
}
|
||||||
|
|
@ -726,15 +724,12 @@ do_port_use_buffers(struct impl *impl,
|
||||||
direction == SPA_DIRECTION_INPUT ? "input" : "output",
|
direction == SPA_DIRECTION_INPUT ? "input" : "output",
|
||||||
port_id, mix_id, buffers, n_buffers, flags);
|
port_id, mix_id, buffers, n_buffers, flags);
|
||||||
|
|
||||||
|
if (direction == SPA_DIRECTION_OUTPUT)
|
||||||
|
mix_id = SPA_ID_INVALID;
|
||||||
|
|
||||||
if ((mix = find_mix(p, mix_id)) == NULL || !mix->valid)
|
if ((mix = find_mix(p, mix_id)) == NULL || !mix->valid)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (direction == SPA_DIRECTION_OUTPUT) {
|
|
||||||
mix_id = SPA_ID_INVALID;
|
|
||||||
if ((mix = find_mix(p, mix_id)) == NULL || !mix->valid)
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
clear_buffers(impl, mix);
|
clear_buffers(impl, mix);
|
||||||
|
|
||||||
if (n_buffers > 0) {
|
if (n_buffers > 0) {
|
||||||
|
|
@ -1380,7 +1375,7 @@ static int port_init_mix(void *data, struct pw_impl_port_mix *mix)
|
||||||
uint32_t idx, pos, len;
|
uint32_t idx, pos, len;
|
||||||
struct pw_memblock *area;
|
struct pw_memblock *area;
|
||||||
|
|
||||||
if ((m = ensure_mix(impl, port, mix->port.port_id)) == NULL)
|
if ((m = create_mix(impl, port, mix->port.port_id)) == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
mix->id = pw_map_insert_new(&impl->io_map, NULL);
|
mix->id = pw_map_insert_new(&impl->io_map, NULL);
|
||||||
|
|
@ -1573,7 +1568,7 @@ static void node_port_init(void *data, struct pw_impl_port *port)
|
||||||
SPA_TYPE_INTERFACE_Node,
|
SPA_TYPE_INTERFACE_Node,
|
||||||
SPA_VERSION_NODE,
|
SPA_VERSION_NODE,
|
||||||
&impl_port_mix, p);
|
&impl_port_mix, p);
|
||||||
ensure_mix(impl, p, SPA_ID_INVALID);
|
create_mix(impl, p, SPA_ID_INVALID);
|
||||||
|
|
||||||
pw_map_insert_at(&impl->ports[p->direction], p->id, p);
|
pw_map_insert_at(&impl->ports[p->direction], p->id, p);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -198,16 +198,6 @@ static struct mix *create_mix(struct node_data *data,
|
||||||
return mix;
|
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,
|
static int client_node_transport(void *_data,
|
||||||
int readfd, int writefd, uint32_t mem_id, uint32_t offset, uint32_t size)
|
int readfd, int writefd, uint32_t mem_id, uint32_t offset, uint32_t size)
|
||||||
{
|
{
|
||||||
|
|
@ -614,7 +604,7 @@ client_node_port_use_buffers(void *_data,
|
||||||
struct mix *mix;
|
struct mix *mix;
|
||||||
int res, prot;
|
int res, prot;
|
||||||
|
|
||||||
mix = ensure_mix(data, direction, port_id, mix_id);
|
mix = find_mix(data, direction, port_id, mix_id);
|
||||||
if (mix == NULL) {
|
if (mix == NULL) {
|
||||||
res = -ENOENT;
|
res = -ENOENT;
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
|
|
@ -767,7 +757,7 @@ client_node_port_set_io(void *_data,
|
||||||
int res = 0;
|
int res = 0;
|
||||||
uint32_t tag[5] = { data->remote_id, direction, port_id, mix_id, id };
|
uint32_t tag[5] = { data->remote_id, direction, port_id, mix_id, id };
|
||||||
|
|
||||||
mix = ensure_mix(data, direction, port_id, mix_id);
|
mix = find_mix(data, direction, port_id, mix_id);
|
||||||
if (mix == NULL) {
|
if (mix == NULL) {
|
||||||
res = -ENOENT;
|
res = -ENOENT;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
@ -1051,6 +1041,22 @@ static void node_port_info_changed(void *data, struct pw_impl_port *port,
|
||||||
add_port_update(d, port, change_mask);
|
add_port_update(d, port, change_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void node_port_added(void *data, struct pw_impl_port *port)
|
||||||
|
{
|
||||||
|
struct node_data *d = data;
|
||||||
|
struct mix *mix;
|
||||||
|
|
||||||
|
pw_log_debug("added %p", d);
|
||||||
|
|
||||||
|
if (d->client_node == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mix = create_mix(d, port->direction, port->port_id, SPA_ID_INVALID, SPA_ID_INVALID);
|
||||||
|
if (mix == NULL) {
|
||||||
|
pw_log_error("%p: failed to create port mix: %m", d->node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void node_port_removed(void *data, struct pw_impl_port *port)
|
static void node_port_removed(void *data, struct pw_impl_port *port)
|
||||||
{
|
{
|
||||||
struct node_data *d = data;
|
struct node_data *d = data;
|
||||||
|
|
@ -1099,6 +1105,7 @@ static const struct pw_impl_node_events node_events = {
|
||||||
.free = node_free,
|
.free = node_free,
|
||||||
.info_changed = node_info_changed,
|
.info_changed = node_info_changed,
|
||||||
.port_info_changed = node_port_info_changed,
|
.port_info_changed = node_port_info_changed,
|
||||||
|
.port_added = node_port_added,
|
||||||
.port_removed = node_port_removed,
|
.port_removed = node_port_removed,
|
||||||
.active_changed = node_active_changed,
|
.active_changed = node_active_changed,
|
||||||
.event = node_event,
|
.event = node_event,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue