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.
This commit is contained in:
Robin Gareus 2018-12-18 13:30:31 +01:00
parent 0d55dad045
commit 0a3fc4a87f
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -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 }
};