summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2018-12-18 13:30:31 +0100
committerRobin Gareus <robin@gareus.org>2018-12-18 13:30:31 +0100
commit0a3fc4a87fcdab7f7c1ed95d42ec7ac28c95c3e1 (patch)
tree035f5a32c19658a0b7b6f173228987d559a4b280
parent0d55dad0456e556f1dd969f266329452ebc2cabb (diff)
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.
-rw-r--r--libs/ardour/lv2_plugin.cc7
1 files changed, 7 insertions, 0 deletions
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 }
};