diff options
-rw-r--r-- | src/modules/alsa-util.c | 23 | ||||
-rw-r--r-- | src/modules/alsa-util.h | 2 | ||||
-rw-r--r-- | src/modules/module-alsa-sink.c | 2 | ||||
-rw-r--r-- | src/modules/module-alsa-source.c | 2 |
4 files changed, 20 insertions, 9 deletions
diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c index 22e623f6..be0fc064 100644 --- a/src/modules/alsa-util.c +++ b/src/modules/alsa-util.c @@ -337,18 +337,29 @@ int pa_alsa_prepare_mixer(snd_mixer_t *mixer, const char *dev) { return 0; } -snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name) { +snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback) { snd_mixer_elem_t *elem; - snd_mixer_selem_id_t *sid; + snd_mixer_selem_id_t *sid = NULL; snd_mixer_selem_id_alloca(&sid); - assert(mixer && name); + assert(mixer); + assert(name); snd_mixer_selem_id_set_name(sid, name); - elem = snd_mixer_find_selem(mixer, sid); - if (!elem) - pa_log_warn(__FILE__": Cannot find mixer control %s", snd_mixer_selem_id_get_name(sid)); + if (!(elem = snd_mixer_find_selem(mixer, sid))) { + pa_log_warn(__FILE__": Cannot find mixer control \"%s\".", snd_mixer_selem_id_get_name(sid)); + + if (fallback) { + snd_mixer_selem_id_set_name(sid, fallback); + + if (!(elem = snd_mixer_find_selem(mixer, sid))) + pa_log_warn(__FILE__": Cannot find fallback mixer control \"%s\".", snd_mixer_selem_id_get_name(sid)); + } + } + + if (elem) + pa_log_warn(__FILE__": Using mixer control \"%s\".", snd_mixer_selem_id_get_name(sid)); return elem; } diff --git a/src/modules/alsa-util.h b/src/modules/alsa-util.h index 4bee8625..83d1481f 100644 --- a/src/modules/alsa-util.h +++ b/src/modules/alsa-util.h @@ -40,6 +40,6 @@ int pa_alsa_fdlist_init_mixer(struct pa_alsa_fdlist *fdl, snd_mixer_t *mixer_han int pa_alsa_set_hw_params(snd_pcm_t *pcm_handle, pa_sample_spec *ss, uint32_t *periods, snd_pcm_uframes_t *period_size); int pa_alsa_prepare_mixer(snd_mixer_t *mixer, const char *dev); -snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name); +snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback); #endif diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c index a0b6dc08..620047b7 100644 --- a/src/modules/module-alsa-sink.c +++ b/src/modules/module-alsa-sink.c @@ -373,7 +373,7 @@ int pa__init(pa_core *c, pa_module*m) { } if ((pa_alsa_prepare_mixer(u->mixer_handle, dev) < 0) || - !(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "PCM"))) { + !(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "PCM", "Master"))) { snd_mixer_close(u->mixer_handle); u->mixer_handle = NULL; } diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c index 10b98f75..0999c65f 100644 --- a/src/modules/module-alsa-source.c +++ b/src/modules/module-alsa-source.c @@ -366,7 +366,7 @@ int pa__init(pa_core *c, pa_module*m) { } if ((pa_alsa_prepare_mixer(u->mixer_handle, dev) < 0) || - !(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Capture"))) { + !(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Capture", "Mic"))) { snd_mixer_close(u->mixer_handle); u->mixer_handle = NULL; } |