mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
alsa: fix buffer recycle
We only set the OUT flag when we put the buffer on an io area and might need to recycle later. Before placing the output buffer into the io area, recycle any buffer that might be left in there. Only emit the ready callback when we have some data queued.
This commit is contained in:
parent
acccccd2c0
commit
441fdb2333
3 changed files with 31 additions and 22 deletions
|
|
@ -337,17 +337,6 @@ static int impl_node_remove_port(void *object, enum spa_direction direction, uin
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static void recycle_buffer(struct state *this, uint32_t buffer_id)
|
||||
{
|
||||
struct buffer *b = &this->buffers[buffer_id];
|
||||
|
||||
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_OUT)) {
|
||||
spa_log_trace_fp(this->log, NAME " %p: recycle buffer %u", this, buffer_id);
|
||||
spa_list_append(&this->free, &b->link);
|
||||
SPA_FLAG_CLEAR(b->flags, BUFFER_FLAG_OUT);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_enum_params(void *object, int seq,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
|
@ -623,7 +612,7 @@ static int impl_node_port_reuse_buffer(void *object, uint32_t port_id, uint32_t
|
|||
if (buffer_id >= this->n_buffers)
|
||||
return -EINVAL;
|
||||
|
||||
recycle_buffer(this, buffer_id);
|
||||
spa_alsa_recycle_buffer(this, buffer_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -643,7 +632,7 @@ static int impl_node_process(void *object)
|
|||
return SPA_STATUS_HAVE_DATA;
|
||||
|
||||
if (io->buffer_id < this->n_buffers) {
|
||||
recycle_buffer(this, io->buffer_id);
|
||||
spa_alsa_recycle_buffer(this, io->buffer_id);
|
||||
io->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
|
|
@ -655,6 +644,7 @@ static int impl_node_process(void *object)
|
|||
|
||||
b = spa_list_first(&this->ready, struct buffer, link);
|
||||
spa_list_remove(&b->link);
|
||||
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUT);
|
||||
|
||||
spa_log_trace_fp(this->log, NAME " %p: dequeue buffer %d", this, b->id);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue