mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
udev: don't loop forever on errors
When we can't find the v4l2 device id, unref the device and continue instead of looping forever and consuming all memory. Fixes #219
This commit is contained in:
parent
f22b7b22a8
commit
a1846c9780
2 changed files with 8 additions and 14 deletions
|
|
@ -460,18 +460,17 @@ static int enum_devices(struct impl *this)
|
|||
udev_enumerate_add_match_subsystem(enumerate, "sound");
|
||||
udev_enumerate_scan_devices(enumerate);
|
||||
|
||||
devices = udev_enumerate_get_list_entry(enumerate);
|
||||
|
||||
while (devices) {
|
||||
for (devices = udev_enumerate_get_list_entry(enumerate); devices;
|
||||
devices = udev_list_entry_get_next(devices)) {
|
||||
struct udev_device *dev;
|
||||
|
||||
dev = udev_device_new_from_syspath(this->udev, udev_list_entry_get_name(devices));
|
||||
if (dev == NULL)
|
||||
continue;
|
||||
|
||||
emit_device(this, ACTION_ADD, true, dev);
|
||||
|
||||
udev_device_unref(dev);
|
||||
|
||||
devices = udev_list_entry_get_next(devices);
|
||||
}
|
||||
udev_enumerate_unref(enumerate);
|
||||
|
||||
|
|
|
|||
|
|
@ -338,9 +338,8 @@ static int enum_devices(struct impl *this)
|
|||
udev_enumerate_add_match_subsystem(enumerate, "video4linux");
|
||||
udev_enumerate_scan_devices(enumerate);
|
||||
|
||||
devices = udev_enumerate_get_list_entry(enumerate);
|
||||
|
||||
while (devices) {
|
||||
for (devices = udev_enumerate_get_list_entry(enumerate); devices;
|
||||
devices = udev_list_entry_get_next(devices)) {
|
||||
struct udev_device *dev;
|
||||
uint32_t id;
|
||||
|
||||
|
|
@ -348,14 +347,10 @@ static int enum_devices(struct impl *this)
|
|||
if (dev == NULL)
|
||||
continue;
|
||||
|
||||
if ((id = get_device_id(this, dev)) == SPA_ID_INVALID)
|
||||
continue;
|
||||
|
||||
emit_object_info(this, id, dev);
|
||||
if ((id = get_device_id(this, dev)) != SPA_ID_INVALID)
|
||||
emit_object_info(this, id, dev);
|
||||
|
||||
udev_device_unref(dev);
|
||||
|
||||
devices = udev_list_entry_get_next(devices);
|
||||
}
|
||||
udev_enumerate_unref(enumerate);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue