Don't enable RTKit/D-Bus support on Windows

This commit is contained in:
Chris Robinson 2022-05-09 12:38:12 -07:00
parent 5c55ec2f9b
commit c870e550fa
2 changed files with 44 additions and 42 deletions

View File

@ -677,39 +677,42 @@ set(CORE_OBJS
core/voice_change.h)
set(HAVE_RTKIT 0)
option(ALSOFT_REQUIRE_RTKIT "Require RTKit/D-Bus support" FALSE)
find_package(DBus1 QUIET)
if(NOT DBus1_FOUND AND PkgConfig_FOUND)
pkg_check_modules(DBUS dbus-1)
endif()
if(DBus1_FOUND OR DBUS_FOUND)
option(ALSOFT_RTKIT "Enable RTKit support" ON)
if(ALSOFT_RTKIT)
set(HAVE_RTKIT 1)
set(CORE_OBJS ${CORE_OBJS} core/dbus_wrap.cpp core/dbus_wrap.h core/rtkit.cpp core/rtkit.h)
if(NOT DBus1_FOUND)
set(INC_PATHS ${INC_PATHS} ${DBUS_INCLUDE_DIRS})
set(CPP_DEFS ${CPP_DEFS} ${DBUS_CFLAGS_OTHER})
if(NOT WIN32 AND NOT HAVE_DLFCN_H)
set(EXTRA_LIBS ${EXTRA_LIBS} ${DBUS_LINK_LIBRARIES})
if(NOT WIN32)
option(ALSOFT_REQUIRE_RTKIT "Require RTKit/D-Bus support" FALSE)
find_package(DBus1 QUIET)
if(NOT DBus1_FOUND AND PkgConfig_FOUND)
pkg_check_modules(DBUS dbus-1)
endif()
if(DBus1_FOUND OR DBUS_FOUND)
option(ALSOFT_RTKIT "Enable RTKit support" ON)
if(ALSOFT_RTKIT)
set(HAVE_RTKIT 1)
set(CORE_OBJS ${CORE_OBJS} core/dbus_wrap.cpp core/dbus_wrap.h
core/rtkit.cpp core/rtkit.h)
if(NOT DBus1_FOUND)
set(INC_PATHS ${INC_PATHS} ${DBUS_INCLUDE_DIRS})
set(CPP_DEFS ${CPP_DEFS} ${DBUS_CFLAGS_OTHER})
if(NOT HAVE_DLFCN_H)
set(EXTRA_LIBS ${EXTRA_LIBS} ${DBUS_LINK_LIBRARIES})
endif()
elseif(HAVE_DLFCN_H)
set(INC_PATHS ${INC_PATHS} ${DBus1_INCLUDE_DIRS})
set(CPP_DEFS ${CPP_DEFS} ${DBus1_DEFINITIONS})
else()
set(EXTRA_LIBS ${EXTRA_LIBS} ${DBus1_LIBRARIES})
endif()
elseif(WIN32 OR HAVE_DLFCN_H)
set(INC_PATHS ${INC_PATHS} ${DBus1_INCLUDE_DIRS})
set(CPP_DEFS ${CPP_DEFS} ${DBus1_DEFINITIONS})
else()
set(EXTRA_LIBS ${EXTRA_LIBS} ${DBus1_LIBRARIES})
endif()
else()
set(MISSING_VARS "")
if(NOT DBus1_INCLUDE_DIRS)
set(MISSING_VARS "${MISSING_VARS} DBus1_INCLUDE_DIRS")
endif()
if(NOT DBus1_LIBRARIES)
set(MISSING_VARS "${MISSING_VARS} DBus1_LIBRARIES")
endif()
message(STATUS "Could NOT find DBus1 (missing:${MISSING_VARS})")
unset(MISSING_VARS)
endif()
else()
set(MISSING_VARS "")
if(NOT DBus1_INCLUDE_DIRS)
set(MISSING_VARS "${MISSING_VARS} DBus1_INCLUDE_DIRS")
endif()
if(NOT DBus1_LIBRARIES)
set(MISSING_VARS "${MISSING_VARS} DBus1_LIBRARIES")
endif()
message(STATUS "Could NOT find DBus1 (missing:${MISSING_VARS})")
unset(MISSING_VARS)
endif()
if(ALSOFT_REQUIRE_RTKIT AND NOT HAVE_RTKIT)
message(FATAL_ERROR "Failed to enabled required RTKit support")

View File

@ -461,6 +461,17 @@ bool SetRTPriorityRTKit(int prio)
/* Don't stupidly exit if the connection dies while doing this. */
dbus_connection_set_exit_on_disconnect(conn.get(), false);
int nicemin{};
int err{rtkit_get_min_nice_level(conn.get(), &nicemin)};
if(err == -ENOENT)
{
err = std::abs(err);
ERR("Could not query RTKit: %s (%d)\n", std::strerror(err), err);
return false;
}
int rtmax{rtkit_get_max_realtime_priority(conn.get())};
TRACE("Maximum real-time priority: %d, minimum niceness: %d\n", rtmax, nicemin);
auto limit_rttime = [](DBusConnection *c) -> int
{
using ulonglong = unsigned long long;
@ -483,18 +494,6 @@ bool SetRTPriorityRTKit(int prio)
}
return 0;
};
int nicemin{};
int err{rtkit_get_min_nice_level(conn.get(), &nicemin)};
if(err == -ENOENT)
{
err = std::abs(err);
ERR("Could not query RTKit: %s (%d)\n", std::strerror(err), err);
return false;
}
int rtmax{rtkit_get_max_realtime_priority(conn.get())};
TRACE("Maximum real-time priority: %d, minimum niceness: %d\n", rtmax, nicemin);
if(rtmax > 0)
{
if(AllowRTTimeLimit)