alsa: add api.alsa.headroom setting

Can be used to tweak the extra distance kept between the hardware
and software pointers when reading and writing.

See #289
This commit is contained in:
Wim Taymans 2021-01-14 17:10:05 +01:00
parent abe73c9146
commit 7347b5ef05
5 changed files with 13 additions and 1 deletions

View file

@ -605,8 +605,12 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
CHECK(snd_pcm_hw_params_get_buffer_size_max(params, &state->buffer_frames), "get_buffer_size_max");
CHECK(snd_pcm_hw_params_set_buffer_size_near(hndl, params, &state->buffer_frames), "set_buffer_size_near");
if (state->default_headroom == 0)
state->headroom = is_batch ? period_size : 0;
else
state->headroom = state->default_headroom;
state->period_frames = period_size;
state->headroom = is_batch ? period_size : 0;
periods = state->buffer_frames / state->period_frames;
spa_log_info(state->log, NAME" %s (%s): format:%s access:%s-%s rate:%d channels:%d "