summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-02 20:37:50 +0000
committerDavid Robillard <d@drobilla.net>2010-02-02 20:37:50 +0000
commita645d2b8be4d7d31f6eef1649156b166a01e0c31 (patch)
tree3d83c08e9a5460cc6582482bcfc673dff956a1e7 /src/engine
parent653679e967f11a0e008521885fcaf6994d2961fa (diff)
downloadingen-a645d2b8be4d7d31f6eef1649156b166a01e0c31.tar.gz
ingen-a645d2b8be4d7d31f6eef1649156b166a01e0c31.tar.bz2
ingen-a645d2b8be4d7d31f6eef1649156b166a01e0c31.zip
Use Glib string interning (quarks) to make Path/URI operator== very fast.
This avoids a ton of string comparison overhead in Ingen when setting various properties (e.g. "ingen:value" was compared several times every time a port value was changed, now this is just a single pointer comparison and the full round trip of a value change does no string comparison at all, but is still property based and RDFey). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2408 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/BufferFactory.cpp6
-rw-r--r--src/engine/ControlBindings.cpp4
-rw-r--r--src/engine/Engine.cpp18
-rw-r--r--src/engine/GraphObjectImpl.cpp9
-rw-r--r--src/engine/GraphObjectImpl.hpp25
-rw-r--r--src/engine/HTTPEngineReceiver.cpp2
-rw-r--r--src/engine/InternalPlugin.cpp9
-rw-r--r--src/engine/JackDriver.cpp5
-rw-r--r--src/engine/LADSPAPlugin.cpp13
-rw-r--r--src/engine/LV2Plugin.cpp6
-rw-r--r--src/engine/NodeBase.cpp4
-rw-r--r--src/engine/NodeBase.hpp12
-rw-r--r--src/engine/NodeImpl.hpp4
-rw-r--r--src/engine/ObjectSender.cpp8
-rw-r--r--src/engine/ObjectSender.hpp2
-rw-r--r--src/engine/PatchImpl.cpp6
-rw-r--r--src/engine/PatchImpl.hpp16
-rw-r--r--src/engine/PortImpl.cpp13
-rw-r--r--src/engine/events/CreateNode.cpp2
-rw-r--r--src/engine/events/CreatePatch.cpp9
-rw-r--r--src/engine/events/CreatePort.cpp9
-rw-r--r--src/engine/events/Delete.cpp4
-rw-r--r--src/engine/events/RequestMetadata.cpp6
-rw-r--r--src/engine/events/SendPortValue.cpp4
-rw-r--r--src/engine/events/SetMetadata.cpp28
-rw-r--r--src/engine/events/SetPortValue.cpp12
26 files changed, 126 insertions, 110 deletions
diff --git a/src/engine/BufferFactory.cpp b/src/engine/BufferFactory.cpp
index 87caa2af..39c644e2 100644
--- a/src/engine/BufferFactory.cpp
+++ b/src/engine/BufferFactory.cpp
@@ -88,15 +88,15 @@ BufferFactory::create(Shared::PortType type, size_t size)
if (size == 0)
size = sizeof(LV2_Object) + sizeof(float);
AudioBuffer* ret = new AudioBuffer(*this, type, size);
- ret->object()->type = _map->object_class_vector;
- ((LV2_Vector_Body*)ret->object()->body)->elem_type = _map->object_class_float32;
+ ret->object()->type = _map->object_class_vector.id;
+ ((LV2_Vector_Body*)ret->object()->body)->elem_type = _map->object_class_float32.id;
buffer = ret;
} else if (type.is_audio()) {
if (size == 0)
size = sizeof(LV2_Object) + sizeof(LV2_Vector_Body)
+ _engine.driver()->buffer_size() * sizeof(float);
AudioBuffer* ret = new AudioBuffer(*this, type, size);
- ret->object()->type = _map->object_class_float32;
+ ret->object()->type = _map->object_class_float32.id;
buffer = ret;
} else if (type.is_events()) {
if (size == 0)
diff --git a/src/engine/ControlBindings.cpp b/src/engine/ControlBindings.cpp
index 2874fa05..43e30338 100644
--- a/src/engine/ControlBindings.cpp
+++ b/src/engine/ControlBindings.cpp
@@ -107,7 +107,7 @@ ControlBindings::process(ProcessContext& context, EventBuffer* buffer)
if (_learn_port) {
buffer->rewind();
while (buffer->get_event(&frames, &subframes, &type, &size, &buf)) {
- if (type == _map->midi_event && (buf[0] & 0xF0) == MIDI_CMD_CONTROL) {
+ if (type == _map->midi_event.id && (buf[0] & 0xF0) == MIDI_CMD_CONTROL) {
const int8_t controller = static_cast<const int8_t>(buf[1]);
bind(context, controller);
break;
@@ -119,7 +119,7 @@ ControlBindings::process(ProcessContext& context, EventBuffer* buffer)
if (!bindings->empty()) {
buffer->rewind();
while (buffer->get_event(&frames, &subframes, &type, &size, &buf)) {
- if (type == _map->midi_event && (buf[0] & 0xF0) == MIDI_CMD_CONTROL) {
+ if (type == _map->midi_event.id && (buf[0] & 0xF0) == MIDI_CMD_CONTROL) {
const int8_t controller = static_cast<const int8_t>(buf[1]);
const int8_t value = static_cast<const int8_t>(buf[2]);
Bindings::const_iterator i = bindings->find(controller);
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp
index 437389d3..26febf3b 100644
--- a/src/engine/Engine.cpp
+++ b/src/engine/Engine.cpp
@@ -65,10 +65,8 @@ Engine::Engine(Ingen::Shared::World* world)
, _broadcaster(new ClientBroadcaster())
, _node_factory(new NodeFactory(world))
, _message_context(new MessageContext(*this))
- , _buffer_factory(new BufferFactory(*this, PtrCast<LV2URIMap>(
- world->lv2_features->feature(LV2_URI_MAP_URI))))
- , _control_bindings(new ControlBindings(*this, PtrCast<LV2URIMap>(
- world->lv2_features->feature(LV2_URI_MAP_URI))))
+ , _buffer_factory(new BufferFactory(*this, world->uris))
+ , _control_bindings(new ControlBindings(*this, world->uris))
, _quit_flag(false)
, _activated(false)
{
@@ -165,14 +163,16 @@ Engine::activate()
for (EventSources::iterator i = _event_sources.begin(); i != _event_sources.end(); ++i)
(*i)->activate_source();
+ const LV2URIMap& uris = *world()->uris;
+
// Create root patch
PatchImpl* root_patch = _driver->root_patch();
if (!root_patch) {
- root_patch = new PatchImpl(*this, "", 1, NULL,
+ root_patch = new PatchImpl(*this, "root", 1, NULL,
_driver->sample_rate(), _driver->buffer_size(), 1);
- root_patch->meta().set_property("rdf:type", Raul::Atom(Raul::Atom::URI, "ingen:Patch"));
- root_patch->meta().set_property("ingen:polyphony", Raul::Atom(int32_t(1)));
- root_patch->set_property("rdf:type", Raul::Atom(Raul::Atom::URI, "ingen:Node"));
+ root_patch->meta().set_property(uris.rdf_type, Raul::Atom(Raul::Atom::URI, "ingen:Patch"));
+ root_patch->meta().set_property(uris.ingen_polyphony, Raul::Atom(int32_t(1)));
+ root_patch->set_property(uris.rdf_type, Raul::Atom(Raul::Atom::URI, "ingen:Node"));
root_patch->activate();
_world->store->add(root_patch);
root_patch->compiled_patch(root_patch->compile());
@@ -180,7 +180,7 @@ Engine::activate()
// Add control port
Shared::Resource::Properties properties;
- properties.insert(make_pair("lv2:name", "Control"));
+ properties.insert(make_pair(uris.lv2_name, "Control"));
Events::CreatePort* ev = new Events::CreatePort(*this, SharedPtr<Responder>(), 0,
"/ingen_control", "lv2ev:EventPort", false, NULL, properties);
ev->pre_process();
diff --git a/src/engine/GraphObjectImpl.cpp b/src/engine/GraphObjectImpl.cpp
index 50b0e58b..60aefa85 100644
--- a/src/engine/GraphObjectImpl.cpp
+++ b/src/engine/GraphObjectImpl.cpp
@@ -28,15 +28,14 @@ namespace Ingen {
using namespace Shared;
-GraphObjectImpl::GraphObjectImpl(GraphObjectImpl* parent, const std::string& name, bool polyphonic)
- : ResourceImpl((parent ? parent->path().base() : Raul::Path::root_uri) + name)
+GraphObjectImpl::GraphObjectImpl(GraphObjectImpl* parent, const Symbol& symbol, bool polyphonic)
+ : ResourceImpl(parent ? parent->path().child(symbol) : Raul::Path::root.child(symbol))
, _parent(parent)
- , _name(name)
+ , _path(parent ? parent->path().child(symbol) : "/")
+ , _symbol(symbol)
, _meta(ResourceImpl::meta_uri(uri()))
, _polyphonic(polyphonic)
{
- assert(parent == NULL || _name.length() > 0);
- assert(_name.find("/") == std::string::npos);
}
diff --git a/src/engine/GraphObjectImpl.hpp b/src/engine/GraphObjectImpl.hpp
index b9e13219..82ff7f53 100644
--- a/src/engine/GraphObjectImpl.hpp
+++ b/src/engine/GraphObjectImpl.hpp
@@ -51,9 +51,9 @@ class GraphObjectImpl : virtual public Ingen::Shared::GraphObject
public:
virtual ~GraphObjectImpl() {}
- const Raul::URI meta_uri() const { return _meta.uri(); }
- const Raul::URI uri() const { return path(); }
- const Raul::Symbol symbol() const { return _name; }
+ const Raul::URI& meta_uri() const { return _meta.uri(); }
+ const Raul::URI& uri() const { return _path; }
+ const Raul::Symbol& symbol() const { return _symbol; }
bool polyphonic() const { return _polyphonic; }
virtual bool set_polyphonic(Raul::Maid& maid, bool p) { _polyphonic = p; return true; }
@@ -67,9 +67,8 @@ public:
/** Rename */
virtual void set_path(const Raul::Path& new_path) {
- assert(new_path.parent() == path().parent());
- _name = new_path.name();
- assert(_name.find("/") == std::string::npos);
+ _path = new_path;
+ _symbol = new_path.symbol();
}
const Raul::Atom& get_property(const Raul::URI& key) const;
@@ -80,22 +79,16 @@ public:
virtual PatchImpl* parent_patch() const;
/** Raul::Path is dynamically generated from parent to ease renaming */
- const Raul::Path path() const {
- if (!_parent)
- return Raul::Path(std::string("/").append(_name));
- else if (_parent->path().is_root())
- return Raul::Path(std::string("/").append(_name));
- else
- return Raul::Path(_parent->path().child(_name));
- }
+ const Raul::Path& path() const { return _path; }
SharedPtr<GraphObject> find_child(const std::string& name) const;
protected:
- GraphObjectImpl(GraphObjectImpl* parent, const std::string& name, bool polyphonic=false);
+ GraphObjectImpl(GraphObjectImpl* parent, const Raul::Symbol& symbol, bool polyphonic=false);
GraphObjectImpl* _parent;
- std::string _name;
+ Raul::Path _path;
+ Raul::Symbol _symbol;
ResourceImpl _meta;
bool _polyphonic;
};
diff --git a/src/engine/HTTPEngineReceiver.cpp b/src/engine/HTTPEngineReceiver.cpp
index a621132a..025243eb 100644
--- a/src/engine/HTTPEngineReceiver.cpp
+++ b/src/engine/HTTPEngineReceiver.cpp
@@ -117,7 +117,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const
// Special GET paths
if (msg->method == SOUP_METHOD_GET) {
- if (path == Path::root_uri || path == "") {
+ if (path == Path::root.str() || path == "") {
const string r = string("@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n")
.append("\n<> rdfs:seeAlso <plugins> ;")
.append("\n rdfs:seeAlso <stream> ;")
diff --git a/src/engine/InternalPlugin.cpp b/src/engine/InternalPlugin.cpp
index 0c848feb..946ed956 100644
--- a/src/engine/InternalPlugin.cpp
+++ b/src/engine/InternalPlugin.cpp
@@ -16,12 +16,14 @@
*/
#include <cassert>
-#include "InternalPlugin.hpp"
+#include "module/ingen_module.hpp"
+#include "shared/LV2URIMap.hpp"
#include "internals/Note.hpp"
#include "internals/Trigger.hpp"
#include "internals/Controller.hpp"
-#include "Engine.hpp"
#include "Driver.hpp"
+#include "Engine.hpp"
+#include "InternalPlugin.hpp"
using namespace std;
using namespace Raul;
@@ -34,7 +36,8 @@ InternalPlugin::InternalPlugin(const std::string& uri, const std::string& symbol
: PluginImpl(Plugin::Internal, uri)
, _symbol(symbol)
{
- set_property("rdf:type", Atom(Atom::URI, "ingen:Internal"));
+ const LV2URIMap& uris = *ingen_get_world()->uris.get();
+ set_property(uris.rdf_type, uris.ingen_Internal);
}
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index 1cd7d3ee..24291fa9 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -194,9 +194,8 @@ JackDriver::JackDriver(Engine& engine)
, _process_context(engine)
, _root_patch(NULL)
{
- SharedPtr<Shared::LV2URIMap> map = PtrCast<Shared::LV2URIMap>(
- _engine.world()->lv2_features->feature(LV2_URI_MAP_URI));
- _midi_event_type = map->uri_to_id(NULL, "http://lv2plug.in/ns/ext/midi#MidiEvent");
+ _midi_event_type = _engine.world()->uris->uri_to_id(
+ NULL, "http://lv2plug.in/ns/ext/midi#MidiEvent");
}
diff --git a/src/engine/LADSPAPlugin.cpp b/src/engine/LADSPAPlugin.cpp
index 1f316849..e1fdff40 100644
--- a/src/engine/LADSPAPlugin.cpp
+++ b/src/engine/LADSPAPlugin.cpp
@@ -18,6 +18,8 @@
#include <cassert>
#include <ladspa.h>
#include <raul/Symbol.hpp>
+#include "module/ingen_module.hpp"
+#include "shared/LV2URIMap.hpp"
#include "LADSPAPlugin.hpp"
#include "LADSPANode.hpp"
#include "Engine.hpp"
@@ -38,18 +40,19 @@ LADSPAPlugin::LADSPAPlugin(
: PluginImpl(Plugin::LADSPA, uri, library_path)
, _id(id)
, _label(label)
- , _name(Raul::Atom::STRING, name)
+ , _name(name)
{
- set_property("rdf:type", Atom(Atom::URI, "ingen:LADSPAPlugin"));
- set_property("lv2:symbol", Atom(Atom::STRING, Symbol::symbolify(label)));
- set_property("doap:name", Atom(Atom::STRING, name));
+ const LV2URIMap& uris = *ingen_get_world()->uris;
+ set_property(uris.rdf_type, uris.ingen_LADSPAPlugin);
+ set_property(uris.lv2_symbol, Symbol::symbolify(label));
+ set_property(uris.doap_name, name);
}
const Raul::Atom&
LADSPAPlugin::get_property(const Raul::URI& uri) const
{
- if (uri.str() == "doap:name")
+ if (uri == ingen_get_world()->uris->doap_name)
return _name;
else
return ResourceImpl::get_property(uri);
diff --git a/src/engine/LV2Plugin.cpp b/src/engine/LV2Plugin.cpp
index eafa3be2..5a0502d4 100644
--- a/src/engine/LV2Plugin.cpp
+++ b/src/engine/LV2Plugin.cpp
@@ -18,6 +18,8 @@
#include <cassert>
#include <glibmm.h>
#include "redlandmm/World.hpp"
+#include "module/ingen_module.hpp"
+#include "shared/LV2URIMap.hpp"
#include "LV2Plugin.hpp"
#include "LV2Node.hpp"
#include "NodeImpl.hpp"
@@ -35,9 +37,11 @@ LV2Plugin::LV2Plugin(SharedPtr<LV2Info> lv2_info, const std::string& uri)
, _slv2_plugin(NULL)
, _lv2_info(lv2_info)
{
- set_property("rdf:type", Atom(Atom::URI, "lv2:Plugin"));
+ const LV2URIMap& uris = *ingen_get_world()->uris.get();
+ set_property(uris.rdf_type, uris.lv2_Plugin);
}
+
const string
LV2Plugin::symbol() const
{
diff --git a/src/engine/NodeBase.cpp b/src/engine/NodeBase.cpp
index 0a30b33a..5874c93f 100644
--- a/src/engine/NodeBase.cpp
+++ b/src/engine/NodeBase.cpp
@@ -33,8 +33,8 @@ using namespace std;
namespace Ingen {
-NodeBase::NodeBase(PluginImpl* plugin, const string& name, bool polyphonic, PatchImpl* parent, SampleRate srate, size_t buffer_size)
- : NodeImpl(parent, name, polyphonic)
+NodeBase::NodeBase(PluginImpl* plugin, const Raul::Symbol& symbol, bool polyphonic, PatchImpl* parent, SampleRate srate, size_t buffer_size)
+ : NodeImpl(parent, symbol, polyphonic)
, _plugin(plugin)
, _polyphony((polyphonic && parent) ? parent->internal_polyphony() : 1)
, _srate(srate)
diff --git a/src/engine/NodeBase.hpp b/src/engine/NodeBase.hpp
index a85d51b5..950a79a3 100644
--- a/src/engine/NodeBase.hpp
+++ b/src/engine/NodeBase.hpp
@@ -48,12 +48,12 @@ namespace Shared { class ClientInterface; }
class NodeBase : public NodeImpl
{
public:
- NodeBase(PluginImpl* plugin,
- const std::string& name,
- bool poly,
- PatchImpl* parent,
- SampleRate rate,
- size_t buffer_size);
+ NodeBase(PluginImpl* plugin,
+ const Raul::Symbol& symbol,
+ bool poly,
+ PatchImpl* parent,
+ SampleRate rate,
+ size_t buffer_size);
virtual ~NodeBase();
diff --git a/src/engine/NodeImpl.hpp b/src/engine/NodeImpl.hpp
index 01901df9..d6923ff3 100644
--- a/src/engine/NodeImpl.hpp
+++ b/src/engine/NodeImpl.hpp
@@ -53,8 +53,8 @@ class ProcessContext;
class NodeImpl : public GraphObjectImpl, virtual public Ingen::Shared::Node
{
public:
- NodeImpl(GraphObjectImpl* parent, const std::string& name, bool poly)
- : GraphObjectImpl(parent, name, poly)
+ NodeImpl(GraphObjectImpl* parent, const Raul::Symbol& symbol, bool poly)
+ : GraphObjectImpl(parent, symbol, poly)
{}
/** Activate this Node.
diff --git a/src/engine/ObjectSender.cpp b/src/engine/ObjectSender.cpp
index 198296ec..f4cd6664 100644
--- a/src/engine/ObjectSender.cpp
+++ b/src/engine/ObjectSender.cpp
@@ -17,6 +17,8 @@
#include "ObjectSender.hpp"
#include "interface/ClientInterface.hpp"
+#include "module/ingen_module.hpp"
+#include "shared/LV2URIMap.hpp"
#include "EngineStore.hpp"
#include "PatchImpl.hpp"
#include "NodeImpl.hpp"
@@ -135,16 +137,18 @@ ObjectSender::send_port(ClientInterface* client, const PortImpl* port, bool bund
if (graph_parent)
client->put(port->meta_uri(), port->meta().properties());
+ const Shared::LV2URIMap& map = *ingen_get_world()->uris.get();
+
client->put(port->path(), port->properties());
if (graph_parent && graph_parent->internal_polyphony() > 1)
- client->set_property(port->meta_uri(), "ingen:polyphonic", bool(port->polyphonic()));
+ client->set_property(port->meta_uri(), map.ingen_polyphonic, bool(port->polyphonic()));
// Send control value
if (port->type() == PortType::CONTROL) {
//const Sample& value = PtrCast<const AudioBuffer>(port->buffer(0))->value_at(0);
const Sample& value = ((const AudioBuffer*)port->buffer(0).get())->value_at(0);
- client->set_property(port->path(), "ingen:value", value);
+ client->set_property(port->path(), map.ingen_value, value);
}
if (bundle)
diff --git a/src/engine/ObjectSender.hpp b/src/engine/ObjectSender.hpp
index 54b3bbbb..4e61d01a 100644
--- a/src/engine/ObjectSender.hpp
+++ b/src/engine/ObjectSender.hpp
@@ -18,8 +18,6 @@
#ifndef INGEN_ENGINE_OBJECTSENDER_HPP
#define INGEN_ENGINE_OBJECTSENDER_HPP
-#include <list>
-
namespace Ingen {
namespace Shared { class ClientInterface; }
diff --git a/src/engine/PatchImpl.cpp b/src/engine/PatchImpl.cpp
index 771c9d6d..a0172679 100644
--- a/src/engine/PatchImpl.cpp
+++ b/src/engine/PatchImpl.cpp
@@ -37,9 +37,9 @@ namespace Ingen {
using namespace Shared;
-PatchImpl::PatchImpl(Engine& engine, const string& path, uint32_t poly, PatchImpl* parent, SampleRate srate, size_t buffer_size, uint32_t internal_poly)
+PatchImpl::PatchImpl(Engine& engine, const Raul::Symbol& symbol, uint32_t poly, PatchImpl* parent, SampleRate srate, size_t buffer_size, uint32_t internal_poly)
: NodeBase(new PatchPlugin("http://example.org/FIXME", "patch", "Ingen Patch"),
- path, poly, parent, srate, buffer_size)
+ symbol, poly, parent, srate, buffer_size)
, _engine(engine)
, _internal_poly(internal_poly)
, _compiled_patch(NULL)
@@ -281,7 +281,7 @@ PatchImpl::add_node(List<NodeImpl*>::Node* ln)
* Preprocessing thread only.
*/
PatchImpl::Nodes::Node*
-PatchImpl::remove_node(const string& symbol)
+PatchImpl::remove_node(const Raul::Symbol& symbol)
{
ThreadManager::assert_thread(THREAD_PRE_PROCESS);
for (List<NodeImpl*>::iterator i = _nodes.begin(); i != _nodes.end(); ++i)
diff --git a/src/engine/PatchImpl.hpp b/src/engine/PatchImpl.hpp
index e86cb1bc..54839e92 100644
--- a/src/engine/PatchImpl.hpp
+++ b/src/engine/PatchImpl.hpp
@@ -48,13 +48,13 @@ class ProcessContext;
class PatchImpl : public NodeBase, public Ingen::Shared::Patch
{
public:
- PatchImpl(Engine& engine,
- const std::string& name,
- uint32_t poly,
- PatchImpl* parent,
- SampleRate srate,
- size_t buffer_size,
- uint32_t local_poly);
+ PatchImpl(Engine& engine,
+ const Raul::Symbol& symbol,
+ uint32_t poly,
+ PatchImpl* parent,
+ SampleRate srate,
+ size_t buffer_size,
+ uint32_t local_poly);
virtual ~PatchImpl();
@@ -86,7 +86,7 @@ public:
typedef Raul::List<NodeImpl*> Nodes;
void add_node(Nodes::Node* tn);
- Nodes::Node* remove_node(const std::string& name);
+ Nodes::Node* remove_node(const Raul::Symbol& symbol);
Nodes& nodes() { return _nodes; }
Connections& connections() { return _connections; }
diff --git a/src/engine/PortImpl.cpp b/src/engine/PortImpl.cpp
index 62206710..e2c25dc7 100644
--- a/src/engine/PortImpl.cpp
+++ b/src/engine/PortImpl.cpp
@@ -17,6 +17,8 @@
#include "raul/Array.hpp"
#include "raul/Maid.hpp"
+#include "module/ingen_module.hpp"
+#include "shared/LV2URIMap.hpp"
#include "contexts.lv2/contexts.h"
#include "interface/PortType.hpp"
#include "events/SendPortValue.hpp"
@@ -75,7 +77,8 @@ PortImpl::PortImpl(BufferFactory& bufs,
else
_polyphonic = true;
- add_property("rdf:type", Atom(Atom::URI, type.uri()));
+ add_property("rdf:type", Atom(Atom::URI, type.uri()));
+ set_property("lv2:index", Atom((int32_t)index));
set_context(_context);
if (type == PortType::EVENTS)
@@ -197,23 +200,23 @@ PortImpl::broadcast_value(Context& context, bool force)
if (val.type() == Atom::FLOAT && (force || val != _last_broadcasted_value)) {
_last_broadcasted_value = val;
- const Events::SendPortValue ev(context.engine(), context.start(), this, false, 0, val);
+ const Events::SendPortValue ev(context.engine(), context.start(), this, true, 0, val);
context.event_sink().write(sizeof(ev), &ev);
}
-
}
void
PortImpl::set_context(Context::ID c)
{
+ const LV2URIMap& uris = *ingen_get_world()->uris.get();
_context = c;
switch (c) {
case Context::AUDIO:
- set_property("ctx:context", Atom(Atom::URI, "ctx:AudioContext"));
+ set_property(uris.ctx_context, uris.ctx_AudioContext);
break;
case Context::MESSAGE:
- set_property("ctx:context", Atom(Atom::URI, "ctx:MessageContext"));
+ set_property(uris.ctx_context, uris.ctx_MessageContext);
break;
}
}
diff --git a/src/engine/events/CreateNode.cpp b/src/engine/events/CreateNode.cpp
index bc43620d..7dabd65d 100644
--- a/src/engine/events/CreateNode.cpp
+++ b/src/engine/events/CreateNode.cpp
@@ -90,7 +90,7 @@ CreateNode::pre_process()
if (_patch && _plugin) {
- _node = _plugin->instantiate(*_engine.buffer_factory(), _path.name(), _polyphonic, _patch, _engine);
+ _node = _plugin->instantiate(*_engine.buffer_factory(), _path.symbol(), _polyphonic, _patch, _engine);
if (_node != NULL) {
_node->properties().insert(_properties.begin(), _properties.end());
diff --git a/src/engine/events/CreatePatch.cpp b/src/engine/events/CreatePatch.cpp
index b76efcdc..5d72f13a 100644
--- a/src/engine/events/CreatePatch.cpp
+++ b/src/engine/events/CreatePatch.cpp
@@ -17,6 +17,7 @@
#include "raul/Maid.hpp"
#include "raul/Path.hpp"
+#include "shared/LV2URIMap.hpp"
#include "events/CreatePatch.hpp"
#include "Responder.hpp"
#include "PatchImpl.hpp"
@@ -83,11 +84,13 @@ CreatePatch::pre_process()
if (_parent != NULL && _poly > 1 && _poly == static_cast<int>(_parent->internal_polyphony()))
poly = _poly;
- _patch = new PatchImpl(_engine, path.name(), poly, _parent,
+ const LV2URIMap& uris = *_engine.world()->uris.get();
+
+ _patch = new PatchImpl(_engine, path.symbol(), poly, _parent,
_engine.driver()->sample_rate(), _engine.driver()->buffer_size(), _poly);
_patch->meta().properties().insert(_properties.begin(), _properties.end());
- _patch->meta().set_property("rdf:type", Atom(Atom::URI, "ingen:Patch"));
- _patch->set_property("rdf:type", Atom(Atom::URI, "ingen:Node"));
+ _patch->meta().set_property(uris.rdf_type, uris.ingen_Patch);
+ _patch->set_property(uris.rdf_type, uris.ingen_Node);
if (_parent != NULL) {
_parent->add_node(new PatchImpl::Nodes::Node(_patch));
diff --git a/src/engine/events/CreatePort.cpp b/src/engine/events/CreatePort.cpp
index 73ba4b83..44ffe90d 100644
--- a/src/engine/events/CreatePort.cpp
+++ b/src/engine/events/CreatePort.cpp
@@ -88,16 +88,13 @@ CreatePort::pre_process()
if (_patch != NULL) {
assert(_patch->path() == _path.parent());
- size_t buffer_size = 1;
- if (_type.str() != "ingen:Float")
- buffer_size = _engine.driver()->buffer_size();
+ size_t buffer_size = _engine.driver()->buffer_size();
const uint32_t old_num_ports = _patch->num_ports();
- _patch_port = _patch->create_port(*_engine.buffer_factory(), _path.name(), _data_type, buffer_size, _is_output);
+ _patch_port = _patch->create_port(*_engine.buffer_factory(), _path.symbol(), _data_type, buffer_size, _is_output);
if (_patch->parent())
- _patch_port->set_property("rdf:instanceOf",
- Atom(Atom::URI, _patch_port->meta_uri().str()));
+ _patch_port->set_property("rdf:instanceOf", _patch_port->meta_uri());
_patch_port->meta().properties().insert(_properties.begin(), _properties.end());
diff --git a/src/engine/events/Delete.cpp b/src/engine/events/Delete.cpp
index 11d355a4..30166c51 100644
--- a/src/engine/events/Delete.cpp
+++ b/src/engine/events/Delete.cpp
@@ -80,7 +80,7 @@ Delete::pre_process()
if (_node && !_path.is_root()) {
assert(_node->parent_patch());
- _patch_node_listnode = _node->parent_patch()->remove_node(_path.name());
+ _patch_node_listnode = _node->parent_patch()->remove_node(_path.symbol());
if (_patch_node_listnode) {
assert(_patch_node_listnode->elem() == _node.get());
@@ -101,7 +101,7 @@ Delete::pre_process()
}
} else if (_port) {
assert(_port->parent_patch());
- _patch_port_listnode = _port->parent_patch()->remove_port(_path.name());
+ _patch_port_listnode = _port->parent_patch()->remove_port(_path.symbol());
if (_patch_port_listnode) {
assert(_patch_port_listnode->elem() == _port.get());
diff --git a/src/engine/events/RequestMetadata.cpp b/src/engine/events/RequestMetadata.cpp
index c773ae3d..1cc092e2 100644
--- a/src/engine/events/RequestMetadata.cpp
+++ b/src/engine/events/RequestMetadata.cpp
@@ -18,6 +18,7 @@
#include "interface/ClientInterface.hpp"
#include "events/RequestMetadata.hpp"
#include "shared/LV2Object.hpp"
+#include "shared/LV2URIMap.hpp"
#include "AudioBuffer.hpp"
#include "ClientBroadcaster.hpp"
#include "Engine.hpp"
@@ -73,7 +74,7 @@ RequestMetadata::pre_process()
GraphObjectImpl* obj = dynamic_cast<GraphObjectImpl*>(_resource);
if (obj) {
- if (_key.str() == "ingen:value")
+ if (_key == _engine.world()->uris->ingen_value)
_special_type = PORT_VALUE;
else if (_is_meta)
_value = obj->meta().get_property(_key);
@@ -113,7 +114,8 @@ RequestMetadata::post_process()
if (_special_type == PORT_VALUE) {
if (_resource) {
_responder->respond_ok();
- _responder->client()->set_property(_uri.str(), "ingen:value", _value);
+ _responder->client()->set_property(_uri.str(),
+ _engine.world()->uris->ingen_value, _value);
} else {
const string msg = "Get value for non-port " + _uri.str();
_responder->respond_error(msg);
diff --git a/src/engine/events/SendPortValue.cpp b/src/engine/events/SendPortValue.cpp
index 52592d81..1d7d400d 100644
--- a/src/engine/events/SendPortValue.cpp
+++ b/src/engine/events/SendPortValue.cpp
@@ -17,6 +17,7 @@
#include <sstream>
#include "events/SendPortValue.hpp"
+#include "shared/LV2URIMap.hpp"
#include "Engine.hpp"
#include "PortImpl.hpp"
#include "ClientBroadcaster.hpp"
@@ -31,7 +32,8 @@ void
SendPortValue::post_process()
{
if (_omni) {
- _engine.broadcaster()->set_property(_port->path(), "ingen:value", _value);
+ _engine.broadcaster()->set_property(_port->path(),
+ _engine.world()->uris->ingen_value, _value);
} else {
_engine.broadcaster()->set_voice_value(_port->path(), _voice_num, _value);
}
diff --git a/src/engine/events/SetMetadata.cpp b/src/engine/events/SetMetadata.cpp
index ae69aecf..85768b3d 100644
--- a/src/engine/events/SetMetadata.cpp
+++ b/src/engine/events/SetMetadata.cpp
@@ -19,6 +19,7 @@
#include <boost/format.hpp>
#include "raul/log.hpp"
#include "interface/PortType.hpp"
+#include "shared/LV2URIMap.hpp"
#include "ClientBroadcaster.hpp"
#include "CreateNode.hpp"
#include "CreatePatch.hpp"
@@ -92,6 +93,8 @@ SetMetadata::pre_process()
return;
}
+ const LV2URIMap& uris = *_engine.world()->uris.get();
+
if (is_graph_object && !_object) {
Path path(_subject.str());
bool is_patch = false, is_node = false, is_port = false, is_output = false;
@@ -99,13 +102,13 @@ SetMetadata::pre_process()
ResourceImpl::type(_properties, is_patch, is_node, is_port, is_output, data_type);
if (is_patch) {
uint32_t poly = 1;
- iterator p = _properties.find("ingen:polyphony");
+ iterator p = _properties.find(uris.ingen_polyphony);
if (p != _properties.end() && p->second.is_valid() && p->second.type() == Atom::INT)
poly = p->second.get_int32();
_create_event = new CreatePatch(_engine, _responder, _time,
path, poly, _properties);
} else if (is_node) {
- const iterator p = _properties.find("rdf:instanceOf");
+ const iterator p = _properties.find(uris.rdf_instanceOf);
_create_event = new CreateNode(_engine, _responder, _time,
path, p->second.get_uri(), true, _properties);
} else if (is_port) {
@@ -143,10 +146,13 @@ SetMetadata::pre_process()
_patch = dynamic_cast<PatchImpl*>(_object);
- if (key.str() == "ingen:broadcast") {
- op = ENABLE_BROADCAST;
+ if (key == uris.ingen_broadcast) {
+ if (value.type() == Atom::BOOL)
+ op = ENABLE_BROADCAST;
+ else
+ _error = BAD_VALUE_TYPE;
} else if (_patch) {
- if (key.str() == "ingen:enabled") {
+ if (key == uris.ingen_enabled) {
if (value.type() == Atom::BOOL) {
op = ENABLE;
if (value.get_bool() && !_patch->compiled_patch())
@@ -154,13 +160,13 @@ SetMetadata::pre_process()
} else {
_error = BAD_VALUE_TYPE;
}
- } else if (key.str() == "ingen:polyphonic") {
+ } else if (key == uris.ingen_polyphonic) {
if (value.type() == Atom::BOOL) {
op = POLYPHONIC;
} else {
_error = BAD_VALUE_TYPE;
}
- } else if (key.str() == "ingen:polyphony") {
+ } else if (key == uris.ingen_polyphony) {
if (value.type() == Atom::INT) {
op = POLYPHONY;
_patch->prepare_internal_poly(*_engine.buffer_factory(), value.get_int32());
@@ -168,7 +174,7 @@ SetMetadata::pre_process()
_error = BAD_VALUE_TYPE;
}
}
- } else if (key.str() == "ingen:value") {
+ } else if (key == uris.ingen_value) {
PortImpl* port = dynamic_cast<PortImpl*>(_object);
if (port) {
SetPortValue* ev = new SetPortValue(_engine, _responder, _time, port, value);
@@ -263,17 +269,17 @@ SetMetadata::post_process()
break;
case NOT_FOUND:
_responder->respond_error((boost::format(
- "Unable to find object '%1%'") % _subject).str());
+ "Unable to find object `%1%'") % _subject).str());
case INTERNAL:
_responder->respond_error("Internal error");
break;
case BAD_OBJECT_TYPE:
_responder->respond_error((boost::format(
- "Bad type for object '%1%'") % _subject).str());
+ "Bad type for object `%1%'") % _subject).str());
break;
case BAD_VALUE_TYPE:
_responder->respond_error((boost::format(
- "Bad metadata value type for subject '%1%' predicate '%2%")
+ "Bad metadata value type for subject `%1%' predicate `%2%'")
% _subject % _error_predicate).str());
break;
}
diff --git a/src/engine/events/SetPortValue.cpp b/src/engine/events/SetPortValue.cpp
index f1abc720..0ec5d98b 100644
--- a/src/engine/events/SetPortValue.cpp
+++ b/src/engine/events/SetPortValue.cpp
@@ -126,7 +126,7 @@ SetPortValue::pre_process()
if (_port) {
_port->set_value(_value);
- _port->set_property("ingen:value", _value);
+ _port->set_property(_engine.world()->uris->ingen_value, _value);
}
QueuedEvent::pre_process();
@@ -181,8 +181,7 @@ SetPortValue::apply(Context& context)
return;
}
- SharedPtr<LV2URIMap> map = PtrCast<LV2URIMap>(
- _engine.world()->lv2_features->feature(LV2_URI_MAP_URI));
+ SharedPtr<LV2URIMap> uris = _engine.world()->uris;
EventBuffer* const ebuf = dynamic_cast<EventBuffer*>(buf);
if (ebuf) {
@@ -190,14 +189,14 @@ SetPortValue::apply(Context& context)
// Size 0 event, pass it along to the plugin as a typed but empty event
if (_value.data_size() == 0) {
- const uint32_t type_id = map->uri_to_id(NULL, _value.get_blob_type());
+ const uint32_t type_id = uris->uri_to_id(NULL, _value.get_blob_type());
ebuf->append(frames, 0, type_id, 0, NULL);
_port->raise_set_by_user_flag();
return;
} else if (!strcmp(_value.get_blob_type(), "lv2midi:MidiEvent")) {
ebuf->prepare_write(context);
- ebuf->append(frames, 0, map->midi_event, _value.data_size(),
+ ebuf->append(frames, 0, uris->midi_event.id, _value.data_size(),
(const uint8_t*)_value.get_blob());
_port->raise_set_by_user_flag();
return;
@@ -231,7 +230,8 @@ SetPortValue::post_process()
assert(_port != NULL);
_responder->respond_ok();
if (_omni)
- _engine.broadcaster()->set_property(_port_path, "ingen:value", _value);
+ _engine.broadcaster()->set_property(_port_path,
+ _engine.world()->uris->ingen_value, _value);
else
_engine.broadcaster()->set_voice_value(_port_path, _voice_num, _value);
break;