summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-17 04:05:30 +0000
committerDavid Robillard <d@drobilla.net>2008-08-17 04:05:30 +0000
commitfa067527fe00b66b85d71955e152e9ef9215c9cd (patch)
tree382a8e9e58259929415e7188992252ac1ca2ea9b /src/libs/engine
parent3019b09099371b3fe568b7dcc3bb92203d800b1f (diff)
downloadingen-fa067527fe00b66b85d71955e152e9ef9215c9cd.tar.gz
ingen-fa067527fe00b66b85d71955e152e9ef9215c9cd.tar.bz2
ingen-fa067527fe00b66b85d71955e152e9ef9215c9cd.zip
Replace imperative polyphony/polyphonic stuff with properties (kill more API).
git-svn-id: http://svn.drobilla.net/lad/ingen@1412 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/ClientBroadcaster.cpp16
-rw-r--r--src/libs/engine/ClientBroadcaster.hpp2
-rw-r--r--src/libs/engine/GraphObjectImpl.hpp10
-rw-r--r--src/libs/engine/OSCClientSender.cpp49
-rw-r--r--src/libs/engine/OSCClientSender.hpp9
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp20
-rw-r--r--src/libs/engine/ObjectSender.cpp8
-rw-r--r--src/libs/engine/QueuedEngineInterface.cpp21
-rw-r--r--src/libs/engine/QueuedEngineInterface.hpp13
-rw-r--r--src/libs/engine/events/RequestMetadataEvent.cpp21
-rw-r--r--src/libs/engine/events/RequestMetadataEvent.hpp8
-rw-r--r--src/libs/engine/events/SetPolyphonicEvent.cpp2
-rw-r--r--src/libs/engine/events/SetPolyphonyEvent.cpp2
13 files changed, 65 insertions, 116 deletions
diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp
index dce6691e..ff880433 100644
--- a/src/libs/engine/ClientBroadcaster.cpp
+++ b/src/libs/engine/ClientBroadcaster.cpp
@@ -162,14 +162,6 @@ ClientBroadcaster::send_destroyed(const string& path)
void
-ClientBroadcaster::send_polyphonic(const string& path, bool polyphonic)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->polyphonic(path, polyphonic);
-}
-
-
-void
ClientBroadcaster::send_patch_cleared(const string& patch_path)
{
for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
@@ -192,14 +184,6 @@ ClientBroadcaster::send_disconnection(const string& src_port_path, const string&
}
-void
-ClientBroadcaster::send_patch_polyphony(const string& patch_path, uint32_t poly)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->patch_polyphony(patch_path, poly);
-}
-
-
/** Send notification of a variable update.
*
* Like control changes, does not send update to client that set the variable, if applicable.
diff --git a/src/libs/engine/ClientBroadcaster.hpp b/src/libs/engine/ClientBroadcaster.hpp
index 07da01f5..b0963610 100644
--- a/src/libs/engine/ClientBroadcaster.hpp
+++ b/src/libs/engine/ClientBroadcaster.hpp
@@ -71,12 +71,10 @@ public:
void send_node(const NodeImpl* node, bool recursive);
void send_port(const PortImpl* port);
void send_destroyed(const string& path);
- void send_polyphonic(const string& path, bool polyphonic);
void send_patch_cleared(const string& patch_path);
void send_connection(const SharedPtr<const ConnectionImpl> connection);
void send_disconnection(const string& src_port_path, const string& dst_port_path);
void send_rename(const string& old_path, const string& new_path);
- void send_patch_polyphony(const string& patch_path, uint32_t poly);
void send_variable_change(const string& node_path, const string& key, const Raul::Atom& value);
void send_property_change(const string& node_path, const string& key, const Raul::Atom& value);
void send_port_value(const string& port_path, const Raul::Atom& value);
diff --git a/src/libs/engine/GraphObjectImpl.hpp b/src/libs/engine/GraphObjectImpl.hpp
index 1eb8acc9..628db3db 100644
--- a/src/libs/engine/GraphObjectImpl.hpp
+++ b/src/libs/engine/GraphObjectImpl.hpp
@@ -78,8 +78,15 @@ public:
Variables::iterator i = _variables.find(key);
return (i != _variables.end()) ? (*i).second : null_atom;
}
+
+ const Atom& get_property(const std::string& key) {
+ static Atom null_atom;
+ Variables::iterator i = _properties.find(key);
+ return (i != _properties.end()) ? (*i).second : null_atom;
+ }
- const Variables& variables() const { return _variables; }
+ const Variables& variables() const { return _variables; }
+ const Variables& properties() const { return _properties; }
/** The Patch this object is a child of. */
virtual PatchImpl* parent_patch() const;
@@ -111,6 +118,7 @@ protected:
private:
Variables _variables;
+ Variables _properties;
};
diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp
index 1429d616..63b7033f 100644
--- a/src/libs/engine/OSCClientSender.cpp
+++ b/src/libs/engine/OSCClientSender.cpp
@@ -211,15 +211,9 @@ OSCClientSender::plugins()
* followed by /ingen/new_node_end. </p> \n \n
*/
void OSCClientSender::new_node(const std::string& node_path,
- const std::string& plugin_uri,
- bool is_polyphonic)
+ const std::string& plugin_uri)
{
- if (is_polyphonic)
- send("/ingen/new_node", "ssT", node_path.c_str(),
- plugin_uri.c_str(), LO_ARGS_END);
- else
- send("/ingen/new_node", "ssF", node_path.c_str(),
- plugin_uri.c_str(), LO_ARGS_END);
+ send("/ingen/new_node", "ss", node_path.c_str(), plugin_uri.c_str());
}
@@ -250,30 +244,6 @@ OSCClientSender::new_port(const std::string& path,
/** \page client_osc_namespace
- * <p> \b /ingen/polyphonic - Notification an object's polyphonic property has changed.
- * \arg \b path (string) - Path of object
- * \arg \b polyphonic (bool) - Whether or not object is polyphonic (from it's parent's perspective).
- *
- * \li This is a notification that the object is <em>externally</em> polyphonic,
- * i.e. its parent sees several independent buffers for a single port, one for each voice.
- * An object can be internally polyphonic but externally not if the voices are mixed down;
- * this is true of some instruments and subpatches with mismatched polyphony. </p> \n \n
- */
-void
-OSCClientSender::polyphonic(const std::string& path,
- bool polyphonic)
-{
- if (!_enabled)
- return;
-
- if (polyphonic)
- lo_send(_address, "/ingen/polyphonic", "sT", path.c_str());
- else
- lo_send(_address, "/ingen/polyphonic", "sF", path.c_str());
-}
-
-
-/** \page client_osc_namespace
* <p> \b /ingen/destroyed - Notification an object has been destroyed
* \arg \b path (string) - Path of object (which no longer exists) </p> \n \n
*/
@@ -298,21 +268,6 @@ OSCClientSender::patch_cleared(const std::string& patch_path)
/** \page client_osc_namespace
- * <p> \b /ingen/patch_polyphony - Notification a patch's DSP processing has been polyphony.
- * \arg \b path (string) - Path of polyphony patch</p> \n \n
- */
-void
-OSCClientSender::patch_polyphony(const std::string& patch_path, uint32_t poly)
-{
- if (!_enabled)
- return;
-
- lo_send(_address, "/ingen/patch_polyphony", "si", patch_path.c_str(), poly);
-}
-
-
-
-/** \page client_osc_namespace
* <p> \b /ingen/new_connection - Notification a new connection has been made.
* \arg \b src-path (string) - Path of the source port
* \arg \b dst-path (string) - Path of the destination port</p> \n \n
diff --git a/src/libs/engine/OSCClientSender.hpp b/src/libs/engine/OSCClientSender.hpp
index 714e17b2..9a79f934 100644
--- a/src/libs/engine/OSCClientSender.hpp
+++ b/src/libs/engine/OSCClientSender.hpp
@@ -79,20 +79,13 @@ public:
virtual void new_patch(const std::string& path, uint32_t poly);
virtual void new_node(const std::string& path,
- const std::string& plugin_uri,
- bool is_polyphonic);
+ const std::string& plugin_uri);
virtual void new_port(const std::string& path,
uint32_t index,
const std::string& data_type,
bool is_output);
- virtual void polyphonic(const std::string& path,
- bool polyphonic);
-
- virtual void patch_polyphony(const std::string& path,
- uint32_t poly);
-
virtual void patch_cleared(const std::string& path);
virtual void object_destroyed(const std::string& path);
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index afac70b0..b9e2a70d 100644
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -92,10 +92,10 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t
lo_server_add_method(_server, "/ingen/set_polyphonic", "isT", set_polyphonic_cb, this);
lo_server_add_method(_server, "/ingen/set_polyphonic", "isF", set_polyphonic_cb, this);
lo_server_add_method(_server, "/ingen/new_port", "issi", new_port_cb, this);
- lo_server_add_method(_server, "/ingen/new_node", "issssT", new_node_cb, this);
- lo_server_add_method(_server, "/ingen/new_node", "issssF", new_node_cb, this);
- lo_server_add_method(_server, "/ingen/new_node", "issT", new_node_by_uri_cb, this);
- lo_server_add_method(_server, "/ingen/new_node", "issF", new_node_by_uri_cb, this);
+ lo_server_add_method(_server, "/ingen/new_node", "issss", new_node_cb, this);
+ lo_server_add_method(_server, "/ingen/new_node", "issss", new_node_cb, this);
+ lo_server_add_method(_server, "/ingen/new_node", "iss", new_node_by_uri_cb, this);
+ lo_server_add_method(_server, "/ingen/new_node", "iss", new_node_by_uri_cb, this);
lo_server_add_method(_server, "/ingen/destroy", "is", destroy_cb, this);
lo_server_add_method(_server, "/ingen/rename", "iss", rename_cb, this);
lo_server_add_method(_server, "/ingen/connect", "iss", connect_cb, this);
@@ -477,17 +477,15 @@ OSCEngineReceiver::_new_port_cb(const char* path, const char* types, lo_arg** ar
* <p> \b /ingen/new_node - Add a node into a given patch (load a plugin by URI)
* \arg \b response-id (integer)
* \arg \b node-path (string) - Full path of the new node (ie. /patch2/subpatch/newnode)
- * \arg \b plug-uri (string) - URI of the plugin to load
- * \arg \b polyphonic (boolean) - Whether node is polyphonic </p> \n \n
+ * \arg \b plug-uri (string) - URI of the plugin to load \n \n
*/
int
OSCEngineReceiver::_new_node_by_uri_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* node_path = &argv[1]->s;
const char* plug_uri = &argv[2]->s;
- bool polyphonic = (types[3] == 'T');
- new_node(node_path, plug_uri, polyphonic);
+ new_node(node_path, plug_uri);
return 0;
}
@@ -498,8 +496,7 @@ OSCEngineReceiver::_new_node_by_uri_cb(const char* path, const char* types, lo_a
* \arg \b node-path (string) - Full path of the new node (ie. /patch2/subpatch/newnode)
* \arg \b type (string) - Plugin type ("LADSPA" or "Internal")
* \arg \b lib-name (string) - Name of library where plugin resides (eg "cmt.so")
- * \arg \b plug-label (string) - Label (ID) of plugin (eg "sine_fcaa")
- * \arg \b poly (boolean) - Whether node is polyphonic
+ * \arg \b plug-label (string) - Label (ID) of plugin (eg "sine_fcaa") \n \n
*
* \li This is only here to provide backwards compatibility for old patches that store LADSPA plugin
* references as libname, label. It is to be removed ASAP, don't use it.
@@ -512,9 +509,8 @@ OSCEngineReceiver::_new_node_cb(const char* path, const char* types, lo_arg** ar
const char* type = &argv[2]->s;
const char* lib_name = &argv[3]->s;
const char* plug_label = &argv[4]->s;
- bool polyphonic = (types[5] == 'T');
- new_node_deprecated(node_path, type, lib_name, plug_label, polyphonic);
+ new_node_deprecated(node_path, type, lib_name, plug_label);
return 0;
}
diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp
index 82500446..3a716a28 100644
--- a/src/libs/engine/ObjectSender.cpp
+++ b/src/libs/engine/ObjectSender.cpp
@@ -36,7 +36,7 @@ ObjectSender::send_patch(ClientInterface* client, const PatchImpl* patch, bool r
client->bundle_begin();
client->new_patch(patch->path(), patch->internal_polyphony());
- client->polyphonic(patch->path(), patch->polyphonic());
+ client->set_property(patch->path(), "ingen:polyphonic", patch->polyphonic());
// Send variable
const GraphObjectImpl::Variables& data = patch->variables();
@@ -94,8 +94,8 @@ ObjectSender::send_node(ClientInterface* client, const NodeImpl* node, bool recu
client->bundle_begin();
- client->new_node(node->path(), node->plugin()->uri(), node->polyphonic());
- client->polyphonic(node->path(), node->polyphonic());
+ client->new_node(node->path(), node->plugin()->uri());
+ client->set_property(node->path(), "ingen:polyphonic", node->polyphonic());
// Send variable
const GraphObjectImpl::Variables& data = node->variables();
@@ -120,7 +120,7 @@ ObjectSender::send_port(ClientInterface* client, const PortImpl* port)
client->bundle_begin();
client->new_port(port->path(), port->index(), port->type().uri(), port->is_output());
- client->polyphonic(port->path(), port->polyphonic());
+ client->set_property(port->path(), "ingen:polyphonic", port->polyphonic());
// Send variable
const GraphObjectImpl::Variables& data = port->variables();
diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp
index 6deeb727..23b9c77e 100644
--- a/src/libs/engine/QueuedEngineInterface.cpp
+++ b/src/libs/engine/QueuedEngineInterface.cpp
@@ -157,11 +157,10 @@ void QueuedEngineInterface::new_port(const string& path,
void
QueuedEngineInterface::new_node(const string& path,
- const string& plugin_uri,
- bool polyphonic)
+ const string& plugin_uri)
{
push_queued(new CreateNodeEvent(_engine, _responder, now(),
- path, plugin_uri, polyphonic));
+ path, plugin_uri, true)); // FIXME: polyphonic by default
}
@@ -169,11 +168,10 @@ void
QueuedEngineInterface::new_node_deprecated(const string& path,
const string& plugin_type,
const string& plugin_lib,
- const string& plugin_label,
- bool polyphonic)
+ const string& plugin_label)
{
push_queued(new CreateNodeEvent(_engine, _responder, now(),
- path, plugin_type, plugin_lib, plugin_label, polyphonic));
+ path, plugin_type, plugin_lib, plugin_label, true)); // FIXME: polyphonic by default
}
void
@@ -359,12 +357,21 @@ QueuedEngineInterface::request_port_value(const string& port_path)
push_queued(new RequestPortValueEvent(_engine, _responder, now(), port_path));
}
+
void
QueuedEngineInterface::request_variable(const string& object_path, const string& key)
{
- push_queued(new RequestMetadataEvent(_engine, _responder, now(), object_path, key));
+ push_queued(new RequestMetadataEvent(_engine, _responder, now(), false, object_path, key));
}
+
+void
+QueuedEngineInterface::request_property(const string& object_path, const string& key)
+{
+ push_queued(new RequestMetadataEvent(_engine, _responder, now(), true, object_path, key));
+}
+
+
void
QueuedEngineInterface::request_plugins()
{
diff --git a/src/libs/engine/QueuedEngineInterface.hpp b/src/libs/engine/QueuedEngineInterface.hpp
index 585f1104..6fea3708 100644
--- a/src/libs/engine/QueuedEngineInterface.hpp
+++ b/src/libs/engine/QueuedEngineInterface.hpp
@@ -90,15 +90,13 @@ public:
bool direction);
virtual void new_node(const string& path,
- const string& plugin_uri,
- bool polyphonic);
+ const string& plugin_uri);
/** FIXME: DEPRECATED, REMOVE */
virtual void new_node_deprecated(const string& path,
const string& plugin_type,
const string& lib_path,
- const string& plug_label,
- bool polyphonic);
+ const string& plug_label);
virtual void rename(const string& old_path,
const string& new_name);
@@ -155,17 +153,12 @@ public:
// Requests //
virtual void ping();
-
virtual void request_plugin(const string& uri);
-
virtual void request_object(const string& path);
-
virtual void request_port_value(const string& port_path);
-
virtual void request_variable(const string& object_path, const string& key);
-
+ virtual void request_property(const string& object_path, const string& key);
virtual void request_plugins();
-
virtual void request_all_objects();
protected:
diff --git a/src/libs/engine/events/RequestMetadataEvent.cpp b/src/libs/engine/events/RequestMetadataEvent.cpp
index 23a3ac7b..733a6a82 100644
--- a/src/libs/engine/events/RequestMetadataEvent.cpp
+++ b/src/libs/engine/events/RequestMetadataEvent.cpp
@@ -28,11 +28,17 @@ using std::string;
namespace Ingen {
-RequestMetadataEvent::RequestMetadataEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& node_path, const string& key)
-: QueuedEvent(engine, responder, timestamp),
- _path(node_path),
- _key(key),
- _object(NULL)
+RequestMetadataEvent::RequestMetadataEvent(Engine& engine,
+ SharedPtr<Responder> responder,
+ SampleCount timestamp,
+ bool property,
+ const string& node_path,
+ const string& key)
+ : QueuedEvent(engine, responder, timestamp)
+ , _path(node_path)
+ , _property(property)
+ , _key(key)
+ , _object(NULL)
{
}
@@ -48,7 +54,10 @@ RequestMetadataEvent::pre_process()
}
}
- _value = _object->get_variable(_key);
+ if (_property)
+ _value = _object->get_property(_key);
+ else
+ _value = _object->get_variable(_key);
QueuedEvent::pre_process();
}
diff --git a/src/libs/engine/events/RequestMetadataEvent.hpp b/src/libs/engine/events/RequestMetadataEvent.hpp
index 71f55399..f6a18dfc 100644
--- a/src/libs/engine/events/RequestMetadataEvent.hpp
+++ b/src/libs/engine/events/RequestMetadataEvent.hpp
@@ -38,13 +38,19 @@ namespace Shared {
class RequestMetadataEvent : public QueuedEvent
{
public:
- RequestMetadataEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& key);
+ RequestMetadataEvent(Engine& engine,
+ SharedPtr<Responder> responder,
+ SampleCount timestamp,
+ bool property,
+ const string& path,
+ const string& key);
void pre_process();
void post_process();
private:
string _path;
+ bool _property;
string _key;
Raul::Atom _value;
GraphObjectImpl* _object;
diff --git a/src/libs/engine/events/SetPolyphonicEvent.cpp b/src/libs/engine/events/SetPolyphonicEvent.cpp
index bce65ba9..9b7fd980 100644
--- a/src/libs/engine/events/SetPolyphonicEvent.cpp
+++ b/src/libs/engine/events/SetPolyphonicEvent.cpp
@@ -68,7 +68,7 @@ SetPolyphonicEvent::post_process()
if (_object) {
if (_success) {
_responder->respond_ok();
- _engine.broadcaster()->send_polyphonic(_path, _poly);
+ _engine.broadcaster()->send_property_change(_path, "ingen:polyphonic", _poly);
} else {
_responder->respond_error("Unable to set object as polyphonic");
}
diff --git a/src/libs/engine/events/SetPolyphonyEvent.cpp b/src/libs/engine/events/SetPolyphonyEvent.cpp
index 17222330..eb6550cb 100644
--- a/src/libs/engine/events/SetPolyphonyEvent.cpp
+++ b/src/libs/engine/events/SetPolyphonyEvent.cpp
@@ -68,7 +68,7 @@ SetPolyphonyEvent::post_process()
{
if (_patch) {
_responder->respond_ok();
- _engine.broadcaster()->send_patch_polyphony(_patch_path, _poly);
+ _engine.broadcaster()->send_property_change(_patch_path, "ingen:polyphony", (int32_t)_poly);
} else {
_responder->respond_error("Unable to find patch");
}