Set niceness as a fallback only on Linux

If pthread_setschedparam and rtkit_make_realtime both fail, lowering niceness
can also work to boost priority. However, this only works on Linux and other
OSs that implement a per-thread niceness (POSIX standard has it per-process,
which isn't desirable behavior here).
master
Chris Robinson 2022-01-18 14:32:15 -08:00
parent 4920167fa0
commit 5306c9d424
1 changed files with 9 additions and 0 deletions

View File

@ -512,6 +512,12 @@ bool SetRTPriorityRTKit(int prio)
err = std::abs(err);
WARN("Failed to set real-time priority: %s (%d)\n", std::strerror(err), err);
}
/* Don't try to set the niceness for non-Linux systems. Standard POSIX has
* niceness as a per-process attribute, while the intent here is for the
* audio processing thread only to get a priority boost. Currently only
* Linux is known to have per-thread niceness.
*/
#ifdef __linux__
if(nicemin < 0)
{
TRACE("Making high priority with niceness %d\n", nicemin);
@ -521,7 +527,10 @@ bool SetRTPriorityRTKit(int prio)
err = std::abs(err);
WARN("Failed to set high priority: %s (%d)\n", std::strerror(err), err);
}
#endif /* __linux__ */
#else
WARN("D-Bus not supported\n");
#endif
return false;