Skip to content

Commit

Permalink
Fix IO Thread priority
Browse files Browse the repository at this point in the history
This adds `pbd_pthread_priority` indirection to correctly get
the absolute thread priority.

and for consistency a 4 letter enum is used.
  • Loading branch information
x42 committed Oct 11, 2024
1 parent 5efa5b4 commit 0aff098
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/ardour/io_tasklist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion libs/pbd/pbd/pthread_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions libs/pbd/pthread_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand Down

0 comments on commit 0aff098

Please sign in to comment.