Commit 49661f4c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

udev: remove remaining items at exit

parent 0132bb5d
...@@ -63,6 +63,7 @@ struct device ...@@ -63,6 +63,7 @@ struct device
{ {
dev_t devnum; /* must be first */ dev_t devnum; /* must be first */
input_item_t *item; input_item_t *item;
services_discovery_t *sd;
}; };
struct subsys struct subsys
...@@ -99,6 +100,8 @@ static void DestroyDevice (void *data) ...@@ -99,6 +100,8 @@ static void DestroyDevice (void *data)
{ {
struct device *d = data; struct device *d = data;
if (d->sd)
services_discovery_RemoveItem (d->sd, d->item);
vlc_gc_decref (d->item); vlc_gc_decref (d->item);
free (d); free (d);
} }
...@@ -132,8 +135,9 @@ static int AddDevice (services_discovery_t *sd, struct udev_device *dev) ...@@ -132,8 +135,9 @@ static int AddDevice (services_discovery_t *sd, struct udev_device *dev)
vlc_gc_decref (item); vlc_gc_decref (item);
return -1; return -1;
} }
d->item = item;
d->devnum = udev_device_get_devnum (dev); d->devnum = udev_device_get_devnum (dev);
d->item = item;
d->sd = NULL;
struct device **dp = tsearch (d, &p_sys->root, cmpdev); struct device **dp = tsearch (d, &p_sys->root, cmpdev);
if (dp == NULL) /* Out-of-memory */ if (dp == NULL) /* Out-of-memory */
...@@ -143,13 +147,13 @@ static int AddDevice (services_discovery_t *sd, struct udev_device *dev) ...@@ -143,13 +147,13 @@ static int AddDevice (services_discovery_t *sd, struct udev_device *dev)
} }
if (*dp != d) /* Overwrite existing device */ if (*dp != d) /* Overwrite existing device */
{ {
services_discovery_RemoveItem (sd, (*dp)->item);
DestroyDevice (*dp); DestroyDevice (*dp);
*dp = d; *dp = d;
} }
name = p_sys->subsys->get_cat (dev); name = p_sys->subsys->get_cat (dev);
services_discovery_AddItem (sd, item, name ? name : "Generic"); services_discovery_AddItem (sd, item, name ? name : "Generic");
d->sd = sd;
free (name); free (name);
return 0; return 0;
} }
...@@ -167,7 +171,6 @@ static void RemoveDevice (services_discovery_t *sd, struct udev_device *dev) ...@@ -167,7 +171,6 @@ static void RemoveDevice (services_discovery_t *sd, struct udev_device *dev)
return; return;
struct device *d = *dp; struct device *d = *dp;
services_discovery_RemoveItem (sd, d->item);
tdelete (d, &p_sys->root, cmpdev); tdelete (d, &p_sys->root, cmpdev);
DestroyDevice (d); DestroyDevice (d);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment