mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
port: improve buffer handling
Remove the buffers_move method, it's not needed.
This commit is contained in:
parent
d4fab985a2
commit
9c4e5f4e27
5 changed files with 20 additions and 28 deletions
|
|
@ -301,10 +301,3 @@ void pw_buffers_clear(struct pw_buffers *buffers)
|
|||
free(buffers->buffers);
|
||||
spa_zero(*buffers);
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
void pw_buffers_move(struct pw_buffers *dest, struct pw_buffers *src)
|
||||
{
|
||||
*dest = *src;
|
||||
spa_zero(*src);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ int pw_buffers_negotiate(struct pw_core *core, uint32_t flags,
|
|||
struct spa_node *innode, uint32_t in_port_id,
|
||||
struct pw_buffers *result);
|
||||
|
||||
void pw_buffers_move(struct pw_buffers *dest, struct pw_buffers *src);
|
||||
void pw_buffers_clear(struct pw_buffers *buffers);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -417,7 +417,6 @@ static int do_allocation(struct pw_link *this)
|
|||
uint32_t in_flags, out_flags;
|
||||
char *error = NULL;
|
||||
struct pw_port *input, *output;
|
||||
struct pw_buffers allocation = { NULL, };
|
||||
|
||||
if (this->info.state > PW_LINK_STATE_ALLOCATING)
|
||||
return 0;
|
||||
|
|
@ -441,9 +440,9 @@ static int do_allocation(struct pw_link *this)
|
|||
input->node->live = true;
|
||||
}
|
||||
|
||||
if (output->allocation.n_buffers) {
|
||||
if (output->buffers.n_buffers) {
|
||||
pw_log_debug(NAME" %p: reusing %d output buffers %p", this,
|
||||
output->allocation.n_buffers, output->allocation.buffers);
|
||||
output->buffers.n_buffers, output->buffers.buffers);
|
||||
this->rt.out_mix.have_buffers = true;
|
||||
} else {
|
||||
uint32_t flags, alloc_flags;
|
||||
|
|
@ -460,22 +459,21 @@ static int do_allocation(struct pw_link *this)
|
|||
if ((res = pw_buffers_negotiate(this->core, alloc_flags,
|
||||
output->node->node, output->port_id,
|
||||
input->node->node, input->port_id,
|
||||
&allocation)) < 0) {
|
||||
&output->buffers)) < 0) {
|
||||
asprintf(&error, "error alloc buffers: %s", spa_strerror(res));
|
||||
goto error;
|
||||
}
|
||||
|
||||
pw_log_debug(NAME" %p: allocating %d buffers %p", this,
|
||||
allocation.n_buffers, allocation.buffers);
|
||||
output->buffers.n_buffers, output->buffers.buffers);
|
||||
|
||||
if ((res = pw_port_use_buffers(output, &this->rt.out_mix,
|
||||
flags, allocation.buffers, allocation.n_buffers)) < 0) {
|
||||
if ((res = pw_port_use_buffers(output, &this->rt.out_mix, flags,
|
||||
output->buffers.buffers,
|
||||
output->buffers.n_buffers)) < 0) {
|
||||
asprintf(&error, "error use output buffers: %d (%s)", res,
|
||||
spa_strerror(res));
|
||||
goto error;
|
||||
}
|
||||
pw_buffers_move(&output->allocation, &allocation);
|
||||
|
||||
if (SPA_RESULT_IS_ASYNC(res)) {
|
||||
res = spa_node_sync(output->node->node, res),
|
||||
pw_work_queue_add(impl->work, output, res,
|
||||
|
|
@ -488,11 +486,11 @@ static int do_allocation(struct pw_link *this)
|
|||
}
|
||||
|
||||
pw_log_debug(NAME" %p: using %d buffers %p on input port", this,
|
||||
output->allocation.n_buffers, output->allocation.buffers);
|
||||
output->buffers.n_buffers, output->buffers.buffers);
|
||||
|
||||
if ((res = pw_port_use_buffers(input, &this->rt.in_mix, 0,
|
||||
output->allocation.buffers,
|
||||
output->allocation.n_buffers)) < 0) {
|
||||
output->buffers.buffers,
|
||||
output->buffers.n_buffers)) < 0) {
|
||||
asprintf(&error, "error use input buffers: %d (%s)", res,
|
||||
spa_strerror(res));
|
||||
goto error;
|
||||
|
|
@ -508,7 +506,7 @@ static int do_allocation(struct pw_link *this)
|
|||
return 0;
|
||||
|
||||
error:
|
||||
pw_buffers_clear(&output->allocation);
|
||||
pw_buffers_clear(&output->buffers);
|
||||
pw_link_update_state(this, PW_LINK_STATE_ERROR, error);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -984,7 +984,8 @@ void pw_port_destroy(struct pw_port *port)
|
|||
pw_log_debug(NAME" %p: free", port);
|
||||
pw_port_emit_free(port);
|
||||
|
||||
pw_buffers_clear(&port->allocation);
|
||||
pw_buffers_clear(&port->buffers);
|
||||
pw_buffers_clear(&port->mix_buffers);
|
||||
free((void*)port->error);
|
||||
|
||||
pw_map_clear(&port->mix_port_map);
|
||||
|
|
@ -1165,7 +1166,8 @@ int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags,
|
|||
pw_log_debug(NAME" %p: %d %p %d", port, port->state, param, res);
|
||||
|
||||
/* setting the format always destroys the negotiated buffers */
|
||||
pw_buffers_clear(&port->allocation);
|
||||
pw_buffers_clear(&port->buffers);
|
||||
pw_buffers_clear(&port->mix_buffers);
|
||||
|
||||
if (param == NULL || res < 0) {
|
||||
pw_port_update_state(port, PW_PORT_STATE_CONFIGURE, NULL);
|
||||
|
|
@ -1187,7 +1189,6 @@ static int negotiate_mixer_buffers(struct pw_port *port, uint32_t flags,
|
|||
return 0;
|
||||
|
||||
if (SPA_FLAG_IS_SET(port->mix_flags, PW_PORT_MIX_FLAG_NEGOTIATE)) {
|
||||
struct pw_buffers allocation = { NULL, };
|
||||
int alloc_flags;
|
||||
|
||||
/* try dynamic data */
|
||||
|
|
@ -1196,16 +1197,16 @@ static int negotiate_mixer_buffers(struct pw_port *port, uint32_t flags,
|
|||
pw_log_debug(NAME" %p: %d.%d negotiate buffers on node: %p",
|
||||
port, port->direction, port->port_id, node->node);
|
||||
|
||||
pw_buffers_clear(&port->mix_buffers);
|
||||
|
||||
if ((res = pw_buffers_negotiate(node->core, alloc_flags,
|
||||
port->mix, 0,
|
||||
node->node, port->port_id,
|
||||
&allocation)) < 0) {
|
||||
&port->mix_buffers)) < 0) {
|
||||
pw_log_warn(NAME" %p: can't negotiate buffers: %s",
|
||||
port, spa_strerror(res));
|
||||
return res;
|
||||
}
|
||||
pw_buffers_clear(&port->mix_buffers);
|
||||
pw_buffers_move(&port->mix_buffers, &allocation);
|
||||
buffers = port->mix_buffers.buffers;
|
||||
n_buffers = port->mix_buffers.n_buffers;
|
||||
flags = 0;
|
||||
|
|
|
|||
|
|
@ -565,7 +565,8 @@ struct pw_port {
|
|||
struct pw_port_info info;
|
||||
struct spa_param_info params[MAX_PARAMS];
|
||||
|
||||
struct pw_buffers allocation;
|
||||
struct pw_buffers buffers; /**< buffers managed by this port, only on
|
||||
* output ports, shared with all links */
|
||||
|
||||
struct spa_list links; /**< list of \ref pw_link */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue