From 0aff098541183891b99b74327b5b46b5618212cd Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 11 Oct 2024 10:06:49 +0200 Subject: [PATCH] Fix IO Thread priority This adds `pbd_pthread_priority` indirection to correctly get the absolute thread priority. and for consistency a 4 letter enum is used. --- libs/ardour/io_tasklist.cc | 2 +- libs/pbd/pbd/pthread_utils.h | 3 ++- libs/pbd/pthread_utils.cc | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/ardour/io_tasklist.cc b/libs/ardour/io_tasklist.cc index faa0b02ccaf..d5dd73894f6 100644 --- a/libs/ardour/io_tasklist.cc +++ b/libs/ardour/io_tasklist.cc @@ -76,7 +76,7 @@ IOTaskList::IOTaskList (uint32_t n_threads) _workers.resize (_n_threads); for (uint32_t i = 0; i < _n_threads; ++i) { - if (!use_rt || pbd_realtime_pthread_create (policy, THREAD_IO, 0, &_workers[i], &_worker_thread, this)) { + if (!use_rt || pbd_realtime_pthread_create (policy, PBD_RT_PRI_IOFX, 0, &_workers[i], &_worker_thread, this)) { if (use_rt && i == 0) { PBD::warning << _("IOTaskList: cannot acquire realtime permissions.") << endmsg; } diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h index 01108861cfa..069f9c9c23d 100644 --- a/libs/pbd/pbd/pthread_utils.h +++ b/libs/pbd/pbd/pthread_utils.h @@ -58,6 +58,7 @@ # define PBD_RT_PRI_MIDI pbd_pthread_priority (THREAD_MIDI) # define PBD_RT_PRI_PROC pbd_pthread_priority (THREAD_PROC) # define PBD_RT_PRI_CTRL pbd_pthread_priority (THREAD_CTRL) +# define PBD_RT_PRI_IOFX pbd_pthread_priority (THREAD_IOFX) LIBPBD_API int pthread_create_and_store (std::string name, pthread_t *thread, void * (*start_routine)(void *), void * arg, uint32_t stacklimit = 0x80000 /*512kB*/); LIBPBD_API void pthread_cancel_one (pthread_t thread); @@ -73,7 +74,7 @@ enum PBDThreadClass { THREAD_MIDI, // MIDI I/O threads THREAD_PROC, // realtime worker THREAD_CTRL, // Automation watch, BaseUI - THREAD_IO // non-realtime I/O + THREAD_IOFX // non-realtime I/O and regionFX }; LIBPBD_API int pbd_pthread_priority (PBDThreadClass); diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index 88e21d26240..721de0a7288 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -348,7 +348,7 @@ pbd_pthread_priority (PBDThreadClass which) case THREAD_CTRL: default: return -14; // THREAD_PRIORITY_HIGHEST (2) - case THREAD_IO: + case THREAD_IOFX: /* https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-libraries/winpthreads/src/sched.c */ return -15; // THREAD_PRIORITY_ABOVE_NORMAL (1) } @@ -372,7 +372,7 @@ pbd_pthread_priority (PBDThreadClass which) return base - 2; case THREAD_CTRL: return base - 3; - case THREAD_IO: + case THREAD_IOFX: return base - 10; } #endif