From b91ec5f14e12669fbbf0f4cb475647796b20f810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net> Date: Sun, 5 May 2013 08:49:21 +0300 Subject: [PATCH] udev: probe all optical drives without state at start-up Unfortunately, this works only when starting up the SD, not when inserting a disc afterwards. --- modules/services_discovery/udev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/services_discovery/udev.c b/modules/services_discovery/udev.c index 1149217e0ae4..736bdb6905e1 100644 --- a/modules/services_discovery/udev.c +++ b/modules/services_discovery/udev.c @@ -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) -- GitLab