summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/Engine.cpp3
-rw-r--r--src/engine/events/CreatePort.cpp14
-rw-r--r--src/engine/events/CreatePort.hpp1
3 files changed, 18 insertions, 0 deletions
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp
index 3f65b587..fe9bdd8c 100644
--- a/src/engine/Engine.cpp
+++ b/src/engine/Engine.cpp
@@ -197,6 +197,7 @@ Engine::activate()
// Add control input
Shared::Resource::Properties in_properties(control_properties);
in_properties.insert(make_pair(uris.rdf_type, uris.lv2_InputPort));
+ in_properties.insert(make_pair(uris.lv2_index, 0));
execute_and_delete_event(context, new Events::CreatePort(
*this, SharedPtr<Request>(), 0,
@@ -205,6 +206,8 @@ Engine::activate()
// Add control out
Shared::Resource::Properties out_properties(control_properties);
out_properties.insert(make_pair(uris.rdf_type, uris.lv2_OutputPort));
+ out_properties.insert(make_pair(uris.lv2_index, 1));
+
execute_and_delete_event(context, new Events::CreatePort(
*this, SharedPtr<Request>(), 0,
"/control_out", uris.lv2ev_EventPort, true, out_properties));
diff --git a/src/engine/events/CreatePort.cpp b/src/engine/events/CreatePort.cpp
index 63ebede2..d2953c86 100644
--- a/src/engine/events/CreatePort.cpp
+++ b/src/engine/events/CreatePort.cpp
@@ -96,6 +96,14 @@ CreatePort::pre_process()
? _patch->external_ports()->size()
: 0;
+ Shared::Resource::Properties::const_iterator index_i = _properties.find(uris.lv2_index);
+ if (index_i->second.type() != Atom::INT
+ || index_i->second.get_int32() != static_cast<int32_t>(old_num_ports)) {
+ QueuedEvent::pre_process();
+ _error = BAD_INDEX;
+ return;
+ }
+
_patch_port = _patch->create_port(*_engine.buffer_factory(), _path.symbol(), _data_type, buffer_size, _is_output);
if (_patch->parent())
_patch_port->set_property(uris.rdf_instanceOf, _patch_port->meta_uri());
@@ -103,6 +111,8 @@ CreatePort::pre_process()
_patch_port->properties().insert(_properties.begin(), _properties.end());
_patch_port->meta().properties().insert(_properties.begin(), _properties.end());
+ assert(index_i->second == Atom((int)_patch_port->index()));
+
if (_patch_port) {
if (_is_output)
@@ -164,6 +174,10 @@ CreatePort::post_process()
_request->respond_ok();
_engine.broadcaster()->send_object(_patch_port, true);
break;
+ case BAD_INDEX:
+ msg = string("Could not create port ") + _path.str() + " (Illegal index given)";
+ _request->respond_error(msg);
+ break;
case UNKNOWN_TYPE:
msg = string("Could not create port ") + _path.str() + " (Unknown type)";
_request->respond_error(msg);
diff --git a/src/engine/events/CreatePort.hpp b/src/engine/events/CreatePort.hpp
index b901dbf4..350a6b93 100644
--- a/src/engine/events/CreatePort.hpp
+++ b/src/engine/events/CreatePort.hpp
@@ -57,6 +57,7 @@ private:
enum ErrorType {
NO_ERROR,
UNKNOWN_TYPE,
+ BAD_INDEX,
CREATION_FAILED
};