From c5b845bc908754e06bac15caf0da064f4cb7b63c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 22 Jan 2024 10:16:23 +0100 Subject: [PATCH] alsa: improve max-latency property Half of the buffersize is not enough to support as a max-quantum, we need to divide by (4 * frame_scale) to allow some headroom and account for the DSD scaling. We do the same calculation to suggest a buffer size using the quantum-limit. See #3744 --- spa/plugins/alsa/alsa-pcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index c6da1dd5a..967fca247 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -3535,7 +3535,8 @@ void spa_alsa_emit_node_info(struct state *state, bool full) items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_DRIVER, "true"); if (state->have_format) - snprintf(latency, sizeof(latency), "%lu/%d", state->buffer_frames / 2, state->rate); + snprintf(latency, sizeof(latency), "%lu/%d", + state->buffer_frames / (4 * state->frame_scale), state->rate); items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_MAX_LATENCY, latency[0] ? latency : NULL); if (state->have_format)