[pulseaudio-discuss] [PATCH] alsa: Fix device reservation fails when a device string has seperator(, )
KimJeongYeon
jeongyeon.kim at samsung.com
Tue Apr 26 02:23:41 UTC 2016
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 | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index a4bb449..3221203 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -1345,22 +1345,31 @@ 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 *dev;
+ size_t l;
int i;
pa_assert(device);
if ((t = strchr(device, ':')))
- device = t+1;
+ device = t + 1;
- if ((i = snd_card_get_index(device)) < 0) {
+ l = strcspn(device, ",");
+ dev = pa_xstrndup(device, l);
+
+ if ((i = snd_card_get_index(dev)) < 0) {
int32_t k;
- if (pa_atoi(device, &k) < 0)
+ if (pa_atoi(dev, &k) < 0) {
+ pa_xfree(dev);
return NULL;
+ }
i = (int) k;
}
+ pa_xfree(dev);
+
return pa_sprintf_malloc("Audio%i", i);
}
@@ -1514,7 +1523,7 @@ static int mixer_class_compare(const snd_mixer_elem_t *c1, const snd_mixer_elem_
}
static int mixer_class_event(snd_mixer_class_t *class, unsigned int mask,
- snd_hctl_elem_t *helem, snd_mixer_elem_t *melem)
+ snd_hctl_elem_t *helem, snd_mixer_elem_t *melem)
{
int err;
const char *name = snd_hctl_elem_get_name(helem);
@@ -1531,7 +1540,7 @@ static int mixer_class_event(snd_mixer_class_t *class, unsigned int mask,
if ((err = snd_mixer_elem_attach(new_melem, helem)) < 0) {
pa_log_warn("snd_mixer_elem_attach failed: %s", pa_alsa_strerror(err));
- snd_mixer_elem_free(melem);
+ snd_mixer_elem_free(melem);
return 0;
}
--
2.7.4
More information about the pulseaudio-discuss
mailing list