From df8ee18c0139f889bf7c697713a2205364845464 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 25 Jan 2008 06:55:57 +0000 Subject: Overhaul SLV2 API to return/take SLV2Value (instead of strings or primitives) wherever possible. Make 'index' a fundemental property of ingen ports. git-svn-id: http://svn.drobilla.net/lad/ingen@1113 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/NodeModel.cpp | 20 ++++++++++---------- src/libs/client/OSCClientReceiver.cpp | 13 +++++++------ src/libs/client/PluginModel.cpp | 9 ++++++--- src/libs/client/PluginModel.hpp | 10 ++++++++-- src/libs/client/PluginUI.cpp | 5 ++++- src/libs/client/PluginUI.hpp | 1 + src/libs/client/PortModel.hpp | 17 ++++++++++------- src/libs/client/SigClientInterface.hpp | 6 +++--- src/libs/client/Store.cpp | 4 ++-- src/libs/client/Store.hpp | 2 +- src/libs/client/ThreadedSigClientInterface.hpp | 6 +++--- 11 files changed, 55 insertions(+), 38 deletions(-) (limited to 'src/libs/client') diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp index b429d356..2f8af584 100644 --- a/src/libs/client/NodeModel.cpp +++ b/src/libs/client/NodeModel.cpp @@ -156,16 +156,16 @@ NodeModel::port_value_range(SharedPtr port, float& min, float& max) // Plugin value first if (_plugin && _plugin->type() == PluginModel::LV2) { Glib::Mutex::Lock(PluginModel::rdf_world()->mutex()); - - min = slv2_port_get_minimum_value( - _plugin->slv2_plugin(), - slv2_plugin_get_port_by_symbol(_plugin->slv2_plugin(), - port->path().name().c_str())); - - max = slv2_port_get_maximum_value( - _plugin->slv2_plugin(), - slv2_plugin_get_port_by_symbol(_plugin->slv2_plugin(), - port->path().name().c_str())); + + SLV2Value min_val, max_val; + slv2_port_get_range(_plugin->slv2_plugin(), + _plugin->slv2_port(port->index()), + NULL, &min_val, &max_val); + + if (min_val) + min = slv2_value_as_float(min_val); + if (max_val) + max = slv2_value_as_float(max_val); } #endif diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp index 6573c9bf..6002ca59 100644 --- a/src/libs/client/OSCClientReceiver.cpp +++ b/src/libs/client/OSCClientReceiver.cpp @@ -155,7 +155,7 @@ OSCClientReceiver::setup_callbacks() lo_server_thread_add_method(_st, "/ingen/disconnection", "ss", disconnection_cb, this); lo_server_thread_add_method(_st, "/ingen/new_node", "ssTi", new_node_cb, this); lo_server_thread_add_method(_st, "/ingen/new_node", "ssFi", new_node_cb, this); - lo_server_thread_add_method(_st, "/ingen/new_port", "ssi", new_port_cb, this); + lo_server_thread_add_method(_st, "/ingen/new_port", "sisi", new_port_cb, this); lo_server_thread_add_method(_st, "/ingen/polyphonic", "sT", polyphonic_cb, this); lo_server_thread_add_method(_st, "/ingen/polyphonic", "sF", polyphonic_cb, this); lo_server_thread_add_method(_st, "/ingen/variable_change", NULL, variable_change_cb, this); @@ -263,7 +263,7 @@ OSCClientReceiver::_new_node_cb(const char* path, const char* types, lo_arg** ar { const char* uri = &argv[0]->s; const char* node_path = &argv[1]->s; - bool polyphonic = (types[2] == 'T'); + const bool polyphonic = (types[2] == 'T'); const int32_t num_ports = argv[3]->i; new_node(uri, node_path, polyphonic, num_ports); @@ -277,11 +277,12 @@ OSCClientReceiver::_new_node_cb(const char* path, const char* types, lo_arg** ar int OSCClientReceiver::_new_port_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { - const char* port_path = &argv[0]->s; - const char* type = &argv[1]->s; - bool is_output = (argv[2]->i == 1); + const char* port_path = &argv[0]->s; + const uint32_t index = argv[1]->i; + const char* type = &argv[2]->s; + const bool is_output = (argv[3]->i == 1); - new_port(port_path, type, is_output); + new_port(port_path, index, type, is_output); return 0; } diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp index 83762566..df8d4bf7 100644 --- a/src/libs/client/PluginModel.cpp +++ b/src/libs/client/PluginModel.cpp @@ -102,7 +102,7 @@ PluginModel::ui(SharedPtr engine, SharedPtr node) co Glib::Mutex::Lock(_rdf_world->mutex()); - return PluginUI::create(engine, node, _slv2_plugin); + return PluginUI::create(engine, node, _slv2_world, _slv2_plugin); } @@ -120,8 +120,10 @@ string PluginModel::get_lv2_icon_path(SLV2Plugin plugin) { string result; - SLV2Values paths = slv2_plugin_get_value(plugin, SLV2_URI, - "http://ll-plugins.nongnu.org/lv2/namespace#svgIcon"); + SLV2Value svg_icon_pred = slv2_value_new_uri(_slv2_world, + "http://ll-plugins.nongnu.org/lv2/namespace#svgIcon"); + + SLV2Values paths = slv2_plugin_get_value(plugin, svg_icon_pred); if (slv2_values_size(paths) > 0) { SLV2Value value = slv2_values_get_at(paths, 0); @@ -130,6 +132,7 @@ PluginModel::get_lv2_icon_path(SLV2Plugin plugin) slv2_values_free(paths); } + slv2_value_free(svg_icon_pred); return result; } diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp index de90bba2..f5ac71f4 100644 --- a/src/libs/client/PluginModel.hpp +++ b/src/libs/client/PluginModel.hpp @@ -54,7 +54,9 @@ public: , _name(name) { #ifdef HAVE_SLV2 - _slv2_plugin = slv2_plugins_get_by_uri(_slv2_plugins, uri.c_str()); + SLV2Value plugin_uri = slv2_value_new_uri(_slv2_world, uri.c_str()); + _slv2_plugin = slv2_plugins_get_by_uri(_slv2_plugins, plugin_uri); + slv2_value_free(plugin_uri); #endif } @@ -82,8 +84,12 @@ public: string default_node_name(SharedPtr parent); #ifdef HAVE_SLV2 - SLV2Plugin slv2_plugin() { return _slv2_plugin; } static SLV2World slv2_world() { return _slv2_world; } + SLV2Plugin slv2_plugin() { return _slv2_plugin; } + + SLV2Port slv2_port(uint32_t index) { + return slv2_plugin_get_port_by_index(_slv2_plugin, index); + } static void set_slv2_world(SLV2World world) { _slv2_world = world; diff --git a/src/libs/client/PluginUI.cpp b/src/libs/client/PluginUI.cpp index d1b911f8..5ce48bd1 100644 --- a/src/libs/client/PluginUI.cpp +++ b/src/libs/client/PluginUI.cpp @@ -74,11 +74,13 @@ PluginUI::~PluginUI() SharedPtr PluginUI::create(SharedPtr engine, SharedPtr node, + SLV2World world, SLV2Plugin plugin) { SharedPtr ret; - static const char* gtk_gui_uri = "http://ll-plugins.nongnu.org/lv2/ext/ui#GtkUI"; + SLV2Value gtk_gui_uri = slv2_value_new_uri(world, + "http://ll-plugins.nongnu.org/lv2/ext/ui#GtkUI"); SLV2UIs uis = slv2_plugin_get_uis(plugin); SLV2UI ui = NULL; @@ -107,6 +109,7 @@ PluginUI::create(SharedPtr engine, } } + slv2_value_free(gtk_gui_uri); return ret; } diff --git a/src/libs/client/PluginUI.hpp b/src/libs/client/PluginUI.hpp index 62bbf9af..fc14d5c9 100644 --- a/src/libs/client/PluginUI.hpp +++ b/src/libs/client/PluginUI.hpp @@ -39,6 +39,7 @@ public: static SharedPtr create(SharedPtr engine, SharedPtr node, + SLV2World world, SLV2Plugin plugin); SharedPtr engine() { return _engine; } diff --git a/src/libs/client/PortModel.hpp b/src/libs/client/PortModel.hpp index 5455c1f9..940b967e 100644 --- a/src/libs/client/PortModel.hpp +++ b/src/libs/client/PortModel.hpp @@ -43,11 +43,12 @@ class PortModel : public ObjectModel, public Ingen::Shared::Port public: enum Direction { INPUT, OUTPUT }; - inline DataType type() const { return _type; } - inline Atom value() const { return Atom(_current_val); } - inline bool connected() const { return (_connections > 0); } - inline bool is_input() const { return (_direction == INPUT); } - inline bool is_output() const { return (_direction == OUTPUT); } + inline uint32_t index() const { return _index; } + inline DataType type() const { return _type; } + inline const Atom& value() const { return _current_val; } + inline bool connected() const { return (_connections > 0); } + inline bool is_input() const { return (_direction == INPUT); } + inline bool is_output() const { return (_direction == OUTPUT); } bool is_logarithmic() const; bool is_integer() const; @@ -74,8 +75,9 @@ public: private: friend class Store; - PortModel(Store& store, const Path& path, DataType type, Direction dir) + PortModel(Store& store, const Path& path, uint32_t index, DataType type, Direction dir) : ObjectModel(store, path, true), + _index(index), _type(type), _direction(dir), _current_val(0.0f), @@ -91,9 +93,10 @@ private: void connected_to(SharedPtr p) { ++_connections; signal_connection.emit(p); } void disconnected_from(SharedPtr p) { --_connections; signal_disconnection.emit(p); } + uint32_t _index; DataType _type; Direction _direction; - float _current_val; + Atom _current_val; size_t _connections; }; diff --git a/src/libs/client/SigClientInterface.hpp b/src/libs/client/SigClientInterface.hpp index 4e57a7ec..14d96b21 100644 --- a/src/libs/client/SigClientInterface.hpp +++ b/src/libs/client/SigClientInterface.hpp @@ -53,7 +53,7 @@ public: sigc::signal signal_new_plugin; sigc::signal signal_new_patch; sigc::signal signal_new_node; - sigc::signal signal_new_port; + sigc::signal signal_new_port; sigc::signal signal_polyphonic; sigc::signal signal_patch_enabled; sigc::signal signal_patch_disabled; @@ -107,8 +107,8 @@ protected: void new_node(const string& plugin_uri, const string& node_path, bool poly, uint32_t num_ports) { if (_enabled) signal_new_node.emit(plugin_uri, node_path, poly, num_ports); } - void new_port(const string& path, const string& data_type, bool is_output) - { if (_enabled) signal_new_port.emit(path, data_type, is_output); } + void new_port(const string& path, uint32_t index, const string& data_type, bool is_output) + { if (_enabled) signal_new_port.emit(path, index, data_type, is_output); } void polyphonic(const string& path, bool polyphonic) { if (_enabled) signal_polyphonic.emit(path, polyphonic); } diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index 3068295a..10db5231 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -432,11 +432,11 @@ Store::new_node_event(const string& plugin_uri, const Path& node_path, bool is_p void -Store::new_port_event(const Path& path, const string& type, bool is_output) +Store::new_port_event(const Path& path, uint32_t index, const string& type, bool is_output) { PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT; - SharedPtr p(new PortModel(*this, path, type, pdir)); + SharedPtr p(new PortModel(*this, path, index, type, pdir)); add_object(p); if (p->parent()) resolve_connection_orphans(p); diff --git a/src/libs/client/Store.hpp b/src/libs/client/Store.hpp index 5dd4f34e..443a411f 100644 --- a/src/libs/client/Store.hpp +++ b/src/libs/client/Store.hpp @@ -100,7 +100,7 @@ private: void new_plugin_event(const string& uri, const string& type_uri, const string& symbol, const string& name); void new_patch_event(const Path& path, uint32_t poly); void new_node_event(const string& plugin_uri, const Path& node_path, bool is_polyphonic, uint32_t num_ports); - void new_port_event(const Path& path, const string& data_type, bool is_output); + void new_port_event(const Path& path, uint32_t index, const string& data_type, bool is_output); void polyphonic_event(const Path& path, bool polyphonic); void patch_enabled_event(const Path& path); void patch_disabled_event(const Path& path); diff --git a/src/libs/client/ThreadedSigClientInterface.hpp b/src/libs/client/ThreadedSigClientInterface.hpp index e5ec2741..7cac212f 100644 --- a/src/libs/client/ThreadedSigClientInterface.hpp +++ b/src/libs/client/ThreadedSigClientInterface.hpp @@ -99,8 +99,8 @@ public: void new_node(const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports) { push_sig(sigc::bind(new_node_slot, plugin_uri, node_path, is_polyphonic, num_ports)); } - void new_port(const string& path, const string& data_type, bool is_output) - { push_sig(sigc::bind(new_port_slot, path, data_type, is_output)); } + void new_port(const string& path, uint32_t index, const string& data_type, bool is_output) + { push_sig(sigc::bind(new_port_slot, path, index, data_type, is_output)); } void polyphonic(const string& path, bool polyphonic) { push_sig(sigc::bind(polyphonic_slot, path, polyphonic)); } @@ -162,7 +162,7 @@ private: sigc::slot new_plugin_slot; sigc::slot new_patch_slot; sigc::slot new_node_slot; - sigc::slot new_port_slot; + sigc::slot new_port_slot; sigc::slot polyphonic_slot; sigc::slot connection_slot; sigc::slot patch_enabled_slot; -- cgit v1.2.1