mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
module-rt: make sure we change nice of main_pid
This commit is contained in:
parent
09277cbfa4
commit
66c09682c4
1 changed files with 8 additions and 6 deletions
|
|
@ -173,6 +173,7 @@ struct impl {
|
||||||
|
|
||||||
struct spa_thread_utils thread_utils;
|
struct spa_thread_utils thread_utils;
|
||||||
|
|
||||||
|
pid_t main_pid;
|
||||||
struct rlimit rl;
|
struct rlimit rl;
|
||||||
int nice_level;
|
int nice_level;
|
||||||
int rt_prio;
|
int rt_prio;
|
||||||
|
|
@ -587,9 +588,9 @@ static bool check_realtime_privileges(struct impl *impl)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sched_set_nice(int nice_level)
|
static int sched_set_nice(pid_t pid, int nice_level)
|
||||||
{
|
{
|
||||||
if (setpriority(PRIO_PROCESS, _gettid(), nice_level) == 0)
|
if (setpriority(PRIO_PROCESS, pid, nice_level) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
@ -606,12 +607,12 @@ static int set_nice(struct impl *impl, int nice_level, bool warn)
|
||||||
nice_level, impl->min_nice_level);
|
nice_level, impl->min_nice_level);
|
||||||
nice_level = impl->min_nice_level;
|
nice_level = impl->min_nice_level;
|
||||||
}
|
}
|
||||||
res = pw_rtkit_make_high_priority(impl, 0, nice_level);
|
res = pw_rtkit_make_high_priority(impl, impl->main_pid, nice_level);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (impl->rlimits_enabled)
|
if (impl->rlimits_enabled)
|
||||||
res = sched_set_nice(nice_level);
|
res = sched_set_nice(impl->main_pid, nice_level);
|
||||||
else
|
else
|
||||||
res = -ENOTSUP;
|
res = -ENOTSUP;
|
||||||
|
|
||||||
|
|
@ -813,7 +814,7 @@ static int do_make_realtime(struct spa_loop *loop, bool async, uint32_t seq,
|
||||||
int err, min, max, priority = params->priority;
|
int err, min, max, priority = params->priority;
|
||||||
pid_t pid = params->pid;
|
pid_t pid = params->pid;
|
||||||
|
|
||||||
pw_log_info(".");
|
pw_log_debug("rtkit realtime");
|
||||||
|
|
||||||
if ((err = get_rtkit_priority_range(impl, &min, &max)) < 0)
|
if ((err = get_rtkit_priority_range(impl, &min, &max)) < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -933,7 +934,7 @@ static int do_rtkit_setup(struct spa_loop *loop, bool async, uint32_t seq,
|
||||||
int res;
|
int res;
|
||||||
long long retval;
|
long long retval;
|
||||||
|
|
||||||
pw_log_debug("enter dbus setup");
|
pw_log_debug("enter rtkit setup");
|
||||||
|
|
||||||
/* Checking xdg-desktop-portal. It works fine in all situations. */
|
/* Checking xdg-desktop-portal. It works fine in all situations. */
|
||||||
if (impl->rtportal_enabled)
|
if (impl->rtportal_enabled)
|
||||||
|
|
@ -1029,6 +1030,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
|
|
||||||
impl->rl.rlim_cur = impl->rt_time_soft;
|
impl->rl.rlim_cur = impl->rt_time_soft;
|
||||||
impl->rl.rlim_max = impl->rt_time_hard;
|
impl->rl.rlim_max = impl->rt_time_hard;
|
||||||
|
impl->main_pid = _gettid();
|
||||||
|
|
||||||
bool can_use_rtkit = false, use_rtkit = false;
|
bool can_use_rtkit = false, use_rtkit = false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue