summaryrefslogtreecommitdiffstats
path: root/src/server/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/events')
-rw-r--r--src/server/events/CreateGraph.cpp92
-rw-r--r--src/server/events/CreateGraph.hpp17
-rw-r--r--src/server/events/CreatePort.cpp12
-rw-r--r--src/server/events/CreatePort.hpp10
-rw-r--r--src/server/events/Delta.cpp2
5 files changed, 109 insertions, 24 deletions
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index 7c4b1940..e6ad0cb4 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -24,6 +24,7 @@
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "events/CreateGraph.hpp"
+#include "events/CreatePort.hpp"
namespace Ingen {
namespace Server {
@@ -43,16 +44,63 @@ CreateGraph::CreateGraph(Engine& engine,
, _compiled_graph(NULL)
{}
+void
+CreateGraph::build_child_events()
+{
+ const Ingen::URIs& uris = _engine.world()->uris();
+
+ // Properties common to both ports
+ Resource::Properties control_properties;
+ control_properties.put(uris.lv2_name, uris.forge.alloc("Control"));
+ control_properties.put(uris.rdf_type, uris.atom_AtomPort);
+ control_properties.put(uris.atom_bufferType, uris.atom_Sequence);
+ control_properties.put(uris.rsz_minimumSize, uris.forge.make(4096));
+ control_properties.put(uris.lv2_portProperty, uris.lv2_connectionOptional);
+
+ // Add control input
+ Resource::Properties in_properties(control_properties);
+ in_properties.put(uris.rdf_type, uris.lv2_InputPort);
+ in_properties.put(uris.lv2_index, uris.forge.make(0));
+ in_properties.put(uris.ingen_canvasX, uris.forge.make(32.0f),
+ Resource::Graph::EXTERNAL);
+ in_properties.put(uris.ingen_canvasY, uris.forge.make(32.0f),
+ Resource::Graph::EXTERNAL);
+
+ _child_events.push_back(
+ SPtr<Events::CreatePort>(
+ new Events::CreatePort(
+ _engine, _request_client, -1, _time,
+ _path.child(Raul::Symbol("control_in")),
+ in_properties)));
+
+ // Add control out
+ Resource::Properties out_properties(control_properties);
+ out_properties.put(uris.rdf_type, uris.lv2_OutputPort);
+ out_properties.put(uris.lv2_index, uris.forge.make(1));
+ out_properties.put(uris.ingen_canvasX, uris.forge.make(128.0f),
+ Resource::Graph::EXTERNAL);
+ out_properties.put(uris.ingen_canvasY, uris.forge.make(32.0f),
+ Resource::Graph::EXTERNAL);
+
+ _child_events.push_back(
+ SPtr<Events::CreatePort>(
+ new Events::CreatePort(_engine, _request_client, -1, _time,
+ _path.child(Raul::Symbol("control_out")),
+ out_properties)));
+}
+
bool
CreateGraph::pre_process()
{
- if (_path.is_root() || _engine.store()->get(_path)) {
+ if (_engine.store()->get(_path)) {
return Event::pre_process_done(Status::EXISTS, _path);
}
- _parent = dynamic_cast<GraphImpl*>(_engine.store()->get(_path.parent()));
- if (!_parent) {
- return Event::pre_process_done(Status::PARENT_NOT_FOUND, _path.parent());
+ if (!_path.is_root()) {
+ const Raul::Path up(_path.parent());
+ if (!(_parent = dynamic_cast<GraphImpl*>(_engine.store()->get(up)))) {
+ return Event::pre_process_done(Status::PARENT_NOT_FOUND, up);
+ }
}
const Ingen::URIs& uris = _engine.world()->uris();
@@ -70,11 +118,11 @@ CreateGraph::pre_process()
return Event::pre_process_done(Status::INVALID_POLY, _path);
}
- if (int_poly == _parent->internal_poly()) {
+ if (!_parent || int_poly == _parent->internal_poly()) {
ext_poly = int_poly;
}
- const Raul::Symbol symbol((_path.is_root()) ? "root" : _path.symbol());
+ const Raul::Symbol symbol(_path.is_root() ? "graph" : _path.symbol());
// Get graph prototype
iterator t = _properties.find(uris.lv2_prototype);
@@ -108,10 +156,13 @@ CreateGraph::pre_process()
_graph->set_properties(_properties);
- _parent->add_block(*_graph);
- if (_parent->enabled()) {
- _graph->enable();
- _compiled_graph = _parent->compile();
+ if (_parent) {
+ // Add graph to parent
+ _parent->add_block(*_graph);
+ if (_parent->enabled()) {
+ _graph->enable();
+ _compiled_graph = _parent->compile();
+ }
}
_graph->activate(*_engine.buffer_factory());
@@ -123,6 +174,12 @@ CreateGraph::pre_process()
_engine.store()->add(&block);
}
+ // Build and pre-process child events to create standard ports
+ build_child_events();
+ for (SPtr<Event> ev : _child_events) {
+ ev->pre_process();
+ }
+
return Event::pre_process_done(Status::SUCCESS);
}
@@ -130,7 +187,13 @@ void
CreateGraph::execute(ProcessContext& context)
{
if (_graph) {
- _parent->set_compiled_graph(_compiled_graph);
+ if (_parent) {
+ _parent->set_compiled_graph(_compiled_graph);
+ }
+
+ for (SPtr<Event> ev : _child_events) {
+ ev->execute(context);
+ }
}
}
@@ -141,6 +204,13 @@ CreateGraph::post_process()
if (respond() == Status::SUCCESS) {
_update.send(_engine.broadcaster());
}
+
+ if (_graph) {
+ for (SPtr<Event> ev : _child_events) {
+ ev->post_process();
+ }
+ }
+ _child_events.clear();
}
} // namespace Events
diff --git a/src/server/events/CreateGraph.hpp b/src/server/events/CreateGraph.hpp
index e7a5e7af..bcb857ae 100644
--- a/src/server/events/CreateGraph.hpp
+++ b/src/server/events/CreateGraph.hpp
@@ -48,13 +48,18 @@ public:
void execute(ProcessContext& context);
void post_process();
+ GraphImpl* graph() { return _graph; }
+
private:
- const Raul::Path _path;
- Resource::Properties _properties;
- Events::Get::Response _update;
- GraphImpl* _graph;
- GraphImpl* _parent;
- CompiledGraph* _compiled_graph;
+ void build_child_events();
+
+ const Raul::Path _path;
+ Resource::Properties _properties;
+ Events::Get::Response _update;
+ GraphImpl* _graph;
+ GraphImpl* _parent;
+ CompiledGraph* _compiled_graph;
+ std::list< SPtr<Event> > _child_events;
};
} // namespace Events
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 4988c480..0f711f4f 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -41,7 +41,6 @@ CreatePort::CreatePort(Engine& engine,
int32_t id,
SampleCount timestamp,
const Raul::Path& path,
- bool is_output,
const Resource::Properties& properties)
: Event(engine, client, id, timestamp)
, _path(path)
@@ -53,7 +52,6 @@ CreatePort::CreatePort(Engine& engine,
, _old_ports_array(NULL)
, _engine_port(NULL)
, _properties(properties)
- , _is_output(is_output)
{
const Ingen::URIs& uris = _engine.world()->uris();
@@ -71,6 +69,10 @@ CreatePort::CreatePort(Engine& engine,
_port_type = PortType::CV;
} else if (type == uris.atom_AtomPort) {
_port_type = PortType::ATOM;
+ } else if (type == uris.lv2_InputPort) {
+ _flow = Flow::INPUT;
+ } else if (type == uris.lv2_OutputPort) {
+ _flow = Flow::OUTPUT;
}
}
@@ -88,6 +90,8 @@ CreatePort::pre_process()
{
if (_port_type == PortType::UNKNOWN) {
return Event::pre_process_done(Status::UNKNOWN_TYPE, _path);
+ } else if (!_flow) {
+ return Event::pre_process_done(Status::UNKNOWN_TYPE, _path);
} else if (_path.is_root()) {
return Event::pre_process_done(Status::BAD_URI, _path);
} else if (_engine.store()->get(_path)) {
@@ -136,12 +140,12 @@ CreatePort::pre_process()
_graph->num_ports_non_rt(),
polyphonic,
_port_type, _buf_type, buf_size,
- value, _is_output);
+ value, _flow == Flow::OUTPUT);
_graph_port->properties().insert(_properties.begin(), _properties.end());
_engine.store()->add(_graph_port);
- if (_is_output) {
+ if (_flow == Flow::OUTPUT) {
_graph->add_output(*_graph_port);
} else {
_graph->add_input(*_graph_port);
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index f9f1b6fa..a2dd55ce 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -17,6 +17,8 @@
#ifndef INGEN_EVENTS_CREATEPORT_HPP
#define INGEN_EVENTS_CREATEPORT_HPP
+#include <boost/optional.hpp>
+
#include "ingen/Resource.hpp"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
#include "raul/Array.hpp"
@@ -47,7 +49,6 @@ public:
int32_t id,
SampleCount timestamp,
const Raul::Path& path,
- bool is_output,
const Resource::Properties& properties);
bool pre_process();
@@ -55,6 +56,11 @@ public:
void post_process();
private:
+ enum class Flow {
+ INPUT,
+ OUTPUT
+ };
+
Raul::Path _path;
PortType _port_type;
LV2_URID _buf_type;
@@ -65,7 +71,7 @@ private:
EnginePort* _engine_port; ///< Driver port if on the root
Resource::Properties _properties;
Resource::Properties _update;
- bool _is_output;
+ boost::optional<Flow> _flow;
};
} // namespace Events
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index a85c8253..f6932075 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -201,7 +201,7 @@ Delta::pre_process()
} else if (is_port) {
_create_event = new CreatePort(
_engine, _request_client, _request_id, _time,
- path, is_output, _properties);
+ path, _properties);
}
if (_create_event) {
if (_create_event->pre_process()) {