aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-05-09 12:38:12 -0700
committerChris Robinson <[email protected]>2022-05-09 12:38:12 -0700
commitc870e550fa37d10e8a9d7d15ef1d6370d1e0399e (patch)
treeda7489113d46f666e35f38078511c3ee8a66b592
parent5c55ec2f9bd972510454a04ccb40238f4cd0219c (diff)
Don't enable RTKit/D-Bus support on Windows
-rw-r--r--CMakeLists.txt63
-rw-r--r--core/helpers.cpp23
2 files changed, 44 insertions, 42 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ea646617..d3945e95 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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")
diff --git a/core/helpers.cpp b/core/helpers.cpp
index e4a94fe5..c7e45a8b 100644
--- a/core/helpers.cpp
+++ b/core/helpers.cpp
@@ -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)