]> git.sesse.net Git - vlc/commitdiff
udev: probe all optical drives without state at start-up
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 5 May 2013 05:49:21 +0000 (08:49 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 5 May 2013 05:49:21 +0000 (08:49 +0300)
Unfortunately, this works only when starting up the SD, not when
inserting a disc afterwards.

modules/services_discovery/udev.c

index 1149217e0ae4a97b5b3024a4d203452b678333fe..736bdb6905e189c13f83fd4d946a08a4dd2f37a2 100644 (file)
@@ -523,6 +523,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");
@@ -530,7 +531,13 @@ 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);
+        close (fd);
+        return NULL;
+    }
+    if (!strcmp (val, "blank"))
         return NULL; /* ignore empty drives and virgin recordable discs */
 
     const char *scheme = NULL;
@@ -556,8 +563,7 @@ static char *disc_get_mrl (struct udev_device *dev)
     if (scheme == NULL)
         return NULL;
 
-    val = udev_device_get_devnode (dev);
-    return vlc_path2uri (val, scheme);
+    return vlc_path2uri (node, scheme);
 }
 
 static char *disc_get_name (struct udev_device *dev)