alsa: limit batch period size to default

We take half of the current quantum as the period size for batch
devices. Limit this to the default quantum to ensure we don't end up
with too much headroom.
This commit is contained in:
Wim Taymans 2022-01-11 16:33:19 +01:00
parent 59042251ee
commit 39716cdd44

View file

@ -1420,8 +1420,10 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
if (period_size == 0)
period_size = state->position ? state->position->clock.duration : DEFAULT_PERIOD;
/* batch devices get their hw pointers updated every period. Make
* the period smaller and add one period of headroom */
period_size /= 2;
* the period smaller and add one period of headroom. Limit the
* period size to our default so that we don't create too much
* headroom. */
period_size = SPA_MIN(period_size, DEFAULT_PERIOD) / 2;
spa_log_info(state->log, "%s: batch mode, period_size:%ld",
state->props.device, period_size);
} else {