[polypaudio-commits] r993 - in /trunk/src/modules: alsa-util.c alsa-util.h module-alsa-sink.c module-alsa-source.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Tue May 30 15:48:20 PDT 2006


Author: lennart
Date: Wed May 31 00:48:17 2006
New Revision: 993

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=993&root=polypaudio&view=rev
Log:
* alsa-sink: if "PCM" is not found as mixer track name, fallback to "Master"
* alsa-source: if "Capture" is not found as mixer track name, fallback to "Mic"

Modified:
    trunk/src/modules/alsa-util.c
    trunk/src/modules/alsa-util.h
    trunk/src/modules/module-alsa-sink.c
    trunk/src/modules/module-alsa-source.c

Modified: trunk/src/modules/alsa-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/alsa-util.c?rev=993&root=polypaudio&r1=992&r2=993&view=diff
==============================================================================
--- trunk/src/modules/alsa-util.c (original)
+++ trunk/src/modules/alsa-util.c Wed May 31 00:48:17 2006
@@ -337,18 +337,29 @@
     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;
 }

Modified: trunk/src/modules/alsa-util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/alsa-util.h?rev=993&root=polypaudio&r1=992&r2=993&view=diff
==============================================================================
--- trunk/src/modules/alsa-util.h (original)
+++ trunk/src/modules/alsa-util.h Wed May 31 00:48:17 2006
@@ -40,6 +40,6 @@
 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

Modified: trunk/src/modules/module-alsa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-sink.c?rev=993&root=polypaudio&r1=992&r2=993&view=diff
==============================================================================
--- trunk/src/modules/module-alsa-sink.c (original)
+++ trunk/src/modules/module-alsa-sink.c Wed May 31 00:48:17 2006
@@ -373,7 +373,7 @@
     }
 
     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;
     }

Modified: trunk/src/modules/module-alsa-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-source.c?rev=993&root=polypaudio&r1=992&r2=993&view=diff
==============================================================================
--- trunk/src/modules/module-alsa-source.c (original)
+++ trunk/src/modules/module-alsa-source.c Wed May 31 00:48:17 2006
@@ -366,7 +366,7 @@
     }
 
     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;
     }




More information about the pulseaudio-commits mailing list