alsa: round to next power of 2 for max period_size

Prefer to make the period_size bigger rather than smaller because of
rate conversion.
This commit is contained in:
Wim Taymans 2023-08-31 17:22:38 +02:00
parent af020bc425
commit 6fb53fc9f1

View file

@ -1663,7 +1663,8 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
period_size = state->default_period_size;
is_batch = snd_pcm_hw_params_is_batch(params) && !state->disable_batch;
default_period = flp2(SPA_SCALE32_UP(DEFAULT_PERIOD, state->rate, DEFAULT_RATE));
default_period = SPA_SCALE32_UP(DEFAULT_PERIOD, state->rate, DEFAULT_RATE);
default_period = flp2(2 * default_period - 1);
/* no period size specified. If we are batch or not using timers,
* use the graph duration as the period */