mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
port: remove port_pause
port_pause is not needed, spa elements should pause themselves when setting NULL format or buffers. Handle use_buffer or alloc_buffer error cases. Clear buffers in the port before cleaning up the memory.
This commit is contained in:
parent
f2f94c4f72
commit
8a4f3c546d
3 changed files with 22 additions and 28 deletions
|
|
@ -424,16 +424,6 @@ int pw_port_send_command(struct pw_port *port, bool block, const struct spa_comm
|
||||||
command, SPA_POD_SIZE(command), block, port);
|
command, SPA_POD_SIZE(command), block, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pw_port_pause(struct pw_port *port)
|
|
||||||
{
|
|
||||||
if (port->state > PW_PORT_STATE_PAUSED) {
|
|
||||||
pw_port_send_command(port, true,
|
|
||||||
&SPA_COMMAND_INIT(port->node->core->type.command_node.Pause));
|
|
||||||
port_update_state (port, PW_PORT_STATE_PAUSED);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pw_port_for_each_param(struct pw_port *port,
|
int pw_port_for_each_param(struct pw_port *port,
|
||||||
uint32_t param_id,
|
uint32_t param_id,
|
||||||
const struct spa_pod *filter,
|
const struct spa_pod *filter,
|
||||||
|
|
@ -535,8 +525,6 @@ int pw_port_use_buffers(struct pw_port *port, struct spa_buffer **buffers, uint3
|
||||||
if (n_buffers > 0 && port->state < PW_PORT_STATE_READY)
|
if (n_buffers > 0 && port->state < PW_PORT_STATE_READY)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
pw_port_pause(port);
|
|
||||||
|
|
||||||
res = spa_node_port_use_buffers(node->node, port->direction, port->port_id, buffers, n_buffers);
|
res = spa_node_port_use_buffers(node->node, port->direction, port->port_id, buffers, n_buffers);
|
||||||
pw_log_debug("port %p: use %d buffers: %d (%s)", port, n_buffers, res, spa_strerror(res));
|
pw_log_debug("port %p: use %d buffers: %d (%s)", port, n_buffers, res, spa_strerror(res));
|
||||||
|
|
||||||
|
|
@ -544,11 +532,16 @@ int pw_port_use_buffers(struct pw_port *port, struct spa_buffer **buffers, uint3
|
||||||
free(port->buffers);
|
free(port->buffers);
|
||||||
pw_memblock_free(port->buffer_mem);
|
pw_memblock_free(port->buffer_mem);
|
||||||
}
|
}
|
||||||
port->buffers = buffers;
|
if (res < 0) {
|
||||||
port->n_buffers = n_buffers;
|
port->buffers = NULL;
|
||||||
|
port->n_buffers = 0;
|
||||||
|
} else {
|
||||||
|
port->buffers = buffers;
|
||||||
|
port->n_buffers = n_buffers;
|
||||||
|
}
|
||||||
port->allocated = false;
|
port->allocated = false;
|
||||||
|
|
||||||
if (n_buffers == 0)
|
if (port->n_buffers == 0)
|
||||||
port_update_state (port, PW_PORT_STATE_READY);
|
port_update_state (port, PW_PORT_STATE_READY);
|
||||||
else if (!SPA_RESULT_IS_ASYNC(res))
|
else if (!SPA_RESULT_IS_ASYNC(res))
|
||||||
port_update_state (port, PW_PORT_STATE_PAUSED);
|
port_update_state (port, PW_PORT_STATE_PAUSED);
|
||||||
|
|
@ -566,8 +559,6 @@ int pw_port_alloc_buffers(struct pw_port *port,
|
||||||
if (port->state < PW_PORT_STATE_READY)
|
if (port->state < PW_PORT_STATE_READY)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
pw_port_pause(port);
|
|
||||||
|
|
||||||
res = spa_node_port_alloc_buffers(node->node, port->direction, port->port_id,
|
res = spa_node_port_alloc_buffers(node->node, port->direction, port->port_id,
|
||||||
params, n_params,
|
params, n_params,
|
||||||
buffers, n_buffers);
|
buffers, n_buffers);
|
||||||
|
|
@ -577,11 +568,20 @@ int pw_port_alloc_buffers(struct pw_port *port,
|
||||||
free(port->buffers);
|
free(port->buffers);
|
||||||
pw_memblock_free(port->buffer_mem);
|
pw_memblock_free(port->buffer_mem);
|
||||||
}
|
}
|
||||||
port->buffers = buffers;
|
if (res < 0) {
|
||||||
port->n_buffers = *n_buffers;
|
port->buffers = NULL;
|
||||||
port->allocated = true;
|
port->n_buffers = 0;
|
||||||
|
port->allocated = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
port->buffers = buffers;
|
||||||
|
port->n_buffers = *n_buffers;
|
||||||
|
port->allocated = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!SPA_RESULT_IS_ASYNC(res))
|
if (port->n_buffers == 0)
|
||||||
|
port_update_state (port, PW_PORT_STATE_READY);
|
||||||
|
else if (!SPA_RESULT_IS_ASYNC(res))
|
||||||
port_update_state (port, PW_PORT_STATE_PAUSED);
|
port_update_state (port, PW_PORT_STATE_PAUSED);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
||||||
|
|
@ -502,9 +502,6 @@ int pw_port_alloc_buffers(struct pw_port *port,
|
||||||
/** Send a command to a port */
|
/** Send a command to a port */
|
||||||
int pw_port_send_command(struct pw_port *port, bool block, const struct spa_command *command);
|
int pw_port_send_command(struct pw_port *port, bool block, const struct spa_command *command);
|
||||||
|
|
||||||
/** pause the port */
|
|
||||||
int pw_port_pause(struct pw_port *port);
|
|
||||||
|
|
||||||
/** Change the state of the node */
|
/** Change the state of the node */
|
||||||
int pw_node_set_state(struct pw_node *node, enum pw_node_state state);
|
int pw_node_set_state(struct pw_node *node, enum pw_node_state state);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -945,8 +945,6 @@ client_node_port_set_param(void *object,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_port_pause(port->port);
|
|
||||||
|
|
||||||
res = pw_port_set_param(port->port, id, flags, param);
|
res = pw_port_set_param(port->port, id, flags, param);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -965,6 +963,7 @@ static void clear_buffers(struct node_data *data, struct port *port)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
pw_log_debug("port %p: clear buffers", port);
|
pw_log_debug("port %p: clear buffers", port);
|
||||||
|
pw_port_use_buffers(port->port, NULL, 0);
|
||||||
|
|
||||||
pw_array_for_each(bid, &port->buffer_ids) {
|
pw_array_for_each(bid, &port->buffer_ids) {
|
||||||
if (bid->ptr != NULL) {
|
if (bid->ptr != NULL) {
|
||||||
|
|
@ -1008,8 +1007,6 @@ client_node_port_use_buffers(void *object,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_port_pause(port->port);
|
|
||||||
|
|
||||||
prot = PROT_READ | (direction == SPA_DIRECTION_OUTPUT ? PROT_WRITE : 0);
|
prot = PROT_READ | (direction == SPA_DIRECTION_OUTPUT ? PROT_WRITE : 0);
|
||||||
|
|
||||||
/* clear previous buffers */
|
/* clear previous buffers */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue