spa: use a separate logind dependency separate from systemd

non-systemd systems also have logind, in the form of elogind, which works to
resolve the v4l2 video source race just as well. permit finding elogind, by
using a separate dep object.
This commit is contained in:
psykose 2024-09-20 03:12:04 +02:00 committed by Wim Taymans
parent bdd4d3a8fc
commit 2d071d658f
4 changed files with 20 additions and 7 deletions

View file

@ -273,6 +273,10 @@ summary({'systemd conf data': systemd.found()}, bool_yn: true)
summary({'libsystemd': systemd_dep.found()}, bool_yn: true)
cdata.set('HAVE_SYSTEMD', systemd.found() and systemd_dep.found())
logind_dep = dependency(get_option('logind-provider'), required: get_option('logind'))
summary({'logind': logind_dep.found()}, bool_yn: true)
cdata.set('HAVE_LOGIND', logind_dep.found())
selinux_dep = dependency('libselinux', required: get_option('selinux'))
summary({'libselinux': selinux_dep.found()}, bool_yn: true)
cdata.set('HAVE_SELINUX', selinux_dep.found())

View file

@ -34,6 +34,15 @@ option('systemd',
description: 'Enable systemd integration',
type: 'feature',
value: 'auto')
option('logind',
description: 'Enable logind integration',
type: 'feature',
value: 'auto')
option('logind-provider',
description: 'Provider for logind integration',
type: 'combo',
choices: ['libelogind', 'libsystemd'],
value: 'libsystemd')
option('systemd-system-service',
description: 'Install systemd system service file',
type: 'feature',

View file

@ -6,8 +6,8 @@ v4l2_dependencies = [ spa_dep, libinotify_dep ]
if libudev_dep.found()
v4l2_sources += [ 'v4l2-udev.c' ]
v4l2_dependencies += [ libudev_dep ]
if systemd_dep.found()
v4l2_dependencies += [ systemd_dep ]
if logind_dep.found()
v4l2_dependencies += [ logind_dep ]
endif
endif

View file

@ -27,7 +27,7 @@
#include "config.h"
#include "v4l2.h"
#ifdef HAVE_SYSTEMD
#ifdef HAVE_LOGIND
#include <systemd/sd-login.h>
#endif
@ -66,7 +66,7 @@ struct impl {
struct spa_source source;
struct spa_source notify;
#ifdef HAVE_SYSTEMD
#ifdef HAVE_LOGIND
struct spa_source logind;
sd_login_monitor *logind_monitor;
#endif
@ -472,7 +472,7 @@ static int start_inotify(struct impl *this)
{
int notify_fd;
#ifdef HAVE_SYSTEMD
#ifdef HAVE_LOGIND
/* Do not use inotify when using logind session monitoring */
if (this->logind_monitor)
return 0;
@ -495,7 +495,7 @@ static int start_inotify(struct impl *this)
return 0;
}
#ifdef HAVE_SYSTEMD
#ifdef HAVE_LOGIND
static void impl_on_logind_events(struct spa_source *source)
{
struct impl *this = source->data;
@ -769,7 +769,7 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
this->notify.fd = -1;
#ifdef HAVE_SYSTEMD
#ifdef HAVE_LOGIND
this->logind_monitor = NULL;
#endif