mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-14 05:34:06 -04:00
adapter: fix buffer alloc order
Prefer to let the follower allocate buffers. If we are allocating buffers, first do use_buffers on the allocating node or else the non-allocating node just ends up with NULL buffers.
This commit is contained in:
parent
afb4a2f49c
commit
abc03ec810
2 changed files with 44 additions and 18 deletions
|
|
@ -431,6 +431,9 @@ static int negotiate_buffers(struct impl *this)
|
||||||
uint32_t *aligns, data_flags;
|
uint32_t *aligns, data_flags;
|
||||||
struct spa_data *datas;
|
struct spa_data *datas;
|
||||||
uint64_t follower_flags, conv_flags;
|
uint64_t follower_flags, conv_flags;
|
||||||
|
struct spa_node *alloc_node;
|
||||||
|
enum spa_direction alloc_direction;
|
||||||
|
uint32_t alloc_flags;
|
||||||
|
|
||||||
spa_log_debug(this->log, "%p: n_buffers:%d", this, this->n_buffers);
|
spa_log_debug(this->log, "%p: n_buffers:%d", this, this->n_buffers);
|
||||||
|
|
||||||
|
|
@ -476,11 +479,10 @@ static int negotiate_buffers(struct impl *this)
|
||||||
follower_alloc = SPA_FLAG_IS_SET(follower_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
|
follower_alloc = SPA_FLAG_IS_SET(follower_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
|
||||||
conv_alloc = SPA_FLAG_IS_SET(conv_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
|
conv_alloc = SPA_FLAG_IS_SET(conv_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
|
||||||
|
|
||||||
flags = 0;
|
flags = alloc_flags = 0;
|
||||||
if (conv_alloc || follower_alloc) {
|
if (conv_alloc || follower_alloc) {
|
||||||
flags |= SPA_BUFFER_ALLOC_FLAG_NO_DATA;
|
flags |= SPA_BUFFER_ALLOC_FLAG_NO_DATA;
|
||||||
if (conv_alloc)
|
alloc_flags = SPA_NODE_BUFFERS_FLAG_ALLOC;
|
||||||
follower_alloc = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
align = DEFAULT_ALIGN;
|
align = DEFAULT_ALIGN;
|
||||||
|
|
@ -524,15 +526,26 @@ static int negotiate_buffers(struct impl *this)
|
||||||
return -errno;
|
return -errno;
|
||||||
this->n_buffers = buffers;
|
this->n_buffers = buffers;
|
||||||
|
|
||||||
if ((res = spa_node_port_use_buffers(this->target,
|
/* prefer to let the follower alloc */
|
||||||
SPA_DIRECTION_REVERSE(this->direction), 0,
|
if (follower_alloc) {
|
||||||
conv_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
|
alloc_node = this->follower;
|
||||||
|
alloc_direction = this->direction;
|
||||||
|
} else {
|
||||||
|
alloc_node = this->target;
|
||||||
|
alloc_direction = SPA_DIRECTION_REVERSE(this->direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((res = spa_node_port_use_buffers(alloc_node,
|
||||||
|
alloc_direction, 0, alloc_flags,
|
||||||
this->buffers, this->n_buffers)) < 0)
|
this->buffers, this->n_buffers)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
if ((res = spa_node_port_use_buffers(this->follower,
|
alloc_node = alloc_node == this->follower ? this->target : this->follower;
|
||||||
this->direction, 0,
|
alloc_direction = SPA_DIRECTION_REVERSE(alloc_direction);
|
||||||
follower_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
|
alloc_flags = 0;
|
||||||
|
|
||||||
|
if ((res = spa_node_port_use_buffers(alloc_node,
|
||||||
|
alloc_direction, 0, alloc_flags,
|
||||||
this->buffers, this->n_buffers)) < 0)
|
this->buffers, this->n_buffers)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -432,6 +432,9 @@ static int negotiate_buffers(struct impl *this)
|
||||||
struct spa_data *datas;
|
struct spa_data *datas;
|
||||||
struct spa_meta metas[1];
|
struct spa_meta metas[1];
|
||||||
uint64_t follower_flags, conv_flags;
|
uint64_t follower_flags, conv_flags;
|
||||||
|
struct spa_node *alloc_node;
|
||||||
|
enum spa_direction alloc_direction;
|
||||||
|
uint32_t alloc_flags;
|
||||||
|
|
||||||
spa_log_debug(this->log, "%p: n_buffers:%d", this, this->n_buffers);
|
spa_log_debug(this->log, "%p: n_buffers:%d", this, this->n_buffers);
|
||||||
|
|
||||||
|
|
@ -477,11 +480,10 @@ static int negotiate_buffers(struct impl *this)
|
||||||
follower_alloc = SPA_FLAG_IS_SET(follower_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
|
follower_alloc = SPA_FLAG_IS_SET(follower_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
|
||||||
conv_alloc = SPA_FLAG_IS_SET(conv_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
|
conv_alloc = SPA_FLAG_IS_SET(conv_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
|
||||||
|
|
||||||
flags = 0;
|
flags = alloc_flags = 0;
|
||||||
if (conv_alloc || follower_alloc) {
|
if (conv_alloc || follower_alloc) {
|
||||||
flags |= SPA_BUFFER_ALLOC_FLAG_NO_DATA;
|
flags |= SPA_BUFFER_ALLOC_FLAG_NO_DATA;
|
||||||
if (conv_alloc)
|
alloc_flags = SPA_NODE_BUFFERS_FLAG_ALLOC;
|
||||||
follower_alloc = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
align = DEFAULT_ALIGN;
|
align = DEFAULT_ALIGN;
|
||||||
|
|
@ -527,15 +529,26 @@ static int negotiate_buffers(struct impl *this)
|
||||||
return -errno;
|
return -errno;
|
||||||
this->n_buffers = buffers;
|
this->n_buffers = buffers;
|
||||||
|
|
||||||
if ((res = spa_node_port_use_buffers(this->target,
|
/* prefer to let the follower alloc */
|
||||||
SPA_DIRECTION_REVERSE(this->direction), 0,
|
if (follower_alloc) {
|
||||||
conv_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
|
alloc_node = this->follower;
|
||||||
|
alloc_direction = this->direction;
|
||||||
|
} else {
|
||||||
|
alloc_node = this->target;
|
||||||
|
alloc_direction = SPA_DIRECTION_REVERSE(this->direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((res = spa_node_port_use_buffers(alloc_node,
|
||||||
|
alloc_direction, 0, alloc_flags,
|
||||||
this->buffers, this->n_buffers)) < 0)
|
this->buffers, this->n_buffers)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
if ((res = spa_node_port_use_buffers(this->follower,
|
alloc_node = alloc_node == this->follower ? this->target : this->follower;
|
||||||
this->direction, 0,
|
alloc_direction = SPA_DIRECTION_REVERSE(alloc_direction);
|
||||||
follower_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
|
alloc_flags = 0;
|
||||||
|
|
||||||
|
if ((res = spa_node_port_use_buffers(alloc_node,
|
||||||
|
alloc_direction, 0, alloc_flags,
|
||||||
this->buffers, this->n_buffers)) < 0)
|
this->buffers, this->n_buffers)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue