pipewire/spa/plugins/v4l2
Hans de Goede c5da2e30dc spa: v4l2: Use systemd-logind to listen for access changes
There is a race between logind applying ACLs to allow the active session
of a locally present user access to devices with a udev uaccess tag
(like /dev/video# nodes) getting applied vs wireplumber/pipewire starting.

Wireplumber/pipewire are part of the (user) default.target, which gets
started as soon as a user logs in and systemd --user is started for that
user, where as logind only starts applying the ACLs after the gnome-shell
associated logind session has been created.

This race may cause pipewire to not see v4l2 video sources at login,
this can be reproduced with these steps:

1. sudo setfacl --remove-all /dev/video*
2. systemctl --user restart pipewire
3. Now wp-ctl status will not show any video devices
   (like if pipewire was started before the udev uaccess ACLs got applied)
4. Do a switch to another (test) user without logging out, e.g. in GNOME
   go to the top right system menu press the power on/off icon and select
   "Switch User..."
5. Switch back to your normal user. Run getfacl /dev/video0 this will show
   your user has access now.
6. wp-ctl status should show the camera now, but it does not.

Fix pipewire not seeing v4l2 sources in this case by making v4l2-udev
monitor systemd-logind session changes and redoing the access() checks
on /dev/video# nodes when the session changes.

Closes: #3539
Closes: #3960
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 2a6ba61264)
2024-10-12 15:19:49 +02:00
..
meson.build spa: v4l2: Use systemd-logind to listen for access changes 2024-10-12 15:19:49 +02:00
v4l2-device.c v4l2: fix printf format 2024-04-23 11:16:40 +02:00
v4l2-source.c v4l2: Improve format and control enumeration 2024-08-07 10:44:26 +02:00
v4l2-udev.c spa: v4l2: Use systemd-logind to listen for access changes 2024-10-12 15:19:49 +02:00
v4l2-utils.c v4l2: queue dropped first buffer again 2024-09-19 09:49:53 +02:00
v4l2.c v4l2: include config.h to check for udev 2024-10-12 15:19:49 +02:00
v4l2.h spa: remove unnecessary indirection for some spa_log_topics 2023-10-06 13:08:24 +00:00