]> git.sesse.net Git - vlc/commitdiff
ALSA: list default and configured device in choice list (fix #4995)
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 5 Oct 2011 17:28:18 +0000 (20:28 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 5 Oct 2011 20:50:44 +0000 (23:50 +0300)
modules/audio_output/alsa.c

index f2df6ccb10e5a904bbee4c6b2a89279eef027954..6619864443ac18cb94efc1b9433e62082783967e 100644 (file)
@@ -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);
+    }
 }