pcm: plugin - fix avail_min calculation on rate plugin

commit 88e4ae27, ff1f669d introduced a dynamic recalculation of the slave's
avail_min value.
The calculated avail_min setting did not take into account, that the avail_min value
depends on the used sampling rate and must be adapted accordingly
if the slave is using a different sampling rate.
That leads to too large/too small calculated avail_min settings and inaccurate
period wake-up events if a rate converter plugin is used.

This patch is adapting the avail_min calculation to consider a different
sampling rate between actual pcm and it's slave.

Fixes: https://github.com/alsa-project/alsa-lib/pull/218
Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Andreas Pape 2022-03-22 12:45:37 +01:00 committed by Jaroslav Kysela
parent ea15c83525
commit d21e0e01c6
3 changed files with 31 additions and 0 deletions

View file

@ -286,6 +286,8 @@ struct _snd_pcm {
snd1_pcm_wait_nocheck
#define snd_pcm_rate_get_default_converter \
snd1_pcm_rate_get_default_converter
#define snd_pcm_rate_slave_frames \
snd1_pcm_rate_slave_frames
#define snd_pcm_set_hw_ptr \
snd1_pcm_set_hw_ptr
#define snd_pcm_set_appl_ptr \
@ -1009,6 +1011,8 @@ int snd_pcm_wait_nocheck(snd_pcm_t *pcm, int timeout);
const snd_config_t *snd_pcm_rate_get_default_converter(snd_config_t *root);
snd_pcm_uframes_t snd_pcm_rate_slave_frames(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
#define SND_PCM_HW_PARBIT_ACCESS (1U << SND_PCM_HW_PARAM_ACCESS)
#define SND_PCM_HW_PARBIT_FORMAT (1U << SND_PCM_HW_PARAM_FORMAT)
#define SND_PCM_HW_PARBIT_SUBFORMAT (1U << SND_PCM_HW_PARAM_SUBFORMAT)