mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
module-rt: limit nice level based on rtkit min nice
Ask RTKit what the min nice level is and clamp our value to it to avoid InvalidArgument errors. Also add some more info messages when the level is clamped or invalid. Fixes #3186
This commit is contained in:
parent
5942f2d6aa
commit
b3bb7fd567
1 changed files with 18 additions and 2 deletions
|
|
@ -111,7 +111,9 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
#define PW_SCHED_RESET_ON_FORK 0
|
||||
#endif
|
||||
|
||||
#define IS_VALID_NICE_LEVEL(l) ((l)>=-20 && (l)<=19)
|
||||
#define MIN_NICE_LEVEL -20
|
||||
#define MAX_NICE_LEVEL 19
|
||||
#define IS_VALID_NICE_LEVEL(l) ((l)>=MIN_NICE_LEVEL && (l)<=MAX_NICE_LEVEL)
|
||||
|
||||
#define DEFAULT_NICE_LEVEL 20
|
||||
#define DEFAULT_RT_PRIO_MIN 11
|
||||
|
|
@ -631,8 +633,16 @@ static int set_nice(struct impl *impl, int nice_level, bool warn)
|
|||
int res = 0;
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
if (impl->use_rtkit)
|
||||
if (impl->use_rtkit) {
|
||||
int min_nice = nice_level;
|
||||
pw_rtkit_get_min_nice_level(impl, &min_nice);
|
||||
if (nice_level < min_nice) {
|
||||
pw_log_info("clamped nice level %d to %d",
|
||||
nice_level, min_nice);
|
||||
nice_level = min_nice;
|
||||
}
|
||||
res = pw_rtkit_make_high_priority(impl, 0, nice_level);
|
||||
}
|
||||
else
|
||||
res = sched_set_nice(nice_level);
|
||||
#else
|
||||
|
|
@ -986,6 +996,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
|
||||
bool can_use_rtkit = false, use_rtkit = false;
|
||||
|
||||
if (!IS_VALID_NICE_LEVEL(impl->nice_level)) {
|
||||
pw_log_info("invalid nice level %d (not between %d and %d). "
|
||||
"nice level will not be adjusted",
|
||||
impl->nice_level, MIN_NICE_LEVEL, MAX_NICE_LEVEL);
|
||||
}
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
spa_list_init(&impl->threads_list);
|
||||
pthread_mutex_init(&impl->lock, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue