[pulseaudio-commits] 2 commits - src/modules

Arun Raghavan arun at kemper.freedesktop.org
Tue Dec 4 19:46:44 PST 2012


 src/modules/alsa/alsa-sink.c                    |    2 -
 src/modules/alsa/alsa-source.c                  |    2 -
 src/modules/alsa/alsa-util.c                    |   28 ++++++++++++++++--------
 src/modules/alsa/alsa-util.h                    |    2 -
 src/modules/bluetooth/module-bluetooth-device.c |    4 +--
 5 files changed, 24 insertions(+), 14 deletions(-)

New commits:
commit 2a48c2d66f0484a914d626faecc3c6aba8851f0e
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Mon Dec 3 11:27:27 2012 +0530

    alsa: Try to support non-standard rates in alsa-sink/source
    
    We inadvertantly stopped supporting non-standard rates when the
    passthrough work was done. This makes sure that if no standard rates are
    supported, we try to fallback to whatever ALSA gives us.

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index ee82ec7..ed41b22 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -2202,7 +2202,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
     if (is_iec958(u) || is_hdmi(u))
         set_formats = TRUE;
 
-    u->rates = pa_alsa_get_supported_rates(u->pcm_handle);
+    u->rates = pa_alsa_get_supported_rates(u->pcm_handle, ss.rate);
     if (!u->rates) {
         pa_log_error("Failed to find any supported sample rates.");
         goto fail;
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 802b51b..9f3170d 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1922,7 +1922,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
             pa_log_info("Disabling latency range changes on overrun");
     }
 
-    u->rates = pa_alsa_get_supported_rates(u->pcm_handle);
+    u->rates = pa_alsa_get_supported_rates(u->pcm_handle, ss.rate);
     if (!u->rates) {
         pa_log_error("Failed to find any supported sample rates.");
         goto fail;
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index 4a29a9a..114ab27 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -1326,7 +1326,7 @@ char *pa_alsa_get_reserve_name(const char *device) {
     return pa_sprintf_malloc("Audio%i", i);
 }
 
-unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm) {
+unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_rate) {
     static unsigned int all_rates[] = { 8000, 11025, 12000,
                                         16000, 22050, 24000,
                                         32000, 44100, 48000,
@@ -1352,17 +1352,27 @@ unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm) {
         }
     }
 
-    if (n == 0)
-        return NULL;
+    if (n > 0) {
+        rates = pa_xnew(unsigned int, n + 1);
 
-    rates = pa_xnew(unsigned int, n + 1);
+        for (i = 0, j = 0; i < PA_ELEMENTSOF(all_rates); i++) {
+            if (supported[i])
+                rates[j++] = all_rates[i];
+        }
 
-    for (i = 0, j = 0; i < PA_ELEMENTSOF(all_rates); i++) {
-        if (supported[i])
-            rates[j++] = all_rates[i];
-    }
+        rates[j] = 0;
+    } else {
+        rates = pa_xnew(unsigned int, 2);
 
-    rates[j] = 0;
+        rates[0] = fallback_rate;
+        if ((ret = snd_pcm_hw_params_set_rate_near(pcm, hwparams, &rates[0], NULL)) < 0) {
+            pa_log_debug("snd_pcm_hw_params_set_rate_near() failed: %s", pa_alsa_strerror(ret));
+            pa_xfree(rates);
+            return NULL;
+        }
+
+        rates[1] = 0;
+    }
 
     return rates;
 }
diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h
index 236a329..1326e64 100644
--- a/src/modules/alsa/alsa-util.h
+++ b/src/modules/alsa/alsa-util.h
@@ -133,7 +133,7 @@ char *pa_alsa_get_driver_name_by_pcm(snd_pcm_t *pcm);
 
 char *pa_alsa_get_reserve_name(const char *device);
 
-unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm);
+unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_rate);
 
 pa_bool_t pa_alsa_pcm_is_hw(snd_pcm_t *pcm);
 pa_bool_t pa_alsa_pcm_is_modem(snd_pcm_t *pcm);

commit 5a791f8a1600ae275351866a330edd60f7783ee0
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date:   Wed Nov 28 19:20:58 2012 +0100

    bluetooth: Fix unacquired transports during sink resume
    
    The sink can be resumed while the source is still in PA_SOURCE_INIT.
    This is the case if a module such as module-stream-restore routes the
    audio to the sink during pa_sink_put(), leading to an inconsistent
    state: the sink stays RUNNING but the transport is not actually
    acquired.

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 093550e..6c0c746 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -470,7 +470,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
                         break;
 
                     /* Resume the device if the source was suspended as well */
-                    if (!u->source || u->source->state == PA_SOURCE_SUSPENDED) {
+                    if (!u->source || !PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
                         if (bt_transport_acquire(u, TRUE) < 0)
                             failed = TRUE;
                     }
@@ -545,7 +545,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
                         break;
 
                     /* Resume the device if the sink was suspended as well */
-                    if (!u->sink || u->sink->thread_info.state == PA_SINK_SUSPENDED) {
+                    if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
                         if (bt_transport_acquire(u, TRUE) < 0)
                             failed = TRUE;
                     }



More information about the pulseaudio-commits mailing list