[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] alsa-mixer: handle interface type (CARD, PCM) for mixer element lookups

Arun Raghavan gitlab at gitlab.freedesktop.org
Wed Dec 18 07:40:23 UTC 2019



Arun Raghavan pushed to branch master at PulseAudio / pulseaudio


Commits:
f18b0c34 by Jaroslav Kysela at 2019-12-18T07:35:40Z
alsa-mixer: handle interface type (CARD,PCM) for mixer element lookups

Signed-off-by: Jaroslav Kysela <perex at perex.cz>

- - - - -


5 changed files:

- src/modules/alsa/alsa-mixer.c
- src/modules/alsa/alsa-ucm.c
- src/modules/alsa/alsa-util.c
- src/modules/alsa/alsa-util.h
- src/modules/alsa/module-alsa-card.c


Changes:

=====================================
src/modules/alsa/alsa-mixer.c
=====================================
@@ -1907,7 +1907,7 @@ static int jack_probe(pa_alsa_jack *j, pa_alsa_mapping *mapping, snd_mixer_t *m)
         j->append_pcm_to_name = false;
     }
 
-    has_control = pa_alsa_mixer_find(m, j->alsa_name, 0) != NULL;
+    has_control = pa_alsa_mixer_find_card(m, j->alsa_name, 0) != NULL;
     pa_alsa_jack_set_has_control(j, has_control);
 
     if (j->has_control) {


=====================================
src/modules/alsa/alsa-ucm.c
=====================================
@@ -1796,7 +1796,7 @@ static void ucm_mapping_jack_probe(pa_alsa_mapping *m) {
             mdev_opened = mdev;
         }
 
-        has_control = pa_alsa_mixer_find(mixer_handle, dev->jack->alsa_name, 0) != NULL;
+        has_control = pa_alsa_mixer_find_card(mixer_handle, dev->jack->alsa_name, 0) != NULL;
         pa_alsa_jack_set_has_control(dev->jack, has_control);
         pa_log_info("UCM jack %s has_control=%d", dev->jack->name, dev->jack->has_control);
     }


=====================================
src/modules/alsa/alsa-util.c
=====================================
@@ -1610,7 +1610,11 @@ bool pa_alsa_may_tsched(bool want) {
 
 #define SND_MIXER_ELEM_PULSEAUDIO (SND_MIXER_ELEM_LAST + 10)
 
-snd_mixer_elem_t *pa_alsa_mixer_find(snd_mixer_t *mixer, const char *name, unsigned int device) {
+static snd_mixer_elem_t *pa_alsa_mixer_find(snd_mixer_t *mixer,
+                                            snd_ctl_elem_iface_t iface,
+                                            const char *name,
+                                            unsigned int index,
+                                            unsigned int device) {
     snd_mixer_elem_t *elem;
 
     for (elem = snd_mixer_first_elem(mixer); elem; elem = snd_mixer_elem_next(elem)) {
@@ -1618,8 +1622,12 @@ snd_mixer_elem_t *pa_alsa_mixer_find(snd_mixer_t *mixer, const char *name, unsig
         if (snd_mixer_elem_get_type(elem) != SND_MIXER_ELEM_PULSEAUDIO)
             continue;
         helem = snd_mixer_elem_get_private(elem);
+        if (snd_hctl_elem_get_interface(helem) != iface)
+            continue;
         if (!pa_streq(snd_hctl_elem_get_name(helem), name))
             continue;
+        if (snd_hctl_elem_get_index(helem) != index)
+            continue;
         if (snd_hctl_elem_get_device(helem) != device)
             continue;
         return elem;
@@ -1627,6 +1635,14 @@ snd_mixer_elem_t *pa_alsa_mixer_find(snd_mixer_t *mixer, const char *name, unsig
     return NULL;
 }
 
+snd_mixer_elem_t *pa_alsa_mixer_find_card(snd_mixer_t *mixer, const char *name, unsigned int device) {
+    return pa_alsa_mixer_find(mixer, SND_CTL_ELEM_IFACE_CARD, name, 0, device);
+}
+
+snd_mixer_elem_t *pa_alsa_mixer_find_pcm(snd_mixer_t *mixer, const char *name, unsigned int device) {
+    return pa_alsa_mixer_find(mixer, SND_CTL_ELEM_IFACE_PCM, name, 0, device);
+}
+
 static int mixer_class_compare(const snd_mixer_elem_t *c1, const snd_mixer_elem_t *c2)
 {
     /* Dummy compare function */


=====================================
src/modules/alsa/alsa-util.h
=====================================
@@ -141,7 +141,8 @@ const char* pa_alsa_strerror(int errnum);
 
 bool pa_alsa_may_tsched(bool want);
 
-snd_mixer_elem_t *pa_alsa_mixer_find(snd_mixer_t *mixer, const char *name, unsigned int device);
+snd_mixer_elem_t *pa_alsa_mixer_find_card(snd_mixer_t *mixer, const char *name, unsigned int device);
+snd_mixer_elem_t *pa_alsa_mixer_find_pcm(snd_mixer_t *mixer, const char *name, unsigned int device);
 
 snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device);
 


=====================================
src/modules/alsa/module-alsa-card.c
=====================================
@@ -588,7 +588,7 @@ static void init_eld_ctls(struct userdata *u) {
         if (device < 0)
             continue;
 
-        melem = pa_alsa_mixer_find(u->mixer_handle, "ELD", device);
+        melem = pa_alsa_mixer_find_pcm(u->mixer_handle, "ELD", device);
         if (melem) {
             snd_mixer_elem_set_callback(melem, hdmi_eld_changed);
             snd_mixer_elem_set_callback_private(melem, u);
@@ -635,7 +635,7 @@ static void init_jacks(struct userdata *u) {
     u->mixer_handle = pa_alsa_open_mixer(u->alsa_card_index, NULL);
     if (u->mixer_handle && pa_alsa_fdlist_set_handle(u->mixer_fdl, u->mixer_handle, NULL, u->core->mainloop) >= 0) {
         PA_HASHMAP_FOREACH(jack, u->jacks, state) {
-            jack->melem = pa_alsa_mixer_find(u->mixer_handle, jack->alsa_name, 0);
+            jack->melem = pa_alsa_mixer_find_card(u->mixer_handle, jack->alsa_name, 0);
             if (!jack->melem) {
                 pa_log_warn("Jack '%s' seems to have disappeared.", jack->alsa_name);
                 pa_alsa_jack_set_has_control(jack, false);



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/commit/f18b0c3402f5e1f7db9d0a42c6e10cfe1f212da3

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/commit/f18b0c3402f5e1f7db9d0a42c6e10cfe1f212da3
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20191218/b64218ec/attachment-0001.htm>


More information about the pulseaudio-commits mailing list