[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.16-test3-3-g39aa1cf

Lennart Poettering gitmailer-noreply at 0pointer.de
Thu Jul 30 17:21:13 PDT 2009


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  c14f6c179fb3a52219f2796d20a1c6f5648aa8a1 (commit)

- Log -----------------------------------------------------------------
39aa1cf alsa: revert to first set number of periods, then set buffer size
-----------------------------------------------------------------------

Summary of changes:
 src/modules/alsa/alsa-util.c |   55 ++++++++++++++++++++++-------------------
 1 files changed, 29 insertions(+), 26 deletions(-)

-----------------------------------------------------------------------

commit 39aa1cf94d43efaa80571b3f9d3dc56297f2f5be
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jul 31 02:07:24 2009 +0200

    alsa: revert to first set number of periods, then set buffer size
    
    Apparently some ALSA drivers aren't happy with getting the buffer size
    configured first followed the period size. So swap the order again and
    document this for future reference so that we don't turn that around
    again.

diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index 1f3e5dc..a47a895 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -233,14 +233,16 @@ int pa_alsa_set_hw_params(
         goto finish;
     }
 
-    if (_period_size && tsched_size && _periods) {
+    if (_period_size > 0 && tsched_size > 0 && _periods > 0) {
+        snd_pcm_uframes_t buffer_size;
+        unsigned int p;
 
         /* Adjust the buffer sizes, if we didn't get the rate we were asking for */
         _period_size = (snd_pcm_uframes_t) (((uint64_t) _period_size * r) / ss->rate);
         tsched_size = (snd_pcm_uframes_t) (((uint64_t) tsched_size * r) / ss->rate);
 
         if (_use_tsched) {
-            snd_pcm_uframes_t buffer_size = 0;
+            buffer_size = 0;
 
             if ((ret = snd_pcm_hw_params_get_buffer_size_max(hwparams, &buffer_size)) < 0)
                 pa_log_warn("snd_pcm_hw_params_get_buffer_size_max() failed: %s", pa_alsa_strerror(ret));
@@ -251,32 +253,33 @@ int pa_alsa_set_hw_params(
             _periods = 1;
         }
 
-        if (_period_size > 0 && _periods > 0) {
-            snd_pcm_uframes_t buffer_size;
-
-            buffer_size = _periods * _period_size;
-
-            if ((ret = snd_pcm_hw_params_set_buffer_size_near(pcm_handle, hwparams, &buffer_size)) < 0)
-                pa_log_info("snd_pcm_hw_params_set_buffer_size_near() failed: %s", pa_alsa_strerror(ret));
-        }
-
-        if (_periods > 0) {
-
-            /* First we pass 0 as direction to get exactly what we
-             * asked for. That this is necessary is presumably a bug
-             * in ALSA. All in all this is mostly a hint to ALSA, so
-             * we don't care if this fails. */
-
-            dir = 0;
-            if (snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &_periods, &dir) < 0) {
-                dir = 1;
-                if (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)
-                        pa_log_info("snd_pcm_hw_params_set_periods_near() failed: %s", pa_alsa_strerror(ret));
-                }
+        /* Some ALSA drivers really don't like if we set the buffer
+         * size first and the number of periods second. (which would
+         * make a lot more sense to me) So, follow this rule and
+         * adjust the periods first and the buffer size second */
+
+        /* First we pass 0 as direction to get exactly what we
+         * asked for. That this is necessary is presumably a bug
+         * in ALSA. All in all this is mostly a hint to ALSA, so
+         * we don't care if this fails. */
+
+        p = _periods;
+        dir = 0;
+        if (snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &p, &dir) < 0) {
+            p = _periods;
+            dir = 1;
+            if (snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &p, &dir) < 0) {
+                p = _periods;
+                dir = -1;
+                if ((ret = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &p, &dir)) < 0)
+                    pa_log_info("snd_pcm_hw_params_set_periods_near() failed: %s", pa_alsa_strerror(ret));
             }
         }
+
+        /* Now set the buffer size */
+        buffer_size = _periods * _period_size;
+        if ((ret = snd_pcm_hw_params_set_buffer_size_near(pcm_handle, hwparams, &buffer_size)) < 0)
+            pa_log_info("snd_pcm_hw_params_set_buffer_size_near() failed: %s", pa_alsa_strerror(ret));
     }
 
     if  ((ret = snd_pcm_hw_params(pcm_handle, hwparams)) < 0)

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list