]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ioplug - Fix the refinement of period_* after periods
authorTakashi Iwai <tiwai@suse.de>
Mon, 5 Nov 2007 11:46:46 +0000 (12:46 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 5 Nov 2007 11:46:46 +0000 (12:46 +0100)
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

index b3a3f1ffd27a4c648f9af1543c3a92ca96b5d87a..435572eadb1a2f8d9f0bb5fc5f69fe9f62fd51fc 100644 (file)
@@ -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) {