module-echo-cancel: drop samples when source not ready

When we can't dequeue a buffer from the source stream, drop the samples
instead of leaving them queued in the ringbuffer.
This commit is contained in:
Wim Taymans 2025-10-17 14:51:14 +02:00
parent f70b0892ea
commit fb49759d1f

View file

@ -431,23 +431,22 @@ static void process(struct impl *impl)
avail = spa_ringbuffer_get_read_index(&impl->out_ring, &oindex);
while (avail >= size) {
if ((cout = pw_stream_dequeue_buffer(impl->source)) == NULL) {
if ((cout = pw_stream_dequeue_buffer(impl->source)) != NULL) {
for (i = 0; i < impl->out_info.channels; i++) {
dd = &cout->buffer->datas[i];
spa_ringbuffer_read_data(&impl->out_ring, impl->out_buffer[i],
impl->out_ringsize, oindex % impl->out_ringsize,
(void *)dd->data, size);
dd->chunk->offset = 0;
dd->chunk->size = size;
dd->chunk->stride = sizeof(float);
}
pw_stream_queue_buffer(impl->source, cout);
} else {
/* drop data as to not cause delay */
pw_log_debug("out of source buffers: %m");
break;
}
for (i = 0; i < impl->out_info.channels; i++) {
dd = &cout->buffer->datas[i];
spa_ringbuffer_read_data(&impl->out_ring, impl->out_buffer[i],
impl->out_ringsize, oindex % impl->out_ringsize,
(void *)dd->data, size);
dd->chunk->offset = 0;
dd->chunk->size = size;
dd->chunk->stride = sizeof(float);
}
pw_stream_queue_buffer(impl->source, cout);
oindex += size;
spa_ringbuffer_read_update(&impl->out_ring, oindex);
avail -= size;