[vlc-commits] alsa: insert default choice if not in ALSA device hints

Rémi Denis-Courmont git at videolan.org
Wed Oct 21 19:43:30 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Oct 21 20:30:49 2015 +0300| [1d92fdf3e259b0f8d482b4a5534022cdc71fea16] | committer: Rémi Denis-Courmont

alsa: insert default choice if not in ALSA device hints

This ensures that the default value ("default") for alsa-audio-device
is listed as a possible choice.

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

 modules/audio_output/alsa.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 7e71d3e..42c1d75 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -709,6 +709,7 @@ static int EnumDevices(vlc_object_t *obj, char const *varname,
 
     char **ids = NULL, **names = NULL;
     unsigned n = 0;
+    bool hinted_default = false;
 
     for (size_t i = 0; hints[i] != NULL; i++)
     {
@@ -729,9 +730,22 @@ static int EnumDevices(vlc_object_t *obj, char const *varname,
         ids[n] = name;
         names[n] = desc;
         n++;
+
+        if (!strcmp(name, "default"))
+            hinted_default = true;
     }
 
     snd_device_name_free_hint(hints);
+
+    if (!hinted_default)
+    {
+        ids = xrealloc (ids, (n + 1) * sizeof (*ids));
+        names = xrealloc (names, (n + 1) * sizeof (*names));
+        ids[n] = xstrdup ("default");
+        names[n] = _("Default");
+        n++;
+    }
+
     *idp = ids;
     *namep = names;
     (void) varname;



More information about the vlc-commits mailing list