alsa: increase buffers when using small buffer

We can increase the MAX_LATENCY again if we increase the amount of
buffers when we are using a small buffer.

Normally we ask for 4 * quantum-limit as the buffer. This should be good
to use 1 buffer and quantum-limit as the quantum with enough headroom
to not run out of buffers.

If we are however using less buffer-frames we need to be careful and
allocate an extra buffer. Imagine using a buffer of 4096 frames, we can
support a quantum of up to 2048 frames if we use 2 buffers.

See #3744
This commit is contained in:
Wim Taymans 2024-01-22 12:10:51 +01:00
parent 7e1e05f0da
commit 6ee48f0562
2 changed files with 8 additions and 2 deletions

View file

@ -3535,7 +3535,7 @@ 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 / (4 * state->frame_scale), state->rate);
state->buffer_frames / (2 * state->frame_scale), state->rate);
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_MAX_LATENCY, latency);
snprintf(period, sizeof(period), "%lu", state->period_frames);
items[n_items++] = SPA_DICT_ITEM_INIT("api.alsa.period-size", period);