From 204a75628331e31bca364ad0453c396fe66befd1 Mon Sep 17 00:00:00 2001 From: Peter Date: Sun, 24 Oct 2010 18:53:58 +0200 Subject: [PATCH] Fallback to the Master mixer element if PCM is not available When using PulseAudio through ALSA, the mixer doesn't have a PCM element; fallback to Master in this case. --- src/laudio_alsa.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/laudio_alsa.c b/src/laudio_alsa.c index cf88bd4c..a92c3c90 100644 --- a/src/laudio_alsa.c +++ b/src/laudio_alsa.c @@ -410,6 +410,8 @@ static int mixer_open(void) { snd_mixer_elem_t *elem; + snd_mixer_elem_t *master; + snd_mixer_elem_t *pcm; snd_mixer_selem_id_t *sid; int ret; @@ -449,17 +451,25 @@ mixer_open(void) /* Grab interesting elements */ snd_mixer_selem_id_alloca(&sid); + pcm = NULL; + master = NULL; for (elem = snd_mixer_first_elem(mixer_hdl); elem; elem = snd_mixer_elem_next(elem)) { snd_mixer_selem_get_id(elem, sid); if (strcmp(snd_mixer_selem_id_get_name(sid), "PCM") == 0) - vol_elem = elem; + pcm = elem; + else if (strcmp(snd_mixer_selem_id_get_name(sid), "Master") == 0) + master = elem; } - if (!vol_elem) + if (pcm) + vol_elem = pcm; + else if (master) + vol_elem = master; + else { - DPRINTF(E_LOG, L_LAUDIO, "Failed to open PCM mixer element\n"); + DPRINTF(E_LOG, L_LAUDIO, "Failed to open PCM or Master mixer element\n"); goto out_detach; }