mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
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:
parent
a0a32af386
commit
cfaf424ed8
2 changed files with 22 additions and 4 deletions
|
|
@ -685,7 +685,16 @@ static void playback_process(void *d)
|
|||
struct graph_port *port;
|
||||
struct spa_data *bd;
|
||||
|
||||
if ((in = pw_stream_dequeue_buffer(impl->capture)) == NULL)
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue