mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
link: improve buffer negotiation
Don't free the buffers when the mix is released, this will happen when nothing is using them anymore with port_use_buffers later. Mark a mixer as having buffers when the output port has buffers. Don't set buffers on a mixer port that already has buffers.
This commit is contained in:
parent
d98a6d22d5
commit
ba118e26a3
2 changed files with 26 additions and 31 deletions
|
|
@ -1319,7 +1319,6 @@ static int port_release_mix(void *data, struct pw_port_mix *mix)
|
||||||
{
|
{
|
||||||
struct port *port = data;
|
struct port *port = data;
|
||||||
struct impl *impl = port->impl;
|
struct impl *impl = port->impl;
|
||||||
struct node *this = &impl->node;
|
|
||||||
struct mix *m;
|
struct mix *m;
|
||||||
|
|
||||||
pw_log_debug(NAME " %p: remove mix io %d %p %p", impl, mix->id, mix->io,
|
pw_log_debug(NAME " %p: remove mix io %d %p %p", impl, mix->id, mix->io,
|
||||||
|
|
@ -1329,7 +1328,8 @@ static int port_release_mix(void *data, struct pw_port_mix *mix)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
pw_map_remove(&impl->io_map, mix->id);
|
pw_map_remove(&impl->io_map, mix->id);
|
||||||
mix_clear(this, m);
|
m->valid = false;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -584,9 +584,9 @@ static int do_allocation(struct pw_link *this)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output->allocation.n_buffers) {
|
if (output->allocation.n_buffers) {
|
||||||
move_allocation(&output->allocation, &allocation);
|
|
||||||
pw_log_debug("link %p: reusing %d output buffers %p", this,
|
pw_log_debug("link %p: reusing %d output buffers %p", this,
|
||||||
allocation.n_buffers, allocation.buffers);
|
output->allocation.n_buffers, output->allocation.buffers);
|
||||||
|
this->rt.out_mix.have_buffers = true;
|
||||||
} else {
|
} else {
|
||||||
struct spa_pod **params, *param;
|
struct spa_pod **params, *param;
|
||||||
uint8_t buffer[4096];
|
uint8_t buffer[4096];
|
||||||
|
|
@ -676,41 +676,36 @@ static int do_allocation(struct pw_link *this)
|
||||||
}
|
}
|
||||||
out_res = res;
|
out_res = res;
|
||||||
out_alloc = true;
|
out_alloc = true;
|
||||||
move_allocation(&allocation, &output->allocation);
|
|
||||||
|
|
||||||
pw_log_debug("link %p: allocated %d buffers %p from output port: %s", this,
|
pw_log_debug("link %p: allocated %d buffers %p from output port: %s", this,
|
||||||
allocation.n_buffers, allocation.buffers, spa_strerror(out_res));
|
allocation.n_buffers, allocation.buffers, spa_strerror(out_res));
|
||||||
|
} else {
|
||||||
|
pw_log_debug("link %p: using %d buffers %p on output port", this,
|
||||||
|
allocation.n_buffers, allocation.buffers);
|
||||||
|
|
||||||
|
if ((res = pw_port_use_buffers(output,
|
||||||
|
this->rt.out_mix.port.port_id, 0,
|
||||||
|
allocation.buffers,
|
||||||
|
allocation.n_buffers)) < 0) {
|
||||||
|
asprintf(&error, "link %p: error use output buffers: %s", this,
|
||||||
|
spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
out_res = res;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!out_alloc) {
|
|
||||||
pw_log_debug("link %p: using %d buffers %p on output port", this,
|
|
||||||
allocation.n_buffers, allocation.buffers);
|
|
||||||
|
|
||||||
if ((res = pw_port_use_buffers(output,
|
|
||||||
this->rt.out_mix.port.port_id, 0,
|
|
||||||
allocation.buffers,
|
|
||||||
allocation.n_buffers)) < 0) {
|
|
||||||
asprintf(&error, "link %p: error use output buffers: %s", this,
|
|
||||||
spa_strerror(res));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
out_res = res;
|
|
||||||
|
|
||||||
move_allocation(&allocation, &output->allocation);
|
move_allocation(&allocation, &output->allocation);
|
||||||
}
|
|
||||||
|
|
||||||
if (SPA_RESULT_IS_ASYNC(out_res)) {
|
if (SPA_RESULT_IS_ASYNC(out_res)) {
|
||||||
pw_work_queue_add(impl->work, output->node,
|
pw_work_queue_add(impl->work, output->node,
|
||||||
spa_node_sync(output->node->node, out_res),
|
spa_node_sync(output->node->node, out_res),
|
||||||
complete_paused, this);
|
complete_paused, this);
|
||||||
if (out_alloc)
|
if (out_alloc)
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
complete_paused(output->node, this, out_res, 0);
|
complete_paused(output->node, this, out_res, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pw_log_debug("link %p: using %d buffers %p on input port", this,
|
pw_log_debug("link %p: using %d buffers %p on input port", this,
|
||||||
output->allocation.n_buffers, output->allocation.buffers);
|
output->allocation.n_buffers, output->allocation.buffers);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue