From 07137c0267999948a5625cc318cac2effa17cf79 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Nov 2007 12:46:46 +0100 Subject: [PATCH] ioplug - Fix the refinement of period_* after periods When changing only PERIODS after BUFFER_*, ioplug doesn't update the corresponding PERIOD_* parameters properly. This should fix ALSA bug#2601. --- src/pcm/pcm_ioplug.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c index b3a3f1ff..435572ea 100644 --- a/src/pcm/pcm_ioplug.c +++ b/src/pcm/pcm_ioplug.c @@ -313,7 +313,7 @@ static int snd_pcm_ioplug_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) if (err < 0) return err; change2 |= err; - /* periods = buffer_bytes / periods */ + /* periods = buffer_bytes / period_bytes */ err = rule_div(params, SND_PCM_HW_PARAM_PERIODS, SND_PCM_HW_PARAM_BUFFER_BYTES, SND_PCM_HW_PARAM_PERIOD_BYTES); @@ -344,6 +344,26 @@ static int snd_pcm_ioplug_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) return err; } + /* period_bytes = buffer_bytes / periods */ + err = rule_div(params, SND_PCM_HW_PARAM_PERIOD_BYTES, + SND_PCM_HW_PARAM_BUFFER_BYTES, + SND_PCM_HW_PARAM_PERIODS); + if (err < 0) + return err; + if (err) { + /* update period_size and period_time */ + change |= err; + err = snd_ext_parm_interval_refine(hw_param_interval(params, SND_PCM_HW_PARAM_PERIOD_BYTES), + io->params, SND_PCM_IOPLUG_HW_PERIOD_BYTES); + if (err < 0) + return err; + err = refine_back_time_and_size(params, SND_PCM_HW_PARAM_PERIOD_TIME, + SND_PCM_HW_PARAM_PERIOD_SIZE, + SND_PCM_HW_PARAM_PERIOD_BYTES); + if (err < 0) + return err; + } + params->info = SND_PCM_INFO_BLOCK_TRANSFER; p = &io->params[SND_PCM_IOPLUG_HW_ACCESS]; if (p->active) { -- 2.47.1