mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
Allow to override rt priority for internal backends
This commit is contained in:
parent
2c8916310a
commit
89a0040f1b
2 changed files with 50 additions and 13 deletions
|
|
@ -54,15 +54,9 @@
|
||||||
/* these are relative to sched_get_priority_max()
|
/* these are relative to sched_get_priority_max()
|
||||||
* see pbd_absolute_rt_priority()
|
* see pbd_absolute_rt_priority()
|
||||||
*/
|
*/
|
||||||
#ifdef PLATFORM_WINDOWS
|
# define PBD_RT_PRI_MAIN pbd_pthread_priority (THREAD_MAIN)
|
||||||
# define PBD_RT_PRI_MAIN -1
|
# define PBD_RT_PRI_MIDI pbd_pthread_priority (THREAD_MIDI)
|
||||||
# define PBD_RT_PRI_MIDI -2
|
# define PBD_RT_PRI_PROC pbd_pthread_priority (THREAD_PROC)
|
||||||
# define PBD_RT_PRI_PROC -2
|
|
||||||
#else
|
|
||||||
# define PBD_RT_PRI_MAIN -20
|
|
||||||
# define PBD_RT_PRI_MIDI -21
|
|
||||||
# define PBD_RT_PRI_PROC -22
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LIBPBD_API int pthread_create_and_store (std::string name, pthread_t *thread, void * (*start_routine)(void *), void * arg);
|
LIBPBD_API int pthread_create_and_store (std::string name, pthread_t *thread, void * (*start_routine)(void *), void * arg);
|
||||||
LIBPBD_API void pthread_cancel_one (pthread_t thread);
|
LIBPBD_API void pthread_cancel_one (pthread_t thread);
|
||||||
|
|
@ -71,6 +65,14 @@ LIBPBD_API void pthread_kill_all (int signum);
|
||||||
LIBPBD_API const char* pthread_name ();
|
LIBPBD_API const char* pthread_name ();
|
||||||
LIBPBD_API void pthread_set_name (const char* name);
|
LIBPBD_API void pthread_set_name (const char* name);
|
||||||
|
|
||||||
|
enum PBDThreadClass {
|
||||||
|
THREAD_MAIN, // main audio I/O thread
|
||||||
|
THREAD_MIDI, // MIDI I/O threads
|
||||||
|
THREAD_PROC // realtime worker
|
||||||
|
};
|
||||||
|
|
||||||
|
LIBPBD_API int pbd_pthread_priority (PBDThreadClass);
|
||||||
|
|
||||||
LIBPBD_API int pbd_pthread_create (
|
LIBPBD_API int pbd_pthread_create (
|
||||||
const size_t stacksize,
|
const size_t stacksize,
|
||||||
pthread_t *thread,
|
pthread_t *thread,
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,42 @@ pbd_pthread_create (
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pbd_pthread_priority (PBDThreadClass which)
|
||||||
|
{
|
||||||
|
/* fall back to use values relative to max */
|
||||||
|
#ifdef PLATFORM_WINDOWS
|
||||||
|
switch (which) {
|
||||||
|
case THREAD_MAIN:
|
||||||
|
return -1;
|
||||||
|
case THREAD_MIDI:
|
||||||
|
return -2;
|
||||||
|
default:
|
||||||
|
case THREAD_PROC:
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int base = -20;
|
||||||
|
const char* p = getenv ("ARDOUR_SCHED_PRI");
|
||||||
|
if (p && *p) {
|
||||||
|
base = atoi (p);
|
||||||
|
if (base > -5 && base < 5) {
|
||||||
|
base = -20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (which) {
|
||||||
|
case THREAD_MAIN:
|
||||||
|
return base;
|
||||||
|
case THREAD_MIDI:
|
||||||
|
return base - 1;
|
||||||
|
default:
|
||||||
|
case THREAD_PROC:
|
||||||
|
return base - 2;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pbd_absolute_rt_priority (int policy, int priority)
|
pbd_absolute_rt_priority (int policy, int priority)
|
||||||
{
|
{
|
||||||
|
|
@ -285,13 +321,12 @@ pbd_absolute_rt_priority (int policy, int priority)
|
||||||
const int p_max = sched_get_priority_max (policy); // Linux: 99
|
const int p_max = sched_get_priority_max (policy); // Linux: 99
|
||||||
|
|
||||||
if (priority == 0) {
|
if (priority == 0) {
|
||||||
/* use default. XXX this should be relative to audio (JACK) thread,
|
|
||||||
* internal backends use -20 (Audio), -21 (MIDI), -22 (compuation)
|
|
||||||
*/
|
|
||||||
priority = (p_min + p_max) / 2;
|
priority = (p_min + p_max) / 2;
|
||||||
} else if (priority > 0) {
|
} else if (priority > 0) {
|
||||||
priority += p_min;
|
/* value relative to minium */
|
||||||
|
priority += p_min - 1;
|
||||||
} else {
|
} else {
|
||||||
|
/* value relative maximum */
|
||||||
priority += p_max + 1;
|
priority += p_max + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue