mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-07-21 10:16:14 +00:00
v4l2: handle inotify errors
Handle inotify errors and remove the source. See #3439
This commit is contained in:
parent
3c47fa894b
commit
07b8954dc8
|
@ -393,6 +393,19 @@ static void process_device(struct impl *impl, uint32_t action, struct udev_devic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int stop_inotify(struct device *dev)
|
||||||
|
{
|
||||||
|
struct impl *impl = dev->impl;
|
||||||
|
if (dev->notify.fd == -1)
|
||||||
|
return 0;
|
||||||
|
spa_log_info(impl->log, "stop inotify for /dev/video%u", dev->id);
|
||||||
|
spa_loop_remove_source(impl->main_loop, &dev->notify);
|
||||||
|
close(dev->notify.fd);
|
||||||
|
dev->notify.fd = -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void impl_on_notify_events(struct spa_source *source)
|
static void impl_on_notify_events(struct spa_source *source)
|
||||||
{
|
{
|
||||||
struct device *dev = source->data;
|
struct device *dev = source->data;
|
||||||
|
@ -402,7 +415,12 @@ static void impl_on_notify_events(struct spa_source *source)
|
||||||
struct inotify_event e; /* for appropriate alignment */
|
struct inotify_event e; /* for appropriate alignment */
|
||||||
} buf;
|
} buf;
|
||||||
|
|
||||||
while (true) {
|
if (source->rmask & (SPA_IO_ERR | SPA_IO_HUP)) {
|
||||||
|
spa_log_warn(impl->log, "notify error on /dev/video%u", dev->id);
|
||||||
|
stop_inotify(dev);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (source->rmask & SPA_IO_IN) {
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
const struct inotify_event *event;
|
const struct inotify_event *event;
|
||||||
void *p, *e;
|
void *p, *e;
|
||||||
|
@ -469,18 +487,6 @@ static int start_inotify(struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stop_inotify(struct device *dev)
|
|
||||||
{
|
|
||||||
struct impl *impl = dev->impl;
|
|
||||||
if (dev->notify.fd == -1)
|
|
||||||
return 0;
|
|
||||||
spa_log_info(impl->log, "stop inotify for /dev/video%u", dev->id);
|
|
||||||
spa_loop_remove_source(impl->main_loop, &dev->notify);
|
|
||||||
close(dev->notify.fd);
|
|
||||||
dev->notify.fd = -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void impl_on_fd_events(struct spa_source *source)
|
static void impl_on_fd_events(struct spa_source *source)
|
||||||
{
|
{
|
||||||
struct impl *impl = source->data;
|
struct impl *impl = source->data;
|
||||||
|
|
Loading…
Reference in a new issue