mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-21 08:56:56 -05:00
audioconvert: mark ports and buffers as DYNAMIC
Only passthrough buffer data when the buffer and ports are marked as DYNAMIC. Use extra buffer for nodes that keep a ref on buffers (resample).
This commit is contained in:
parent
df5c81e3be
commit
036ca89c0e
11 changed files with 81 additions and 39 deletions
|
|
@ -98,7 +98,7 @@ static void init_buffer(struct port *port, uint32_t id)
|
|||
b->buf.n_datas = 1;
|
||||
b->buf.datas = b->datas;
|
||||
b->datas[0].type = SPA_DATA_MemPtr;
|
||||
b->datas[0].flags = 0;
|
||||
b->datas[0].flags = SPA_DATA_FLAG_DYNAMIC;
|
||||
b->datas[0].fd = -1;
|
||||
b->datas[0].mapoffset = 0;
|
||||
b->datas[0].maxsize = SPA_ROUND_DOWN_N(sizeof(port->empty), 16);
|
||||
|
|
|
|||
|
|
@ -242,9 +242,10 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
|
|||
SPA_PORT_CHANGE_MASK_PARAMS;
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_FLAG_NO_REF |
|
||||
SPA_PORT_FLAG_DYNAMIC_DATA |
|
||||
SPA_PORT_FLAG_REMOVABLE |
|
||||
SPA_PORT_FLAG_OPTIONAL |
|
||||
SPA_PORT_FLAG_IN_PLACE;
|
||||
SPA_PORT_FLAG_OPTIONAL;
|
||||
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
|
||||
port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
|
||||
port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
|
||||
|
|
@ -928,7 +929,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_FLAG_NO_REF;
|
||||
SPA_PORT_FLAG_DYNAMIC_DATA;
|
||||
port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
|
||||
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
|
||||
port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
|
||||
|
|
|
|||
|
|
@ -633,6 +633,7 @@ static int negotiate_buffers(struct impl *impl)
|
|||
aligns = alloca(sizeof(uint32_t) * blocks);
|
||||
for (i = 0; i < blocks; i++) {
|
||||
datas[i].type = SPA_DATA_MemPtr;
|
||||
datas[i].flags = SPA_DATA_FLAG_DYNAMIC;
|
||||
datas[i].maxsize = size;
|
||||
aligns[i] = align;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,6 +381,7 @@ static int alloc_buffers(struct pw_link *this,
|
|||
uint32_t *data_sizes,
|
||||
int32_t *data_strides,
|
||||
uint32_t *data_aligns,
|
||||
uint32_t flags,
|
||||
struct allocation *allocation)
|
||||
{
|
||||
int res;
|
||||
|
|
@ -419,6 +420,7 @@ static int alloc_buffers(struct pw_link *this,
|
|||
for (i = 0; i < n_datas; i++) {
|
||||
struct spa_data *d = &datas[i];
|
||||
|
||||
spa_zero(*d);
|
||||
if (data_sizes[i] > 0) {
|
||||
d->type = SPA_DATA_MemPtr;
|
||||
d->maxsize = data_sizes[i];
|
||||
|
|
@ -426,6 +428,8 @@ static int alloc_buffers(struct pw_link *this,
|
|||
d->type = SPA_ID_INVALID;
|
||||
d->maxsize = 0;
|
||||
}
|
||||
if (SPA_FLAG_CHECK(flags, SPA_PORT_FLAG_DYNAMIC_DATA))
|
||||
SPA_FLAG_SET(d->flags, SPA_DATA_FLAG_DYNAMIC);
|
||||
}
|
||||
|
||||
spa_buffer_alloc_fill_info(&info, n_metas, metas, n_datas, datas, data_aligns);
|
||||
|
|
@ -579,8 +583,8 @@ static int do_allocation(struct pw_link *this)
|
|||
}
|
||||
|
||||
if (output->allocation.n_buffers) {
|
||||
out_flags = SPA_PORT_FLAG_CAN_USE_BUFFERS;
|
||||
in_flags = SPA_PORT_FLAG_CAN_USE_BUFFERS;
|
||||
SPA_FLAG_UNSET(out_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
|
||||
SPA_FLAG_UNSET(in_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
|
||||
|
||||
move_allocation(&output->allocation, &allocation);
|
||||
|
||||
|
|
@ -659,6 +663,7 @@ static int do_allocation(struct pw_link *this)
|
|||
1,
|
||||
data_sizes, data_strides,
|
||||
data_aligns,
|
||||
in_flags & out_flags,
|
||||
&allocation)) < 0) {
|
||||
asprintf(&error, "error alloc buffers: %d", res);
|
||||
goto error;
|
||||
|
|
@ -676,7 +681,7 @@ static int do_allocation(struct pw_link *this)
|
|||
goto error;
|
||||
}
|
||||
out_res = res;
|
||||
out_flags &= ~SPA_PORT_FLAG_CAN_USE_BUFFERS;
|
||||
SPA_FLAG_UNSET(out_flags, SPA_PORT_FLAG_CAN_USE_BUFFERS);
|
||||
move_allocation(&allocation, &output->allocation);
|
||||
|
||||
pw_log_debug("link %p: allocated %d buffers %p from output port", this,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue