From 16665d74d27fdf2445bf050a0a64c9c6480fef6d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 3 Dec 2021 16:43:16 +0100 Subject: [PATCH] pulse-server: don't clamp missing bytes to tlength When we increase the quantum past the tlength, we need to be able to ask for more bytes than the tlength or else we will never exit this underrun state. Look at the last required bytes and use that if it's larger then tlength. --- src/modules/module-protocol-pulse/pulse-server.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 977f9f714..49ed91c67 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -1096,6 +1096,7 @@ struct process_data { uint32_t underrun_for; uint32_t playing_for; uint32_t missing; + uint32_t maxmissing; unsigned int underrun:1; }; @@ -1134,7 +1135,7 @@ do_process_done(struct spa_loop *loop, stream_send_started(stream); } stream->missing += pd->missing; - stream->missing = SPA_MIN(stream->missing, stream->attr.tlength); + stream->missing = SPA_MIN(stream->missing, pd->maxmissing); stream->playing_for += pd->playing_for; if (stream->underrun_for != (uint64_t)-1) stream->underrun_for += pd->underrun_for; @@ -1228,6 +1229,8 @@ static void stream_process(void *data) if (minreq == 0) minreq = stream->attr.minreq; + pd.maxmissing = SPA_MAX(minreq, stream->attr.tlength); + if (avail < (int32_t)minreq || stream->corked) { /* underrun, produce a silence buffer */ size = SPA_MIN(buf->datas[0].maxsize, minreq);