diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index 6b51cb3eae..1090f30307 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -225,7 +225,11 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee LV2_Feature _make_path_feature; LV2_Feature _log_feature; LV2_Feature _work_schedule_feature; - LV2_Feature _buf_size_feature; + LV2_Feature _options_feature; + + // Options passed to plugin + int32_t _block_length; + int32_t _seq_size; mutable unsigned _state_version; diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 14d4b6355c..80cf7efb44 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -52,6 +52,7 @@ #include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "lv2/lv2plug.in/ns/ext/log/log.h" +#include "lv2/lv2plug.in/ns/ext/options/options.h" #include "lv2/lv2plug.in/ns/ext/port-props/port-props.h" #include "lv2/lv2plug.in/ns/ext/presets/presets.h" #include "lv2/lv2plug.in/ns/ext/state/state.h" @@ -158,46 +159,6 @@ work_respond(LV2_Worker_Respond_Handle handle, } } -/* buf-size extension */ - -#ifdef HAVE_NEW_LV2 -/** Called by the plugin to discover properties of the block length. */ -static LV2_Buf_Size_Status -get_sample_count(LV2_Buf_Size_Access_Handle handle, - uint32_t* min, - uint32_t* max, - uint32_t* multiple_of, - uint32_t* power_of) -{ - AudioEngine* engine = (AudioEngine*)handle; - *min = 1; - *max = engine->frames_per_cycle(); - *multiple_of = 1; - *power_of = 0; - return LV2_BUF_SIZE_SUCCESS; -} - -/** Called by the plugin to get the size required for some buffer type. */ -static LV2_Buf_Size_Status -get_buf_size(LV2_Buf_Size_Access_Handle handle, - uint32_t* buf_size, - LV2_URID type, - uint32_t sample_count) -{ - AudioEngine* engine = (AudioEngine*)handle; - if (type == LV2Plugin::_sequence_type) { - *buf_size = engine->raw_buffer_size(DataType::MIDI); - return LV2_BUF_SIZE_SUCCESS; - } - *buf_size = 0; - return LV2_BUF_SIZE_ERR_BAD_TYPE; -} - -static LV2_Buf_Size_Access buf_size_access = { - NULL, sizeof(LV2_Buf_Size_Access), get_sample_count, get_buf_size -}; -#endif - /* log extension */ static int @@ -299,6 +260,8 @@ LV2Plugin::init(const void* c_plugin, framecnt_t rate) _bpm_control_port = 0; _freewheel_control_port = 0; _latency_control_port = 0; + _block_length = _engine.frames_per_cycle(); + _seq_size = _engine.raw_buffer_size(DataType::MIDI); _state_version = 0; _was_activated = false; _has_state_interface = false; @@ -310,12 +273,6 @@ LV2Plugin::init(const void* c_plugin, framecnt_t rate) _work_schedule_feature.URI = LV2_WORKER__schedule; _work_schedule_feature.data = NULL; -#ifdef HAVE_NEW_LV2 - _buf_size_feature.URI = LV2_BUF_SIZE__access; - _buf_size_feature.data = &buf_size_access; - buf_size_access.handle = &_engine; -#endif - const LilvPlugin* plugin = _impl->plugin; LilvNode* state_iface_uri = lilv_new_uri(_world.world, LV2_STATE__interface); @@ -339,10 +296,20 @@ LV2Plugin::init(const void* c_plugin, framecnt_t rate) unsigned n_features = 7; #ifdef HAVE_NEW_LV2 - _buf_size_feature.URI = LV2_BUF_SIZE__access; - _buf_size_feature.data = &buf_size_access; - buf_size_access.handle = &_engine; - _features[n_features++] = &_buf_size_feature; + LV2_URID atom_Int = _uri_map.uri_to_id(LV2_ATOM__Int); + LV2_Options_Option options[] = { + { _uri_map.uri_to_id(LV2_BUF_SIZE__minBlockLength), + sizeof(int32_t), atom_Int, &_block_length }, + { _uri_map.uri_to_id(LV2_BUF_SIZE__maxBlockLength), + sizeof(int32_t), atom_Int, &_block_length }, + { _uri_map.uri_to_id(LV2_BUF_SIZE__sequenceSize), + sizeof(int32_t), atom_Int, &_seq_size }, + { 0, 0, 0, NULL } + }; + + _options_feature.URI = LV2_OPTIONS__options; + _options_feature.data = options; + _features[n_features++] = &_options_feature; #endif LV2_State_Make_Path* make_path = (LV2_State_Make_Path*)malloc( diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 9b3e7944fd..e01de3e764 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -259,7 +259,7 @@ def configure(conf): autowaf.check_pkg(conf, 'lv2', uselib_store='LV2', atleast_version='1.0.0', mandatory=True) autowaf.check_pkg(conf, 'lv2', uselib_store='NEW_LV2', - atleast_version='1.0.7', mandatory=False) + atleast_version='1.0.13', mandatory=False) autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD', atleast_version='0.14.0', mandatory=True) autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD',