summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-09-09 00:04:50 +0300
committerLennart Poettering <lennart@poettering.net>2008-09-09 00:04:50 +0300
commitf4c2f00f78208057609293b189fd40d792b8a4e3 (patch)
treeaef089c14f1de396c63270ce95bc803a827bde72 /src
parentc7a77657ffe00b6d52a0c7e3d29f4fcf8537af5f (diff)
Work around presumable ALSA bug that treats the dir argument to
snd_pcm_hw_params_set_periods_near() actually as > or < instead of >= and <=.
Diffstat (limited to 'src')
-rw-r--r--src/modules/alsa-util.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index 8fa405dd..c3eb72f5 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -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;
+ }
}
}