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: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/554>
This commit is contained in:
Georg Chini 2021-05-16 19:03:58 +02:00 committed by PulseAudio Marge Bot
parent 80efd7a64c
commit dbaf450394

View file

@ -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); */