mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-26 07:58:03 -04:00
Merge branch 'bugfix/clean-up-io-structure-on-node-pause' into 'master'
Clean up port's io struct when node is paused Closes #5190 See merge request pipewire/pipewire!2760
This commit is contained in:
commit
ff5decc3cf
2 changed files with 30 additions and 17 deletions
|
|
@ -1571,6 +1571,8 @@ int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
|
||||||
int impl_node_send_command(void *object, const struct spa_command *command)
|
int impl_node_send_command(void *object, const struct spa_command *command)
|
||||||
{
|
{
|
||||||
struct impl *impl = (struct impl*)object;
|
struct impl *impl = (struct impl*)object;
|
||||||
|
struct port *port;
|
||||||
|
struct spa_io_buffers *io;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
spa_return_val_if_fail(impl != nullptr, -EINVAL);
|
spa_return_val_if_fail(impl != nullptr, -EINVAL);
|
||||||
|
|
@ -1592,8 +1594,13 @@ int impl_node_send_command(void *object, const struct spa_command *command)
|
||||||
}
|
}
|
||||||
case SPA_NODE_COMMAND_Pause:
|
case SPA_NODE_COMMAND_Pause:
|
||||||
case SPA_NODE_COMMAND_Suspend:
|
case SPA_NODE_COMMAND_Suspend:
|
||||||
if ((res = spa_libcamera_stream_off(impl)) < 0)
|
spa_libcamera_stream_off(impl);
|
||||||
return res;
|
port = GET_OUT_PORT(impl, 0);
|
||||||
|
io = port->io;
|
||||||
|
if (io && (io->buffer_id < port->n_buffers)) {
|
||||||
|
spa_libcamera_buffer_recycle(impl, port, io->buffer_id);
|
||||||
|
io->buffer_id = SPA_ID_INVALID;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
|
||||||
|
|
@ -334,10 +334,25 @@ static void on_output(void* data, uint64_t expirations)
|
||||||
spa_node_call_ready(&this->callbacks, res);
|
spa_node_call_ready(&this->callbacks, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void reuse_buffer(struct impl *this, struct port *port, uint32_t id)
|
||||||
|
{
|
||||||
|
struct buffer *b = &port->buffers[id];
|
||||||
|
spa_return_if_fail(b->outstanding);
|
||||||
|
|
||||||
|
spa_log_trace(this->log, "%p: reuse buffer %d", this, id);
|
||||||
|
|
||||||
|
b->outstanding = false;
|
||||||
|
spa_list_append(&port->empty, &b->link);
|
||||||
|
|
||||||
|
if (!this->props.live)
|
||||||
|
set_timer(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
static int impl_node_send_command(void *object, const struct spa_command *command)
|
static int impl_node_send_command(void *object, const struct spa_command *command)
|
||||||
{
|
{
|
||||||
struct impl *this = object;
|
struct impl *this = object;
|
||||||
struct port *port;
|
struct port *port;
|
||||||
|
struct spa_io_buffers *io;
|
||||||
|
|
||||||
spa_return_val_if_fail(this != NULL, -EINVAL);
|
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||||
|
|
@ -375,6 +390,11 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
|
||||||
return 0;
|
return 0;
|
||||||
this->started = false;
|
this->started = false;
|
||||||
set_timer(this, false);
|
set_timer(this, false);
|
||||||
|
io = port->io;
|
||||||
|
if (io && (io->buffer_id < port->n_buffers)) {
|
||||||
|
reuse_buffer(this, port, io->buffer_id);
|
||||||
|
io->buffer_id = SPA_ID_INVALID;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
@ -513,7 +533,7 @@ impl_node_port_enum_params(void *object, int seq,
|
||||||
|
|
||||||
result.id = id;
|
result.id = id;
|
||||||
result.next = start;
|
result.next = start;
|
||||||
next:
|
next:
|
||||||
result.index = result.next++;
|
result.index = result.next++;
|
||||||
|
|
||||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||||
|
|
@ -746,20 +766,6 @@ impl_node_port_set_io(void *object,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void reuse_buffer(struct impl *this, struct port *port, uint32_t id)
|
|
||||||
{
|
|
||||||
struct buffer *b = &port->buffers[id];
|
|
||||||
spa_return_if_fail(b->outstanding);
|
|
||||||
|
|
||||||
spa_log_trace(this->log, "%p: reuse buffer %d", this, id);
|
|
||||||
|
|
||||||
b->outstanding = false;
|
|
||||||
spa_list_append(&port->empty, &b->link);
|
|
||||||
|
|
||||||
if (!this->props.live)
|
|
||||||
set_timer(this, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int impl_node_port_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id)
|
static int impl_node_port_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id)
|
||||||
{
|
{
|
||||||
struct impl *this = object;
|
struct impl *this = object;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue