module-loopback: always dequeue the last capture buffer

Because the capture triggers the playback stream, the playback stream
might not be actually triggered when the stream is not running.

This can cause a buffer to be queued in the capture side that is never
dequeued from the playback side. If 2 buffers are queued (and 2 buffers
are available on the stream), the capture source has no more buffers and
starts to drop/stutter.

Fix this problem by always dequeueing/queuing all the queued buffers so
that we always use the last one.

See #3276
This commit is contained in:
Wim Taymans 2023-06-16 11:12:51 +02:00
parent a0a32af386
commit cfaf424ed8
2 changed files with 22 additions and 4 deletions

View file

@ -233,11 +233,20 @@ static void playback_process(void *d)
impl->recalc_delay = false;
}
if ((in = pw_stream_dequeue_buffer(impl->capture)) == NULL)
pw_log_debug("out of capture buffers: %m");
in = NULL;
while (true) {
struct pw_buffer *t;
if ((t = pw_stream_dequeue_buffer(impl->capture)) == NULL)
break;
if (in)
pw_stream_queue_buffer(impl->capture, in);
in = t;
}
if (in == NULL)
pw_log_debug("%p: out of capture buffers: %m", impl);
if ((out = pw_stream_dequeue_buffer(impl->playback)) == NULL)
pw_log_debug("out of playback buffers: %m");
pw_log_debug("%p: out of playback buffers: %m", impl);
if (in != NULL && out != NULL) {
uint32_t outsize = UINT32_MAX;