[vlc-commits] ALSA: list default and configured device in choice list (fix #4995)

Rémi Denis-Courmont git at videolan.org
Wed Oct 5 22:50:54 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Oct  5 20:28:18 2011 +0300| [f094d815a50241ea2d00cb493ff9ab33950d21a7] | committer: Rémi Denis-Courmont

ALSA: list default and configured device in choice list (fix #4995)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f094d815a50241ea2d00cb493ff9ab33950d21a7
---

 modules/audio_output/alsa.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index f2df6cc..6619864 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -745,6 +745,7 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
 static void GetDevices (vlc_object_t *obj, module_config_t *item)
 {
     void **hints;
+    bool hinted_default = false;
 
     msg_Dbg(obj, "Available ALSA PCM devices:");
 
@@ -771,6 +772,9 @@ static void GetDevices (vlc_object_t *obj, module_config_t *item)
                  *lf = ' ';
         msg_Dbg(obj, "%s (%s)", (desc != NULL) ? desc : name, name);
 
+        if (!strcmp (name, "default"))
+            hinted_default = true;
+
         if (item != NULL)
         {
             item->ppsz_list = xrealloc(item->ppsz_list,
@@ -803,4 +807,25 @@ static void GetDevices (vlc_object_t *obj, module_config_t *item)
         item->ppsz_list[item->i_list] = NULL;
         item->ppsz_list_text[item->i_list] = NULL;
     }
+    else
+    {
+        vlc_value_t val, text;
+
+        if (!hinted_default)
+        {
+            val.psz_string = (char *)"default";
+            text.psz_string = (char *)N_("Default");
+            var_Change(obj, "audio-device", VLC_VAR_ADDCHOICE, &val, &text);
+        }
+
+        val.psz_string = var_InheritString (obj, "alsa-audio-device");
+        if (likely(val.psz_string != NULL)
+         && strcmp (val.psz_string, "default"))
+        {
+            text.psz_string = (char *)N_("VLC preferences");
+            var_Change(obj, "audio-device", VLC_VAR_ADDCHOICE, &val, &text);
+        }
+        var_Change(obj, "audio-device", VLC_VAR_SETVALUE, &val, NULL);
+        free (val.psz_string);
+    }
 }



More information about the vlc-commits mailing list