summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-27 19:20:53 +0000
committerDavid Robillard <d@drobilla.net>2012-04-27 19:20:53 +0000
commitfd1e2ef17c7799e8c5d5965932c3bec1570262bd (patch)
tree7fbe21dd87d688ae2d1a124e479e36698cf63bad
parent6dfca027bb8981322b6d2671d687b1e970a4f6f1 (diff)
downloadingen-fd1e2ef17c7799e8c5d5965932c3bec1570262bd.tar.gz
ingen-fd1e2ef17c7799e8c5d5965932c3bec1570262bd.tar.bz2
ingen-fd1e2ef17c7799e8c5d5965932c3bec1570262bd.zip
Implement connecting via atom interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4285 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--ingen/shared/AtomReader.hpp2
-rw-r--r--ingen/shared/URIs.hpp6
-rw-r--r--src/shared/AtomReader.cpp51
-rw-r--r--src/shared/AtomWriter.cpp8
-rw-r--r--src/shared/URIs.cpp6
-rw-r--r--wscript2
6 files changed, 51 insertions, 24 deletions
diff --git a/ingen/shared/AtomReader.hpp b/ingen/shared/AtomReader.hpp
index 7cbacd29..f57dffa7 100644
--- a/ingen/shared/AtomReader.hpp
+++ b/ingen/shared/AtomReader.hpp
@@ -41,6 +41,8 @@ public:
void write(const LV2_Atom* msg);
private:
+ void get_uri(const LV2_Atom* in, Raul::Atom& out);
+
void get_props(const LV2_Atom_Object* obj,
Ingen::Resource::Properties& props);
diff --git a/ingen/shared/URIs.hpp b/ingen/shared/URIs.hpp
index 0014961f..c4086bb5 100644
--- a/ingen/shared/URIs.hpp
+++ b/ingen/shared/URIs.hpp
@@ -60,7 +60,7 @@ public:
const Quark atom_eventTransfer;
const Quark atom_supports;
const Quark doap_name;
- const Quark ingen_Connection;
+ const Quark ingen_Edge;
const Quark ingen_Internal;
const Quark ingen_Node;
const Quark ingen_Patch;
@@ -70,17 +70,17 @@ public:
const Quark ingen_canvasX;
const Quark ingen_canvasY;
const Quark ingen_controlBinding;
- const Quark ingen_destination;
const Quark ingen_document;
const Quark ingen_enabled;
const Quark ingen_engine;
+ const Quark ingen_head;
const Quark ingen_nil;
const Quark ingen_node;
const Quark ingen_polyphonic;
const Quark ingen_polyphony;
const Quark ingen_sampleRate;
const Quark ingen_selected;
- const Quark ingen_source;
+ const Quark ingen_tail;
const Quark ingen_uiEmbedded;
const Quark ingen_value;
const Quark lv2_AudioPort;
diff --git a/src/shared/AtomReader.cpp b/src/shared/AtomReader.cpp
index a7ea5e68..fa14243a 100644
--- a/src/shared/AtomReader.cpp
+++ b/src/shared/AtomReader.cpp
@@ -18,6 +18,7 @@
#include "ingen/shared/AtomReader.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
+#include "raul/Path.hpp"
#include "raul/log.hpp"
namespace Ingen {
@@ -32,20 +33,23 @@ AtomReader::AtomReader(LV2URIMap& map, URIs& uris, Forge& forge, Interface& ifac
}
void
+AtomReader::get_uri(const LV2_Atom* in, Raul::Atom& out)
+{
+ if (in->type == _uris.atom_URID) {
+ const LV2_Atom_URID* urid = (const LV2_Atom_URID*)in;
+ out = _forge.alloc_uri(_map.unmap_uri(urid->body));
+ } else {
+ out = _forge.alloc(in->size, in->type, LV2_ATOM_BODY(in));
+ }
+}
+
+void
AtomReader::get_props(const LV2_Atom_Object* obj,
Ingen::Resource::Properties& props)
{
LV2_ATOM_OBJECT_FOREACH(obj, p) {
Raul::Atom val;
- if (p->value.type == _uris.atom_URID) {
- const LV2_Atom_URID* urid = (const LV2_Atom_URID*)&p->value;
- val = _forge.alloc_uri(_map.unmap_uri(urid->body));
- } else {
- val = _forge.alloc(p->value.size,
- p->value.type,
- LV2_ATOM_BODY(&p->value));
- }
-
+ get_uri(&p->value, val);
props.insert(std::make_pair(_map.unmap_uri(p->key), val));
}
}
@@ -83,11 +87,30 @@ AtomReader::write(const LV2_Atom* msg)
return;
}
- Ingen::Resource::Properties props;
- get_props(body, props);
-
- _iface.set_response_id(obj->body.id);
- _iface.put(subject_uri, props);
+ if (body->body.otype == _uris.ingen_Edge) {
+ LV2_Atom* tail = NULL;
+ LV2_Atom* head = NULL;
+ lv2_atom_object_get(body,
+ (LV2_URID)_uris.ingen_tail, &tail,
+ (LV2_URID)_uris.ingen_head, &head,
+ NULL);
+ if (!tail || !head) {
+ Raul::warn << "Edge has no tail or head" << std::endl;
+ return;
+ }
+
+ Raul::Atom tail_atom;
+ Raul::Atom head_atom;
+ get_uri(tail, tail_atom);
+ get_uri(head, head_atom);
+ _iface.connect(Raul::Path(tail_atom.get_uri()),
+ Raul::Path(head_atom.get_uri()));
+ } else {
+ Ingen::Resource::Properties props;
+ get_props(body, props);
+ _iface.set_response_id(obj->body.id);
+ _iface.put(subject_uri, props);
+ }
} else if (obj->body.otype == _uris.patch_Patch) {
if (!subject_uri) {
Raul::warn << "Put message has no subject" << std::endl;
diff --git a/src/shared/AtomWriter.cpp b/src/shared/AtomWriter.cpp
index 913c85ce..4e3853e8 100644
--- a/src/shared/AtomWriter.cpp
+++ b/src/shared/AtomWriter.cpp
@@ -177,13 +177,15 @@ AtomWriter::connect(const Raul::Path& src,
{
LV2_Atom_Forge_Frame msg;
lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Put);
+ lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0);
+ forge_uri(Raul::Path::lca(src, dst));
lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0);
LV2_Atom_Forge_Frame body;
- lv2_atom_forge_blank(&_forge, &body, 0, _uris.ingen_Connection);
- lv2_atom_forge_property_head(&_forge, _uris.ingen_source, 0);
+ lv2_atom_forge_blank(&_forge, &body, 0, _uris.ingen_Edge);
+ lv2_atom_forge_property_head(&_forge, _uris.ingen_tail, 0);
forge_uri(src);
- lv2_atom_forge_property_head(&_forge, _uris.ingen_destination, 0);
+ lv2_atom_forge_property_head(&_forge, _uris.ingen_head, 0);
forge_uri(dst);
lv2_atom_forge_pop(&_forge, &body);
diff --git a/src/shared/URIs.cpp b/src/shared/URIs.cpp
index 415fc421..b1ecda5f 100644
--- a/src/shared/URIs.cpp
+++ b/src/shared/URIs.cpp
@@ -64,7 +64,7 @@ URIs::URIs(Ingen::Forge& f, LV2URIMap* map)
, atom_eventTransfer (forge, map, LV2_ATOM__eventTransfer)
, atom_supports (forge, map, LV2_ATOM__supports)
, doap_name (forge, map, "http://usefulinc.com/ns/doap#name")
- , ingen_Connection (forge, map, NS_INGEN "Connection")
+ , ingen_Edge (forge, map, NS_INGEN "Edge")
, ingen_Internal (forge, map, NS_INGEN "Internal")
, ingen_Node (forge, map, NS_INGEN "Node")
, ingen_Patch (forge, map, NS_INGEN "Patch")
@@ -74,17 +74,17 @@ URIs::URIs(Ingen::Forge& f, LV2URIMap* map)
, ingen_canvasX (forge, map, NS_INGEN "canvasX")
, ingen_canvasY (forge, map, NS_INGEN "canvasY")
, ingen_controlBinding (forge, map, NS_INGEN "controlBinding")
- , ingen_destination (forge, map, NS_INGEN "destination")
, ingen_document (forge, map, NS_INGEN "document")
, ingen_enabled (forge, map, NS_INGEN "enabled")
, ingen_engine (forge, map, NS_INGEN "engine")
+ , ingen_head (forge, map, NS_INGEN "head")
, ingen_nil (forge, map, NS_INGEN "nil")
, ingen_node (forge, map, NS_INGEN "node")
, ingen_polyphonic (forge, map, NS_INGEN "polyphonic")
, ingen_polyphony (forge, map, NS_INGEN "polyphony")
, ingen_sampleRate (forge, map, NS_INGEN "sampleRate")
, ingen_selected (forge, map, NS_INGEN "selected")
- , ingen_source (forge, map, NS_INGEN "source")
+ , ingen_tail (forge, map, NS_INGEN "tail")
, ingen_uiEmbedded (forge, map, NS_INGEN "uiEmbedded")
, ingen_value (forge, map, NS_INGEN "value")
, lv2_AudioPort (forge, map, LV2_CORE__AudioPort)
diff --git a/wscript b/wscript
index f78164f1..24848bb8 100644
--- a/wscript
+++ b/wscript
@@ -60,7 +60,7 @@ def configure(conf):
autowaf.check_pkg(conf, 'sratom-0', uselib_store='SRATOM',
atleast_version='0.1.0', mandatory=True)
autowaf.check_pkg(conf, 'raul', uselib_store='RAUL',
- atleast_version='0.8.3', mandatory=True)
+ atleast_version='0.8.5', mandatory=True)
autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD',
atleast_version='0.7.0', mandatory=False)
if not Options.options.no_gui: