mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-06 13:45:43 +01:00
Add a PBD API to set pthread priority
This commit is contained in:
parent
f72c819035
commit
229c9584bf
3 changed files with 68 additions and 24 deletions
|
|
@ -82,30 +82,7 @@ BaseUI::new_request_type ()
|
|||
int
|
||||
BaseUI::set_thread_priority (const int policy, int priority) const
|
||||
{
|
||||
struct sched_param param;
|
||||
memset (¶m, 0, sizeof (param));
|
||||
|
||||
/* POSIX requires a spread of at least 32 steps between min..max */
|
||||
const int p_min = sched_get_priority_min (policy); // Linux: 1
|
||||
const int p_max = sched_get_priority_max (policy); // Linux: 99
|
||||
|
||||
if (priority == 0) {
|
||||
/* use default. XXX this should be relative to audio (JACK) thread,
|
||||
* internal backends use -20 (Audio), -21 (MIDI), -22 (compuation)
|
||||
*/
|
||||
priority = 7;
|
||||
}
|
||||
|
||||
if (priority > 0) {
|
||||
priority += p_min;
|
||||
} else {
|
||||
priority += p_max;
|
||||
}
|
||||
if (priority > p_max) priority = p_max;
|
||||
if (priority < p_min) priority = p_min;
|
||||
param.sched_priority = priority;
|
||||
|
||||
return pthread_setschedparam (pthread_self(), SCHED_FIFO, ¶m);
|
||||
return pbd_set_thread_priority (pthread_self(), policy, priority);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue