]> code.delx.au - pulseaudio/commitdiff
Work around presumable ALSA bug that treats the dir argument to
authorLennart Poettering <lennart@poettering.net>
Mon, 8 Sep 2008 21:04:50 +0000 (00:04 +0300)
committerLennart Poettering <lennart@poettering.net>
Mon, 8 Sep 2008 21:04:50 +0000 (00:04 +0300)
snd_pcm_hw_params_set_periods_near() actually as > or < instead of >= and <=.

src/modules/alsa-util.c

index 8fa405ddfddc300ad58ac077fb690474261e0235..c3eb72f5765d14121e048bb2293ec5c3cbea21ba 100644 (file)
@@ -370,11 +370,18 @@ int pa_alsa_set_hw_params(
         goto finish;
 
     if (_periods > 0) {
-        dir = 1;
+
+        /* First we pass 0 as direction to get exactly what we asked
+         * for. That this is necessary is presumably a bug in ALSA */
+
+        dir = 0;
         if ((ret = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &_periods, &dir)) < 0) {
-            dir = -1;
-            if ((ret = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &_periods, &dir)) < 0)
-                goto finish;
+            dir = 1;
+            if ((ret = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &_periods, &dir)) < 0) {
+                dir = -1;
+                if ((ret = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &_periods, &dir)) < 0)
+                    goto finish;
+            }
         }
     }