]> git.sesse.net Git - vlc/blobdiff - modules/services_discovery/udev.c
Contribs: add live for Android
[vlc] / modules / services_discovery / udev.c
index e39f43a7c5ba749f6bf441a8fdc7692eb7bd97e4..2b513c81e37b11ef92be4597d1af216c27567e6d 100644 (file)
 #include <vlc_common.h>
 #include <vlc_services_discovery.h>
 #include <vlc_plugin.h>
-#include <search.h>
+#include <vlc_url.h>
+#ifdef HAVE_SEARCH_H
+# include <search.h>
+#endif
 #include <poll.h>
 #include <errno.h>
 
 static int OpenV4L (vlc_object_t *);
+#ifdef HAVE_ALSA
 static int OpenALSA (vlc_object_t *);
+#endif
 static int OpenDisc (vlc_object_t *);
 static void Close (vlc_object_t *);
 static int vlc_sd_probe_Open (vlc_object_t *);
@@ -49,7 +54,7 @@ vlc_module_begin ()
     set_capability ("services_discovery", 0)
     set_callbacks (OpenV4L, Close)
     add_shortcut ("v4l")
-
+#ifdef HAVE_ALSA
     add_submodule ()
     set_shortname (N_("Audio capture"))
     set_description (N_("Audio capture (ALSA)"))
@@ -58,7 +63,7 @@ vlc_module_begin ()
     set_capability ("services_discovery", 0)
     set_callbacks (OpenALSA, Close)
     add_shortcut ("alsa")
-
+#endif
     add_submodule ()
     set_shortname (N_("Discs"))
     set_description (N_("Discs"))
@@ -85,8 +90,10 @@ static int vlc_sd_probe_Open (vlc_object_t *obj)
     {
         vlc_sd_probe_Add (probe, "v4l{longname=\"Video capture\"}",
                           N_("Video capture"), SD_CAT_DEVICES);
+#ifdef HAVE_ALSA
         vlc_sd_probe_Add (probe, "alsa{longname=\"Audio capture\"}",
                           N_("Audio capture"), SD_CAT_DEVICES);
+#endif
         vlc_sd_probe_Add (probe, "disc{longname=\"Discs\"}", N_("Discs"),
                           SD_CAT_DEVICES);
         udev_monitor_unref (mon);
@@ -538,14 +545,14 @@ static char *disc_get_mrl (struct udev_device *dev)
     if (val && !strcmp (val, "blank"))
         return NULL; /* ignore empty drives and virgin recordable discs */
 
-    const char *scheme = "invalid";
+    const char *scheme = NULL;
     val = udev_device_get_property_value (dev,
                                           "ID_CDROM_MEDIA_TRACK_COUNT_AUDIO");
     if (val && atoi (val))
         scheme = "cdda"; /* Audio CD rather than file system */
     val = udev_device_get_property_value (dev, "ID_CDROM_MEDIA_DVD");
     if (val && atoi (val))
-        scheme = "file";
+        scheme = "dvd";
 
     val = udev_device_get_property_value (dev, "ID_CDROM_MEDIA_BD");
     if (val && atoi (val))
@@ -558,15 +565,11 @@ static char *disc_get_mrl (struct udev_device *dev)
 
     /* We didn't get any property that could tell we have optical disc
        that we can play */
-    if( !strcmp( scheme, "invalid" ) )
+    if (scheme == NULL)
         return NULL;
 
     val = udev_device_get_devnode (dev);
-    char *mrl;
-
-    if (asprintf (&mrl, "%s://%s", scheme, val) == -1)
-        mrl = NULL;
-    return mrl;
+    return make_URI (val, scheme);
 }
 
 static char *disc_get_name (struct udev_device *dev)