From: Robin Gareus Date: Tue, 18 Dec 2018 12:30:31 +0000 (+0100) Subject: Add LV2 option/extension for plugin thread sched priority X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=commitdiff_plain;h=0a3fc4a87fcdab7f7c1ed95d42ec7ac28c95c3e1 Add LV2 option/extension for plugin thread sched priority This allows plugins that need threads to process to configure their thread priority to not interfere with the host's process threads. --- diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 79bef11cdd..15c96ac83e 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -37,6 +37,7 @@ #include "pbd/compose.h" #include "pbd/error.h" #include "pbd/locale_guard.h" +#include "pbd/pthread_utils.h" #include "pbd/replace_all.h" #include "pbd/xml++.h" @@ -495,6 +496,8 @@ LV2Plugin::init(const void* c_plugin, samplecnt_t rate) LV2_URID atom_Int = _uri_map.uri_to_id(LV2_ATOM__Int); 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 () - 2); /* Consider updating max-block-size whenever the buffersize changes. * It requires re-instantiating the plugin (which is a non-realtime operation), * so it should be done lightly and only for plugins that require it. @@ -511,6 +514,10 @@ LV2Plugin::init(const void* c_plugin, samplecnt_t rate) sizeof(int32_t), atom_Int, &_seq_size }, { LV2_OPTIONS_INSTANCE, 0, _uri_map.uri_to_id("http://lv2plug.in/ns/ext/buf-size#nominalBlockLength"), sizeof(int32_t), atom_Int, &_impl->block_length }, + { LV2_OPTIONS_INSTANCE, 0, _uri_map.uri_to_id("http://ardour.org/lv2/threads/#schedPolicy"), + sizeof(int32_t), atom_Int, &rt_policy }, + { LV2_OPTIONS_INSTANCE, 0, _uri_map.uri_to_id("http://ardour.org/lv2/threads/#schedPriority"), + sizeof(int32_t), atom_Int, &rt_priority }, { LV2_OPTIONS_INSTANCE, 0, 0, 0, 0, NULL } };