From b60d7bf2bc350bc3212aca999101669ede7328b2 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 3 Mar 2020 13:28:21 +0100 Subject: [PATCH] examples: always use last buffers Skip buffers and always use the last buffer in the queue. This compensates for slow reading clients. --- src/examples/video-dsp-play.c | 11 ++++++++++- src/examples/video-play.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/examples/video-dsp-play.c b/src/examples/video-dsp-play.c index 42c19064f..c76f6c248 100644 --- a/src/examples/video-dsp-play.c +++ b/src/examples/video-dsp-play.c @@ -100,7 +100,16 @@ on_process(void *_data, struct spa_io_position *position) uint32_t i, j; uint8_t *src, *dst; - if ((b = pw_filter_dequeue_buffer(data->in_port)) == NULL) { + b = NULL; + while (true) { + struct pw_buffer *t; + if ((t = pw_filter_dequeue_buffer(data->in_port)) == NULL) + break; + if (b) + pw_filter_queue_buffer(data->in_port, b); + b = t; + } + if (b == NULL) { pw_log_warn("out of buffers: %m"); return; } diff --git a/src/examples/video-play.c b/src/examples/video-play.c index 46ef446f5..546df19a9 100644 --- a/src/examples/video-play.c +++ b/src/examples/video-play.c @@ -104,7 +104,16 @@ on_process(void *_data) uint8_t *src, *dst; bool render_cursor = false; - if ((b = pw_stream_dequeue_buffer(stream)) == NULL) { + b = NULL; + while (true) { + struct pw_buffer *t; + if ((t = pw_stream_dequeue_buffer(stream)) == NULL) + break; + if (b) + pw_stream_queue_buffer(stream, b); + b = t; + } + if (b == NULL) { pw_log_warn("out of buffers: %m"); return; }