Don't override existing host thread priorities

If the thread that's hosting yabridge's plugin is already using realtime
scheduling.
This commit is contained in:
Robbert van der Helm
2021-01-21 20:30:08 +01:00
parent f8ac296ec7
commit 9b0324f4a7
2 changed files with 12 additions and 0 deletions
+10
View File
@@ -32,6 +32,16 @@ fs::path get_temporary_directory() {
}
bool set_realtime_priority(bool sched_fifo) {
// If we're already using SCHED_FIFO then this is likely set by the host,
// and we should not make any additional changes
if (sched_fifo) {
sched_param current_params{};
if (sched_getparam(0, &current_params) == 0 &&
current_params.sched_priority > 0) {
return true;
}
}
sched_param params{.sched_priority = 5};
return sched_setscheduler(0, sched_fifo ? SCHED_FIFO : SCHED_OTHER,
&params) == 0;