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