[PATCH] alsa: Fix device reservation fails when a device string has seperator(, )

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For example, the device parameter of pa_alsa_get_reserve_name() is "hw:USB,0",
snd_card_get_index() always fails. Because seperator(,) wasn't regarded.
Therefore, JACK couldn't obtain audio device from Pulseaudio.

Signed-off-by: KimJeongYeon <jeongyeon.kim at samsung.com>
---
 src/modules/alsa/alsa-util.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index a4bb449..73e0365 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -1344,23 +1344,36 @@ char *pa_alsa_get_driver_name_by_pcm(snd_pcm_t *pcm) {
 }
 
 char *pa_alsa_get_reserve_name(const char *device) {
-    const char *t;
+    char *card_name, *start, *end;
     int i;
 
     pa_assert(device);
 
-    if ((t = strchr(device, ':')))
-        device = t+1;
+    card_name = pa_xstrdup(device);
+
+    if ((start = strchr(card_name, ':'))) {
+        start++;
+
+        if ((end = strchr(start, ','))) {
+            *end = '\0';
+        }
+
+        strcpy(card_name, start);
+    }
 
-    if ((i = snd_card_get_index(device)) < 0) {
+    if ((i = snd_card_get_index(card_name)) < 0) {
         int32_t k;
 
-        if (pa_atoi(device, &k) < 0)
+        if (pa_atoi(device, &k) < 0) {
+            pa_xfree(card_name);
             return NULL;
+        }
 
         i = (int) k;
     }
 
+    pa_xfree(card_name);
+
     return pa_sprintf_malloc("Audio%i", i);
 }
 
-- 
2.7.4



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux