summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/ClientBroadcaster.cpp2
-rw-r--r--src/libs/engine/ClientBroadcaster.h2
-rw-r--r--src/libs/engine/DSSINode.h12
-rw-r--r--src/libs/engine/GraphObject.h19
-rw-r--r--src/libs/engine/LADSPANode.cpp9
-rw-r--r--src/libs/engine/OSCClientSender.cpp10
-rw-r--r--src/libs/engine/OSCClientSender.h2
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp9
-rw-r--r--src/libs/engine/ObjectSender.cpp16
-rw-r--r--src/libs/engine/QueuedEngineInterface.cpp2
-rw-r--r--src/libs/engine/QueuedEngineInterface.h2
-rw-r--r--src/libs/engine/events/DSSIConfigureEvent.cpp2
-rw-r--r--src/libs/engine/events/RequestMetadataEvent.cpp5
-rw-r--r--src/libs/engine/events/RequestMetadataEvent.h6
-rw-r--r--src/libs/engine/events/SetMetadataEvent.cpp2
-rw-r--r--src/libs/engine/events/SetMetadataEvent.h9
16 files changed, 60 insertions, 49 deletions
diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp
index 1b4a2bd2..7a21c38b 100644
--- a/src/libs/engine/ClientBroadcaster.cpp
+++ b/src/libs/engine/ClientBroadcaster.cpp
@@ -258,7 +258,7 @@ ClientBroadcaster::send_patch_disable(const string& patch_path)
* Like control changes, does not send update to client that set the metadata, if applicable.
*/
void
-ClientBroadcaster::send_metadata_update(const string& node_path, const string& key, const string& value)
+ClientBroadcaster::send_metadata_update(const string& node_path, const string& key, const Atom& value)
{
for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
(*i).second->metadata_update(node_path, key, value);
diff --git a/src/libs/engine/ClientBroadcaster.h b/src/libs/engine/ClientBroadcaster.h
index ed4bec4e..47ad75b4 100644
--- a/src/libs/engine/ClientBroadcaster.h
+++ b/src/libs/engine/ClientBroadcaster.h
@@ -82,7 +82,7 @@ public:
void send_all_objects();
void send_patch_enable(const string& patch_path);
void send_patch_disable(const string& patch_path);
- void send_metadata_update(const string& node_path, const string& key, const string& value);
+ void send_metadata_update(const string& node_path, const string& key, const Atom& value);
void send_control_change(const string& port_path, float value);
void send_program_add(const string& node_path, int bank, int program, const string& name);
void send_program_remove(const string& node_path, int bank, int program);
diff --git a/src/libs/engine/DSSINode.h b/src/libs/engine/DSSINode.h
index 3c8dc841..1ef58d58 100644
--- a/src/libs/engine/DSSINode.h
+++ b/src/libs/engine/DSSINode.h
@@ -37,7 +37,7 @@ class DSSINode : public LADSPANode
{
public:
- typedef map<int, string> Bank;
+ typedef std::map<int, string> Bank;
DSSINode(const Plugin* plugin, const string& name, size_t poly, Patch* parent, DSSI_Descriptor* descriptor, SampleRate srate, size_t buffer_size);
~DSSINode();
@@ -57,7 +57,7 @@ public:
bool update_programs(bool send_events);
void set_default_program();
- const map<int, Bank>& get_programs() const;
+ const std::map<int, Bank>& get_programs() const;
//void send_creation_messages(ClientInterface* client) const;
@@ -90,10 +90,10 @@ private:
lo_address _ui_addr;
// Current values
- int _bank;
- int _program;
- map<string, string> _configures;
- map<int, Bank> _banks;
+ int _bank;
+ int _program;
+ std::map<string, string> _configures;
+ std::map<int, Bank> _banks;
InputPort<MidiMessage>* _midi_in_port;
snd_seq_event_t* _alsa_events;
diff --git a/src/libs/engine/GraphObject.h b/src/libs/engine/GraphObject.h
index 3b0c27b1..4f72a2e6 100644
--- a/src/libs/engine/GraphObject.h
+++ b/src/libs/engine/GraphObject.h
@@ -23,8 +23,9 @@
#include <cassert>
#include "MaidObject.h"
#include "util/Path.h"
+#include "util/Atom.h"
#include "types.h"
-using std::string; using std::map;
+using std::string;
namespace Ingen {
@@ -45,6 +46,8 @@ class ObjectStore;
class GraphObject : public MaidObject
{
public:
+ typedef std::map<string, Atom> MetadataMap;
+
GraphObject(GraphObject* parent, const string& name)
: _parent(parent), _name(name)
{
@@ -67,16 +70,16 @@ public:
assert(_name.find("/") == string::npos);
}
- void set_metadata(const string& key, const string& value)
+ void set_metadata(const string& key, const Atom& value)
{ _metadata[key] = value; }
- const string& get_metadata(const string& key) {
- static const string empty_string = "";
- map<string, string>::iterator i = _metadata.find(key);
- return (i != _metadata.end()) ? (*i).second : empty_string;
+ const Atom& get_metadata(const string& key) {
+ static Atom null_atom;
+ MetadataMap::iterator i = _metadata.find(key);
+ return (i != _metadata.end()) ? (*i).second : null_atom;
}
- const map<string, string>& metadata() const { return _metadata; }
+ const MetadataMap& metadata() const { return _metadata; }
/** Patch and Node override this to recursively add their children. */
@@ -104,7 +107,7 @@ private:
GraphObject(const GraphObject&);
GraphObject& operator=(const GraphObject& copy);
- map<string, string> _metadata;
+ MetadataMap _metadata;
};
diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp
index 76550d0b..00cfd450 100644
--- a/src/libs/engine/LADSPANode.cpp
+++ b/src/libs/engine/LADSPANode.cpp
@@ -123,11 +123,10 @@ LADSPANode::instantiate()
((TypedPort<Sample>*)port)->set_value(0.0f, 0);
}
- char tmp_buf[16];
- snprintf(tmp_buf, 16, "%f", min);
- port->set_metadata("min", tmp_buf);
- snprintf(tmp_buf, 16, "%f", max);
- port->set_metadata("max", tmp_buf);
+ if (port->is_input() && port->buffer_size() == 1) {
+ port->set_metadata("min", min);
+ port->set_metadata("max", max);
+ }
}
return true;
diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp
index 068c461a..538630c0 100644
--- a/src/libs/engine/OSCClientSender.cpp
+++ b/src/libs/engine/OSCClientSender.cpp
@@ -29,7 +29,7 @@
#include "AudioDriver.h"
#include "interface/ClientInterface.h"
#include "Responder.h"
-
+#include "util/LibloAtom.h"
using std::cout; using std::cerr; using std::endl;
namespace Ingen {
@@ -421,9 +421,13 @@ OSCClientSender::disconnection(string src_port_path, string dst_port_path)
* \arg \b value (string)</p> \n \n
*/
void
-OSCClientSender::metadata_update(string path, string key, string value)
+OSCClientSender::metadata_update(string path, string key, Atom value)
{
- lo_send(_address, "/om/metadata/update", "sss", path.c_str(), key.c_str(), value.c_str());
+ lo_message m = lo_message_new();
+ lo_message_add_string(m, path.c_str());
+ lo_message_add_string(m, key.c_str());
+ LibloAtom::lo_message_add_atom(m, value);
+ lo_send_message(_address, "/om/metadata/update", m);
}
diff --git a/src/libs/engine/OSCClientSender.h b/src/libs/engine/OSCClientSender.h
index e2404c1a..260dba63 100644
--- a/src/libs/engine/OSCClientSender.h
+++ b/src/libs/engine/OSCClientSender.h
@@ -107,7 +107,7 @@ public:
virtual void metadata_update(string subject_path,
string predicate,
- string value);
+ Atom value);
virtual void control_change(string port_path,
float value);
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index 2eb68d70..afed89fd 100644
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -22,6 +22,7 @@
#include "types.h"
#include "util/Queue.h"
#include "util/CountedPtr.h"
+#include "util/LibloAtom.h"
#include "QueuedEventSource.h"
#include "interface/ClientKey.h"
#include "interface/ClientInterface.h"
@@ -106,7 +107,7 @@ OSCEngineReceiver::OSCEngineReceiver(CountedPtr<Engine> engine, size_t queue_siz
#endif
lo_server_add_method(_server, "/om/metadata/request", "isss", metadata_get_cb, this);
- lo_server_add_method(_server, "/om/metadata/set", "isss", metadata_set_cb, this);
+ lo_server_add_method(_server, "/om/metadata/set", NULL, metadata_set_cb, this);
// Queries
lo_server_add_method(_server, "/om/request/plugins", "i", request_plugins_cb, this);
@@ -758,9 +759,13 @@ OSCEngineReceiver::m_lash_restore_done_cb(const char* path, const char* types, l
int
OSCEngineReceiver::m_metadata_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
+ if (argc != 4 || types[0] != 'i' || types[1] != 's' || types[2] != 's')
+ return 1;
+
const char* node_path = &argv[1]->s;
const char* key = &argv[2]->s;
- const char* value = &argv[3]->s;
+
+ Atom value = LibloAtom::lo_arg_to_atom(types[3], argv[3]);
set_metadata(node_path, key, value);
diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp
index 063a2d1d..1e6b93c5 100644
--- a/src/libs/engine/ObjectSender.cpp
+++ b/src/libs/engine/ObjectSender.cpp
@@ -45,8 +45,8 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch)
send_port(client, port);
/*
// Send metadata
- const map<string, string>& data = port->metadata();
- for (map<string, string>::const_iterator i = data.begin(); i != data.end(); ++i)
+ const GraphObject::MetadataMap& data = port->metadata();
+ for (GraphObject::MetadataMap::const_iterator i = data.begin(); i != data.end(); ++i)
client->metadata_update(port->path(), (*i).first, (*i).second);
// Control port, send value
@@ -64,8 +64,8 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch)
// Send metadata
- const map<string, string>& data = patch->metadata();
- for (map<string, string>::const_iterator j = data.begin(); j != data.end(); ++j)
+ const GraphObject::MetadataMap& data = patch->metadata();
+ for (GraphObject::MetadataMap::const_iterator j = data.begin(); j != data.end(); ++j)
client->metadata_update(patch->path(), (*j).first, (*j).second);
if (patch->enabled())
@@ -118,8 +118,8 @@ ObjectSender::send_node(ClientInterface* client, const Node* node)
client->bundle_end();
// Send metadata
- const map<string, string>& data = node->metadata();
- for (map<string, string>::const_iterator j = data.begin(); j != data.end(); ++j)
+ const GraphObject::MetadataMap& data = node->metadata();
+ for (GraphObject::MetadataMap::const_iterator j = data.begin(); j != data.end(); ++j)
client->metadata_update(node->path(), (*j).first, (*j).second);
}
@@ -149,8 +149,8 @@ ObjectSender::send_port(ClientInterface* client, const Port* port)
}
// Send metadata
- const map<string, string>& data = port->metadata();
- for (map<string, string>::const_iterator j = data.begin(); j != data.end(); ++j)
+ const GraphObject::MetadataMap& data = port->metadata();
+ for (GraphObject::MetadataMap::const_iterator j = data.begin(); j != data.end(); ++j)
client->metadata_update(port->path(), (*j).first, (*j).second);
}
diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp
index 35e1c99a..b0903e29 100644
--- a/src/libs/engine/QueuedEngineInterface.cpp
+++ b/src/libs/engine/QueuedEngineInterface.cpp
@@ -275,7 +275,7 @@ QueuedEngineInterface::midi_learn(const string& node_path)
void
QueuedEngineInterface::set_metadata(const string& path,
const string& predicate,
- const string& value)
+ const Atom& value)
{
push_queued(new SetMetadataEvent(*_engine.get(), _responder, now(), path, predicate, value));
}
diff --git a/src/libs/engine/QueuedEngineInterface.h b/src/libs/engine/QueuedEngineInterface.h
index 1e35738f..f9aaa0b4 100644
--- a/src/libs/engine/QueuedEngineInterface.h
+++ b/src/libs/engine/QueuedEngineInterface.h
@@ -137,7 +137,7 @@ public:
virtual void set_metadata(const string& path,
const string& predicate,
- const string& value);
+ const Atom& value);
// Requests //
diff --git a/src/libs/engine/events/DSSIConfigureEvent.cpp b/src/libs/engine/events/DSSIConfigureEvent.cpp
index fb9dc727..9a26de0c 100644
--- a/src/libs/engine/events/DSSIConfigureEvent.cpp
+++ b/src/libs/engine/events/DSSIConfigureEvent.cpp
@@ -64,7 +64,7 @@ DSSIConfigureEvent::post_process()
} else {
string key = "dssi-configure--";
key += m_key;
- _engine.broadcaster()->send_metadata_update(m_node_path, key, m_val);
+ _engine.broadcaster()->send_metadata_update(m_node_path, key, Atom(m_val.c_str()));
}
}
diff --git a/src/libs/engine/events/RequestMetadataEvent.cpp b/src/libs/engine/events/RequestMetadataEvent.cpp
index f6f1bdf9..aaea89c6 100644
--- a/src/libs/engine/events/RequestMetadataEvent.cpp
+++ b/src/libs/engine/events/RequestMetadataEvent.cpp
@@ -31,7 +31,6 @@ RequestMetadataEvent::RequestMetadataEvent(Engine& engine, CountedPtr<Responder>
: QueuedEvent(engine, responder, timestamp),
m_path(node_path),
m_key(key),
- m_value(""),
m_object(NULL),
m_client(CountedPtr<ClientInterface>())
{
@@ -61,8 +60,8 @@ void
RequestMetadataEvent::post_process()
{
if (m_client) {
- if (m_value == "") {
- string msg = "Unable to find object ";
+ if (!m_object) {
+ string msg = "Unable to find metadata subject ";
msg += m_path;
_responder->respond_error(msg);
} else {
diff --git a/src/libs/engine/events/RequestMetadataEvent.h b/src/libs/engine/events/RequestMetadataEvent.h
index 4f99e023..f4296ac2 100644
--- a/src/libs/engine/events/RequestMetadataEvent.h
+++ b/src/libs/engine/events/RequestMetadataEvent.h
@@ -19,7 +19,7 @@
#include <string>
#include "QueuedEvent.h"
-
+#include "util/Atom.h"
using std::string;
namespace Ingen {
@@ -45,8 +45,8 @@ public:
private:
string m_path;
string m_key;
- string m_value;
- GraphObject* m_object;
+ Atom m_value;
+ GraphObject* m_object;
CountedPtr<ClientInterface> m_client;
};
diff --git a/src/libs/engine/events/SetMetadataEvent.cpp b/src/libs/engine/events/SetMetadataEvent.cpp
index db8e0118..c4937df5 100644
--- a/src/libs/engine/events/SetMetadataEvent.cpp
+++ b/src/libs/engine/events/SetMetadataEvent.cpp
@@ -27,7 +27,7 @@ using std::string;
namespace Ingen {
-SetMetadataEvent::SetMetadataEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& key, const string& value)
+SetMetadataEvent::SetMetadataEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& key, const Atom& value)
: QueuedEvent(engine, responder, timestamp),
m_path(path),
m_key(key),
diff --git a/src/libs/engine/events/SetMetadataEvent.h b/src/libs/engine/events/SetMetadataEvent.h
index 855aeb62..b78f2502 100644
--- a/src/libs/engine/events/SetMetadataEvent.h
+++ b/src/libs/engine/events/SetMetadataEvent.h
@@ -19,6 +19,7 @@
#include <string>
#include "QueuedEvent.h"
+#include "util/Atom.h"
using std::string;
@@ -34,16 +35,16 @@ class GraphObject;
class SetMetadataEvent : public QueuedEvent
{
public:
- SetMetadataEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& key, const string& value);
+ SetMetadataEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& key, const Atom& value);
void pre_process();
void execute(SampleCount nframes, FrameTime start, FrameTime end);
void post_process();
private:
- string m_path;
- string m_key;
- string m_value;
+ string m_path;
+ string m_key;
+ Atom m_value;
GraphObject* m_object;
};