diff options
author | Jaroslav Kysela <perex@perex.cz> | 2022-06-29 11:23:20 +0200 |
---|---|---|
committer | PulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org> | 2022-07-18 13:51:33 +0000 |
commit | 81a051089f3a5890972006256737776d22de9883 (patch) | |
tree | eb468674c5c201ef0981065742265e33a22a1e1e | |
parent | d1675df0cdd5565aa6823afefe0795816228d06e (diff) | |
download | pulseaudio-81a051089f3a5890972006256737776d22de9883.tar.gz |
alsa-mixer: extend pa_alsa_mixer_find with the subdevice check
The full identifier check must be executed for the new melem
creation, otherwise the duplicate control element code check
is reached.
Example (using the snd-aloop driver):
numid=56,iface=PCM,name='PCM Notify',device=1,subdevice=1
numid=62,iface=PCM,name='PCM Notify',device=1,subdevice=2
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/730>
-rw-r--r-- | src/modules/alsa/alsa-util.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c index d33f3d1f7..9d464a8ac 100644 --- a/src/modules/alsa/alsa-util.c +++ b/src/modules/alsa/alsa-util.c @@ -1614,7 +1614,8 @@ 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) { + unsigned int device, + unsigned int subdevice) { snd_mixer_elem_t *elem; for (elem = snd_mixer_first_elem(mixer); elem; elem = snd_mixer_elem_next(elem)) { @@ -1631,17 +1632,19 @@ static snd_mixer_elem_t *pa_alsa_mixer_find(snd_mixer_t *mixer, continue; if (snd_hctl_elem_get_device(helem) != device) continue; + if (snd_hctl_elem_get_subdevice(helem) != subdevice) + continue; return elem; } return NULL; } snd_mixer_elem_t *pa_alsa_mixer_find_card(snd_mixer_t *mixer, struct pa_alsa_mixer_id *alsa_id, unsigned int device) { - return pa_alsa_mixer_find(mixer, SND_CTL_ELEM_IFACE_CARD, alsa_id->name, alsa_id->index, device); + return pa_alsa_mixer_find(mixer, SND_CTL_ELEM_IFACE_CARD, alsa_id->name, alsa_id->index, device, 0); } 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); + return pa_alsa_mixer_find(mixer, SND_CTL_ELEM_IFACE_PCM, name, 0, device, 0); } static int mixer_class_compare(const snd_mixer_elem_t *c1, const snd_mixer_elem_t *c2) @@ -1679,10 +1682,11 @@ static int mixer_class_event(snd_mixer_class_t *class, unsigned int mask, const char *name = snd_hctl_elem_get_name(helem); const int index = snd_hctl_elem_get_index(helem); const int device = snd_hctl_elem_get_device(helem); + const int subdevice = snd_hctl_elem_get_subdevice(helem); snd_mixer_elem_t *new_melem; bool found = true; - new_melem = pa_alsa_mixer_find(mixer, iface, name, index, device); + new_melem = pa_alsa_mixer_find(mixer, iface, name, index, device, subdevice); if (!new_melem) { _helem = pa_xmalloc(sizeof(snd_hctl_elem_t *)); *_helem = helem; |