13
0

Always use PBD API for thread priorities

This commit is contained in:
Robin Gareus 2024-09-28 03:49:59 +02:00
parent 0b5a197f76
commit 395833e4f8
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
6 changed files with 9 additions and 5 deletions

View File

@ -201,7 +201,7 @@ AutomationWatch::timer ()
void
AutomationWatch::thread ()
{
pbd_set_thread_priority (pthread_self(), PBD_SCHED_FIFO, AudioEngine::instance()->client_real_time_priority() - 2); // XXX
pbd_set_thread_priority (pthread_self(), PBD_SCHED_FIFO, PBD_RT_PRI_CTRL);
while (_run_thread) {
Glib::usleep ((gulong) floor (Config->get_automation_interval_msecs() * 1000)); // TODO use pthread_cond_timedwait on _run_thread
timer ();

View File

@ -169,7 +169,7 @@ Convolution::restart ()
}
if (rv == 0) {
rv = _convproc.start_process (pbd_absolute_rt_priority (PBD_SCHED_FIFO, AudioEngine::instance ()->client_real_time_priority () - 1), PBD_SCHED_FIFO);
rv = _convproc.start_process (pbd_absolute_rt_priority (PBD_SCHED_FIFO, PBD_RT_PRI_PROC), PBD_SCHED_FIFO);
}
assert (rv == 0); // bail out in debug builds

View File

@ -815,7 +815,7 @@ ARDOUR::init_post_engine (uint32_t start_cnt)
}
}
BaseUI::set_thread_priority (pbd_absolute_rt_priority (PBD_SCHED_FIFO, AudioEngine::instance()->client_real_time_priority () - 2));
BaseUI::set_thread_priority (pbd_absolute_rt_priority (PBD_SCHED_FIFO, PBD_RT_PRI_CTRL));
TransportMasterManager::instance ().restart ();
}

View File

@ -607,7 +607,7 @@ LV2Plugin::init(const void* c_plugin, samplecnt_t rate)
static const int32_t _min_block_length = 1; // may happen during split-cycles
static const int32_t _max_block_length = 8192; // max possible (with all engines and during export)
static const int32_t rt_policy = PBD_SCHED_FIFO;
static const int32_t rt_priority = pbd_absolute_rt_priority (PBD_SCHED_FIFO, AudioEngine::instance()->client_real_time_priority () - 1);
static const int32_t rt_priority = pbd_absolute_rt_priority (PBD_SCHED_FIFO, PBD_RT_PRI_PROC);
static const int32_t hw_concurrency = how_many_dsp_threads ();
/* Consider updating max-block-size whenever the buffersize changes.
* It requires re-instantiating the plugin (which is a non-realtime operation),

View File

@ -50,7 +50,7 @@ using namespace PBD;
using namespace Glib;
uint64_t BaseUI::rt_bit = 1;
int BaseUI::_thread_priority = PBD_RT_PRI_PROC - 1;
int BaseUI::_thread_priority = PBD_RT_PRI_CTRL;
BaseUI::RequestType BaseUI::CallSlot = BaseUI::new_request_type();
BaseUI::RequestType BaseUI::Quit = BaseUI::new_request_type();

View File

@ -57,6 +57,7 @@
# define PBD_RT_PRI_MAIN pbd_pthread_priority (THREAD_MAIN)
# 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)
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);
@ -65,10 +66,13 @@ LIBPBD_API void pthread_kill_all (int signum);
LIBPBD_API const char* pthread_name ();
LIBPBD_API void pthread_set_name (const char* name);
LIBPBD_API void pbd_set_engine_rt_priority (int);
enum PBDThreadClass {
THREAD_MAIN, // main audio I/O thread
THREAD_MIDI, // MIDI I/O threads
THREAD_PROC, // realtime worker
THREAD_CTRL, // Automation watch, BaseUI
THREAD_IO // non-realtime I/O
};