+static char *alsa_get_name (struct udev_device *dev)
+{
+ char *name = NULL;
+ unsigned card, device;
+
+ if (alsa_get_device (dev, &card, &device))
+ return NULL;
+
+ char card_name[4 + 3 * sizeof (int)];
+ snprintf (card_name, sizeof (card_name), "hw:%u", card);
+
+ snd_ctl_t *ctl;
+ if (snd_ctl_open (&ctl, card_name, 0))
+ return NULL;
+
+ snd_pcm_info_t *pcm_info;
+ snd_pcm_info_alloca (&pcm_info);
+ snd_pcm_info_set_device (pcm_info, device);
+ snd_pcm_info_set_subdevice (pcm_info, 0);
+ snd_pcm_info_set_stream (pcm_info, SND_PCM_STREAM_CAPTURE);
+ if (snd_ctl_pcm_info (ctl, pcm_info))
+ goto out;
+
+ name = strdup (snd_pcm_info_get_name (pcm_info));
+out:
+ snd_ctl_close (ctl);
+ return name;
+}
+
+static char *alsa_get_cat (struct udev_device *dev)
+{
+ const char *vnd;
+
+ dev = udev_device_get_parent (dev);
+ if (dev == NULL)
+ return NULL;
+
+ vnd = udev_device_get_property_value (dev, "ID_VENDOR_FROM_DATABASE");
+ if (vnd == NULL)
+ /* FIXME: USB may take time to settle... the parent device */
+ vnd = udev_device_get_property_value (dev, "ID_BUS");
+ return vnd ? strdup (vnd) : NULL;
+}
+
+int OpenALSA (vlc_object_t *obj)
+{
+ static const struct subsys subsys = {
+ "sound", alsa_get_mrl, alsa_get_name, alsa_get_cat, ITEM_TYPE_CARD,
+ };
+
+ return Open (obj, &subsys);
+}
+#endif /* HAVE_ALSA */
+
+
+/*** Discs support ***/
+static char *disc_get_mrl (struct udev_device *dev)
+{
+ const char *val;
+
+ val = udev_device_get_property_value (dev, "ID_CDROM");
+ if (val == NULL)
+ return NULL; /* Ignore non-optical block devices */
+
+ val = udev_device_get_property_value (dev, "ID_CDROM_MEDIA_STATE");
+ if (val && !strcmp (val, "blank"))
+ return NULL; /* ignore empty drives and virgin recordable discs */
+
+ 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 = "dvd";
+
+ val = udev_device_get_property_value (dev, "ID_CDROM_MEDIA_BD");
+ if (val && atoi (val))
+ scheme = "bd";
+#ifdef LOL
+ val = udev_device_get_property_value (dev, "ID_CDROM_MEDIA_HDDVD");
+ if (val && atoi (val))
+ scheme = "hddvd";
+#endif
+
+ /* We didn't get any property that could tell we have optical disc
+ that we can play */
+ if (scheme == NULL)
+ return NULL;
+
+ val = udev_device_get_devnode (dev);
+ return make_URI (val, scheme);
+}
+
+static char *disc_get_name (struct udev_device *dev)
+{
+ return decode_property (dev, "ID_FS_LABEL_ENC");
+}
+
+static char *disc_get_cat (struct udev_device *dev)
+{
+ struct udev_list_entry *list, *entry;
+
+ list = udev_device_get_properties_list_entry (dev);
+ if (unlikely(list == NULL))
+ return NULL;
+
+ const char *cat = NULL;
+ udev_list_entry_foreach (entry, list)