From 30a4ba74b2a1870f2204481cbe9681ead9da9fd0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 12 Aug 2008 01:13:26 +0000 Subject: [PATCH] Support for the LV2 'data access' and 'instance access' extensions (for in-process GUIs). git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3684 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/lv2_plugin_ui.cc | 2 +- libs/ardour/ardour/lv2_plugin.h | 10 ++++++++++ libs/ardour/lv2_plugin.cc | 20 +++++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/lv2_plugin_ui.cc b/gtk2_ardour/lv2_plugin_ui.cc index 7df1dbfe85..2ca9166dea 100644 --- a/gtk2_ardour/lv2_plugin_ui.cc +++ b/gtk2_ardour/lv2_plugin_ui.cc @@ -57,7 +57,7 @@ LV2PluginUI::LV2PluginUI (boost::shared_ptr pi, boost::shared_ptr< { _inst = slv2_ui_instantiate( _lv2->slv2_plugin(), _lv2->slv2_ui(), LV2PluginUI::lv2_ui_write, this, - /* FEATURES */ NULL); + _lv2->features()); GtkWidget* c_widget = (GtkWidget*)slv2_ui_instance_get_widget(_inst); _gui_widget = Glib::wrap(c_widget); diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index 8d58c7024d..be584b76c3 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -60,10 +60,14 @@ class LV2Plugin : public ARDOUR::Plugin int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const; uint32_t nth_parameter (uint32_t port, bool& ok) const; + const void* extension_data(const char* uri) { return _instance->lv2_descriptor->extension_data(uri); } + SLV2Plugin slv2_plugin() { return _plugin; } SLV2UI slv2_ui() { return _ui; } SLV2Port slv2_port(uint32_t i) { return slv2_plugin_get_port_by_index(_plugin, i); } + const LV2_Feature* const* features() { return _features; } + std::set automatable() const; void activate () { @@ -109,6 +113,7 @@ class LV2Plugin : public ARDOUR::Plugin private: void* _module; LV2World& _world; + LV2_Feature** _features; SLV2Plugin _plugin; SLV2UI _ui; SLV2Value _name; @@ -122,6 +127,11 @@ class LV2Plugin : public ARDOUR::Plugin bool _was_activated; vector _port_is_input; + typedef struct { const void* (*extension_data)(const char* uri); } LV2_DataAccess; + LV2_DataAccess _data_access_extension_data; + LV2_Feature _data_access_feature; + LV2_Feature _instance_access_feature; + void init (LV2World& world, SLV2Plugin plugin, nframes_t rate); void run (nframes_t nsamples); void latency_compute_run (); diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 028d0c5b45..1b9f278012 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -43,10 +43,11 @@ using namespace std; using namespace ARDOUR; using namespace PBD; - + LV2Plugin::LV2Plugin (AudioEngine& e, Session& session, LV2World& world, SLV2Plugin plugin, nframes_t rate) : Plugin (e, session) , _world(world) + , _features(NULL) { init (world, plugin, rate); } @@ -54,6 +55,7 @@ LV2Plugin::LV2Plugin (AudioEngine& e, Session& session, LV2World& world, SLV2Plu LV2Plugin::LV2Plugin (const LV2Plugin &other) : Plugin (other) , _world(other._world) + , _features(NULL) { init (other._world, other._plugin, other._sample_rate); @@ -73,8 +75,8 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, nframes_t rate) _shadow_data = 0; _latency_control_port = 0; _was_activated = false; - - _instance = slv2_plugin_instantiate(plugin, rate, NULL); + + _instance = slv2_plugin_instantiate(plugin, rate, _features); _name = slv2_plugin_get_name(plugin); assert(_name); _author = slv2_plugin_get_author_name(plugin); @@ -91,6 +93,18 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, nframes_t rate) slv2_value_free(_author); throw failed_constructor(); } + + _instance_access_feature.URI = "http://lv2plug.in/ns/ext/instance-access"; + _instance_access_feature.data = (void*)_instance->lv2_handle; + + _data_access_extension_data.extension_data = _instance->lv2_descriptor->extension_data; + _data_access_feature.URI = "http://lv2plug.in/ns/ext/data-access"; + _data_access_feature.data = &_data_access_extension_data; + + _features = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * 3); + _features[0] = &_instance_access_feature; + _features[1] = &_data_access_feature; + _features[2] = NULL; _sample_rate = rate; -- 2.30.2