From dbaf450394ddb4eef8a45bdedcb7ae7a569e0304 Mon Sep 17 00:00:00 2001 From: Georg Chini Date: Sun, 16 May 2021 19:03:58 +0200 Subject: [PATCH] null-sink: Request no more than the configured latency from sink-input In the case, where the latency is larger than the maximum block size, module-null-sink will request multiples of the maximum block size from the sink input instead of limiting the requested amount of data to the the configured latency. This patch fixes the problem. Part-of: --- src/modules/module-null-sink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c index 6865663da..7cb52cbaf 100644 --- a/src/modules/module-null-sink.c +++ b/src/modules/module-null-sink.c @@ -223,8 +223,12 @@ static void process_render(struct userdata *u, pa_usec_t now) { /* Fill the buffer up the latency size */ while (u->timestamp < now + u->block_usec) { pa_memchunk chunk; + size_t request_size; + + request_size = pa_usec_to_bytes(now + u->block_usec - u->timestamp, &u->sink->sample_spec); + request_size = PA_MIN(request_size, u->sink->thread_info.max_request); + pa_sink_render(u->sink, request_size, &chunk); - pa_sink_render(u->sink, u->sink->thread_info.max_request, &chunk); pa_memblock_unref(chunk.memblock); /* pa_log_debug("Ate %lu bytes.", (unsigned long) chunk.length); */