mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
alsa-mixer: allow to re-attach the mixer control element
It may be possible that the ALSA control element appears again. Allow this combination by checking, if the pulseaudio mixer element already exists. Do not create the duplicate mixer element in this case. Signed-off-by: Jaroslav Kysela <perex@perex.cz> Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/729>
This commit is contained in:
parent
4bdf4c9966
commit
def8eb074e
1 changed files with 13 additions and 5 deletions
|
|
@ -1663,12 +1663,20 @@ static int mixer_class_event(snd_mixer_class_t *class, unsigned int mask,
|
|||
} else if (mask & SND_CTL_EVENT_MASK_ADD) {
|
||||
snd_ctl_elem_iface_t iface = snd_hctl_elem_get_interface(helem);
|
||||
if (iface == SND_CTL_ELEM_IFACE_CARD || iface == SND_CTL_ELEM_IFACE_PCM) {
|
||||
snd_mixer_t *mixer = snd_mixer_class_get_mixer(class);
|
||||
snd_ctl_elem_iface_t iface = snd_hctl_elem_get_interface(helem);
|
||||
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);
|
||||
snd_mixer_elem_t *new_melem;
|
||||
|
||||
/* Put the hctl pointer as our private data - it will be useful for callbacks */
|
||||
if ((err = snd_mixer_elem_new(&new_melem, SND_MIXER_ELEM_PULSEAUDIO, 0, helem, NULL)) < 0) {
|
||||
pa_log_warn("snd_mixer_elem_new failed: %s", pa_alsa_strerror(err));
|
||||
return 0;
|
||||
|
||||
new_melem = pa_alsa_mixer_find(mixer, iface, name, index, device);
|
||||
if (!new_melem) {
|
||||
/* Put the hctl pointer as our private data - it will be useful for callbacks */
|
||||
if ((err = snd_mixer_elem_new(&new_melem, SND_MIXER_ELEM_PULSEAUDIO, 0, helem, NULL)) < 0) {
|
||||
pa_log_warn("snd_mixer_elem_new failed: %s", pa_alsa_strerror(err));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((err = snd_mixer_elem_attach(new_melem, helem)) < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue