mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-14 06:59:57 -05:00
graph: remove io from graph port, it's not needed
This commit is contained in:
parent
249110eb79
commit
d93dd5ec93
10 changed files with 47 additions and 63 deletions
|
|
@ -746,7 +746,6 @@ static int schedule_mix(struct spa_node *_node)
|
|||
struct port *outp = GET_OUT_PORT(n, 0);
|
||||
struct spa_graph_node *node = &port->rt.mix_node;
|
||||
struct spa_graph_port *gp;
|
||||
struct spa_io_buffers *io = port->rt.mix_port.io;
|
||||
size_t buffer_size = 0;
|
||||
struct buffer *outb;
|
||||
float *out = NULL;
|
||||
|
|
@ -760,7 +759,7 @@ static int schedule_mix(struct spa_node *_node)
|
|||
struct spa_io_buffers *inio;
|
||||
struct spa_buffer *inb;
|
||||
|
||||
if ((inio = gp->io) == NULL ||
|
||||
if ((inio = mix->io) == NULL ||
|
||||
inio->buffer_id >= mix->n_buffers ||
|
||||
inio->status != SPA_STATUS_HAVE_BUFFER)
|
||||
continue;
|
||||
|
|
@ -778,7 +777,7 @@ static int schedule_mix(struct spa_node *_node)
|
|||
add_f32(out, inb->datas[0].data, buffer_size);
|
||||
}
|
||||
|
||||
pw_log_trace("mix %p: input %p %p %zd", node, inio, io, buffer_size);
|
||||
pw_log_trace("mix %p: input %p %p %zd", node, inio, mix->io, buffer_size);
|
||||
}
|
||||
|
||||
outb = peek_buffer(n, outp);
|
||||
|
|
|
|||
|
|
@ -676,6 +676,7 @@ static int do_port_set_io(struct impl *impl,
|
|||
memid = SPA_ID_INVALID;
|
||||
mem_offset = mem_size = 0;
|
||||
}
|
||||
mix->io = data;
|
||||
update_io(impl, port, mix->port.port_id, id, memid);
|
||||
|
||||
pw_client_node_resource_port_set_io(this->resource,
|
||||
|
|
@ -1215,8 +1216,6 @@ static int port_init_mix(void *data, struct pw_port_mix *mix)
|
|||
mix->io->buffer_id = SPA_ID_INVALID;
|
||||
mix->io->status = SPA_STATUS_NEED_BUFFER;
|
||||
|
||||
mix->port.io = mix->io;
|
||||
|
||||
pw_log_debug("client-node %p: init mix io %d %p %p", impl, mix->id, mix->io,
|
||||
impl->io_areas->ptr);
|
||||
|
||||
|
|
@ -1248,9 +1247,6 @@ static int mix_port_set_io(struct spa_node *node,
|
|||
struct impl *impl = p->owner_data;
|
||||
struct pw_port_mix *mix;
|
||||
|
||||
p->rt.port.io = data;
|
||||
p->rt.mix_port.io = data;
|
||||
|
||||
mix = pw_map_lookup(&p->mix_port_map, port_id);
|
||||
if (mix == NULL)
|
||||
return -EIO;
|
||||
|
|
@ -1262,11 +1258,6 @@ static int mix_port_set_io(struct spa_node *node,
|
|||
|
||||
static int mix_port_process(struct spa_node *data)
|
||||
{
|
||||
struct pw_port *p = SPA_CONTAINER_OF(data, struct pw_port, mix_node);
|
||||
struct spa_io_buffers *io = p->rt.mix_port.io;
|
||||
if (io != NULL) {
|
||||
pw_log_trace("client-node %p: pass %d %d", data, io->status, io->buffer_id);
|
||||
}
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -486,12 +486,13 @@ param_filter(struct pw_link *this,
|
|||
}
|
||||
|
||||
static int port_set_io(struct pw_link *this, struct pw_port *port, void *data, size_t size,
|
||||
struct spa_graph_port *p)
|
||||
struct pw_port_mix *mix)
|
||||
{
|
||||
struct pw_type *t = &this->core->type;
|
||||
struct spa_graph_port *p = &mix->port;
|
||||
int res = 0;
|
||||
|
||||
p->io = data;
|
||||
mix->io = data;
|
||||
pw_log_debug("link %p: %s port %p %d.%d set io: %p", this,
|
||||
pw_direction_as_string(port->direction),
|
||||
port, port->port_id, p->port_id, data);
|
||||
|
|
@ -516,20 +517,20 @@ static int select_io(struct pw_link *this)
|
|||
if (impl->have_io)
|
||||
return 0;
|
||||
|
||||
io = this->rt.mix[SPA_DIRECTION_INPUT].port.io;
|
||||
io = this->rt.mix[SPA_DIRECTION_INPUT].io;
|
||||
if (io == NULL)
|
||||
io = this->rt.mix[SPA_DIRECTION_OUTPUT].port.io;
|
||||
io = this->rt.mix[SPA_DIRECTION_OUTPUT].io;
|
||||
if (io == NULL)
|
||||
io = &impl->io;
|
||||
if (io == NULL)
|
||||
return -EIO;
|
||||
|
||||
if ((res = port_set_io(this, this->input, io,
|
||||
sizeof(struct spa_io_buffers), &this->rt.mix[SPA_DIRECTION_INPUT].port)) < 0)
|
||||
sizeof(struct spa_io_buffers), &this->rt.mix[SPA_DIRECTION_INPUT])) < 0)
|
||||
return res;
|
||||
|
||||
if ((res = port_set_io(this, this->output, io,
|
||||
sizeof(struct spa_io_buffers), &this->rt.mix[SPA_DIRECTION_OUTPUT].port)) < 0)
|
||||
sizeof(struct spa_io_buffers), &this->rt.mix[SPA_DIRECTION_OUTPUT])) < 0)
|
||||
return res;
|
||||
|
||||
this->io = io;
|
||||
|
|
@ -940,7 +941,6 @@ static void input_remove(struct pw_link *this, struct pw_port *port)
|
|||
{
|
||||
struct impl *impl = (struct impl *) this;
|
||||
struct pw_port_mix *mix = &this->rt.mix[SPA_DIRECTION_INPUT];
|
||||
struct spa_graph_port *p = &mix->port;
|
||||
|
||||
pw_log_debug("link %p: remove input port %p", this, port);
|
||||
spa_hook_remove(&impl->input_port_listener);
|
||||
|
|
@ -951,7 +951,7 @@ static void input_remove(struct pw_link *this, struct pw_port *port)
|
|||
|
||||
clear_port_buffers(this, port);
|
||||
|
||||
port_set_io(this, this->input, NULL, 0, p);
|
||||
port_set_io(this, this->input, NULL, 0, mix);
|
||||
pw_port_release_mix(port, mix);
|
||||
this->input = NULL;
|
||||
}
|
||||
|
|
@ -960,7 +960,6 @@ static void output_remove(struct pw_link *this, struct pw_port *port)
|
|||
{
|
||||
struct impl *impl = (struct impl *) this;
|
||||
struct pw_port_mix *mix = &this->rt.mix[SPA_DIRECTION_OUTPUT];
|
||||
struct spa_graph_port *p = &mix->port;
|
||||
|
||||
pw_log_debug("link %p: remove output port %p", this, port);
|
||||
spa_hook_remove(&impl->output_port_listener);
|
||||
|
|
@ -971,7 +970,7 @@ static void output_remove(struct pw_link *this, struct pw_port *port)
|
|||
|
||||
clear_port_buffers(this, port);
|
||||
|
||||
port_set_io(this, this->output, NULL, 0, p);
|
||||
port_set_io(this, this->output, NULL, 0, mix);
|
||||
pw_port_release_mix(port, mix);
|
||||
this->output = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,26 +49,27 @@ static void port_update_state(struct pw_port *port, enum pw_port_state state)
|
|||
}
|
||||
}
|
||||
|
||||
static int schedule_tee_input(struct spa_node *data)
|
||||
static int tee_process(struct spa_node *data)
|
||||
{
|
||||
struct pw_port *this = SPA_CONTAINER_OF(data, struct pw_port, mix_node);
|
||||
struct spa_graph_node *node = &this->rt.mix_node;
|
||||
struct spa_graph_port *p;
|
||||
struct spa_io_buffers *io = this->rt.mix_port.io;
|
||||
struct spa_io_buffers *io = &this->rt.io;
|
||||
|
||||
if (!spa_list_is_empty(&node->ports[SPA_DIRECTION_OUTPUT])) {
|
||||
pw_log_trace("port %p: tee input %d %d", this, io->status, io->buffer_id);
|
||||
spa_list_for_each(p, &node->ports[SPA_DIRECTION_OUTPUT], link) {
|
||||
struct pw_port_mix *mix = SPA_CONTAINER_OF(p, struct pw_port_mix, port);
|
||||
pw_log_trace("port %p: port %d %d %p->%p", this,
|
||||
p->port_id, p->flags, io, p->io);
|
||||
*p->io = *io;
|
||||
p->port_id, p->flags, io, mix->io);
|
||||
*mix->io = *io;
|
||||
}
|
||||
}
|
||||
io->status = SPA_STATUS_NEED_BUFFER;
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
}
|
||||
|
||||
static int schedule_tee_reuse_buffer(struct spa_node *data, uint32_t port_id, uint32_t buffer_id)
|
||||
static int tee_reuse_buffer(struct spa_node *data, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct pw_port *this = SPA_CONTAINER_OF(data, struct pw_port, mix_node);
|
||||
struct spa_graph_port *p = &this->rt.mix_port, *pp;
|
||||
|
|
@ -83,8 +84,8 @@ static int schedule_tee_reuse_buffer(struct spa_node *data, uint32_t port_id, ui
|
|||
static const struct spa_node schedule_tee_node = {
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
.process = schedule_tee_input,
|
||||
.port_reuse_buffer = schedule_tee_reuse_buffer,
|
||||
.process = tee_process,
|
||||
.port_reuse_buffer = tee_reuse_buffer,
|
||||
};
|
||||
|
||||
static int schedule_mix_input(struct spa_node *data)
|
||||
|
|
@ -92,12 +93,13 @@ static int schedule_mix_input(struct spa_node *data)
|
|||
struct pw_port *this = SPA_CONTAINER_OF(data, struct pw_port, mix_node);
|
||||
struct spa_graph_node *node = &this->rt.mix_node;
|
||||
struct spa_graph_port *p;
|
||||
struct spa_io_buffers *io = this->rt.mix_port.io;
|
||||
struct spa_io_buffers *io = &this->rt.io;
|
||||
|
||||
spa_list_for_each(p, &node->ports[SPA_DIRECTION_INPUT], link) {
|
||||
struct pw_port_mix *mix = SPA_CONTAINER_OF(p, struct pw_port_mix, port);
|
||||
pw_log_trace("port %p: mix input %d %p->%p %d %d", this,
|
||||
p->port_id, p->io, io, p->io->status, p->io->buffer_id);
|
||||
*io = *p->io;
|
||||
p->port_id, mix->io, io, mix->io->status, mix->io->buffer_id);
|
||||
*io = *mix->io;
|
||||
break;
|
||||
}
|
||||
return io->status;
|
||||
|
|
@ -135,14 +137,13 @@ int pw_port_init_mix(struct pw_port *port, struct pw_port_mix *mix)
|
|||
|
||||
spa_graph_port_init(&mix->port,
|
||||
port->direction, id,
|
||||
0,
|
||||
NULL);
|
||||
0);
|
||||
|
||||
if (pi && pi->init_mix)
|
||||
res = pi->init_mix(port->implementation_data, mix);
|
||||
|
||||
pw_log_debug("port %p: init mix %d.%d io %p", port,
|
||||
port->port_id, mix->port.port_id, mix->port.io);
|
||||
port->port_id, mix->port.port_id, mix->io);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -205,8 +206,7 @@ struct pw_port *pw_port_new(enum pw_direction direction,
|
|||
spa_graph_port_init(&this->rt.port,
|
||||
this->direction,
|
||||
this->port_id,
|
||||
0,
|
||||
&this->rt.io);
|
||||
0);
|
||||
spa_graph_node_init(&this->rt.mix_node, &this->rt.mix_state);
|
||||
this->rt.mix_state.status = SPA_STATUS_NEED_BUFFER;
|
||||
|
||||
|
|
@ -219,9 +219,7 @@ struct pw_port *pw_port_new(enum pw_direction direction,
|
|||
|
||||
spa_graph_port_init(&this->rt.mix_port,
|
||||
pw_direction_reverse(this->direction),
|
||||
0,
|
||||
0,
|
||||
&this->rt.io);
|
||||
0, 0);
|
||||
this->rt.io.status = SPA_STATUS_NEED_BUFFER;
|
||||
|
||||
|
||||
|
|
@ -478,7 +476,7 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
|
|||
spa_node_port_set_io(node->node,
|
||||
port->direction, port_id,
|
||||
t->io.Buffers,
|
||||
port->rt.port.io, sizeof(*port->rt.port.io));
|
||||
&port->rt.io, sizeof(port->rt.io));
|
||||
|
||||
if (node->global)
|
||||
pw_port_register(port, node->global->owner, node->global,
|
||||
|
|
|
|||
|
|
@ -1178,13 +1178,13 @@ client_node_port_set_io(void *object,
|
|||
spa_type_map_get_type(core->type.map, id), ptr);
|
||||
|
||||
if (id == t->io.Buffers) {
|
||||
if (ptr == NULL && mix->mix.port.io) {
|
||||
if (ptr == NULL && mix->mix.io) {
|
||||
deactivate_mix(data, mix);
|
||||
m = find_mem_ptr(data, mix->mix.port.io);
|
||||
m = find_mem_ptr(data, mix->mix.io);
|
||||
if (m && --m->ref == 0)
|
||||
clear_mem(data, m);
|
||||
}
|
||||
mix->mix.port.io = ptr;
|
||||
mix->mix.io = ptr;
|
||||
if (ptr)
|
||||
activate_mix(data, mix);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue