]> git.sesse.net Git - vlc/blobdiff - modules/services_discovery/udev.c
smf: reorder code, no functional changes
[vlc] / modules / services_discovery / udev.c
index 7dd910fb52d05fd666879e4b51b423ef3727570f..e70f5c6d0700302879520d8500bc6efff66f76fd 100644 (file)
 # include <config.h>
 #endif
 
+#include <errno.h>
+#include <search.h>
+#include <poll.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
 #include <libudev.h>
+
 #include <vlc_common.h>
 #include <vlc_services_discovery.h>
 #include <vlc_plugin.h>
-#include <vlc_url.h>
-#ifdef HAVE_SEARCH_H
-# include <search.h>
+#ifdef HAVE_ALSA
+# include <vlc_modules.h>
 #endif
-#include <poll.h>
-#include <errno.h>
+#include <vlc_url.h>
 
 static int OpenV4L (vlc_object_t *);
 #ifdef HAVE_ALSA
@@ -91,8 +96,9 @@ 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);
+        if (!module_exists ("pulselist"))
+            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);
@@ -134,7 +140,7 @@ static int cmpdev (const void *a, const void *b)
     dev_t delta = *da - *db;
 
     if (sizeof (delta) > sizeof (int))
-        return delta ? ((delta > 0) ? 1 : -1) : 0;
+        return delta ? (((signed)delta > 0) ? 1 : -1) : 0;
     return (signed)delta;
 }
 
@@ -519,6 +525,7 @@ int OpenALSA (vlc_object_t *obj)
 /*** Discs support ***/
 static char *disc_get_mrl (struct udev_device *dev)
 {
+    const char *node = udev_device_get_devnode (dev);
     const char *val;
 
     val = udev_device_get_property_value (dev, "ID_CDROM");
@@ -526,7 +533,14 @@ static char *disc_get_mrl (struct udev_device *dev)
         return NULL; /* Ignore non-optical block devices */
 
     val = udev_device_get_property_value (dev, "ID_CDROM_MEDIA_STATE");
-    if (val && !strcmp (val, "blank"))
+    if (val == NULL)
+    {   /* Force probing of the disc in the drive if any. */
+        int fd = open (node, O_RDONLY|O_CLOEXEC);
+        if (fd != -1)
+            close (fd);
+        return NULL;
+    }
+    if (!strcmp (val, "blank"))
         return NULL; /* ignore empty drives and virgin recordable discs */
 
     const char *scheme = NULL;
@@ -552,8 +566,7 @@ static char *disc_get_mrl (struct udev_device *dev)
     if (scheme == NULL)
         return NULL;
 
-    val = udev_device_get_devnode (dev);
-    return make_URI (val, scheme);
+    return vlc_path2uri (node, scheme);
 }
 
 static char *disc_get_name (struct udev_device *dev)
@@ -581,7 +594,7 @@ static char *disc_get_name (struct udev_device *dev)
         else if (!strncmp (name, "DVD", 3))
             cat = N_("DVD");
         else if (!strncmp (name, "BD", 2))
-            cat = N_("Blu-Ray");
+            cat = N_("Blu-ray");
         else if (!strncmp (name, "HDDVD", 5))
             cat = N_("HD DVD");