summaryrefslogtreecommitdiffstats
path: root/src/engine/events
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-25 20:40:13 +0000
committerDavid Robillard <d@drobilla.net>2010-02-25 20:40:13 +0000
commit77a9beca75debd2d87d735fc4fe847694eee6f13 (patch)
treeae03699b999e84bc4c283abfd215c8037ecddaf6 /src/engine/events
parente22984efe9b82ab006494aea93814a592cd44ece (diff)
downloadingen-77a9beca75debd2d87d735fc4fe847694eee6f13.tar.gz
ingen-77a9beca75debd2d87d735fc4fe847694eee6f13.tar.bz2
ingen-77a9beca75debd2d87d735fc4fe847694eee6f13.zip
Work on contexts and polymorphic ports.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2492 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/events')
-rw-r--r--src/engine/events/Connect.cpp72
-rw-r--r--src/engine/events/Connect.hpp2
-rw-r--r--src/engine/events/Disconnect.cpp10
-rw-r--r--src/engine/events/RequestMetadata.cpp15
-rw-r--r--src/engine/events/SetMetadata.cpp2
-rw-r--r--src/engine/events/SetPortValue.cpp2
6 files changed, 40 insertions, 63 deletions
diff --git a/src/engine/events/Connect.cpp b/src/engine/events/Connect.cpp
index b4389438..5b7726d9 100644
--- a/src/engine/events/Connect.cpp
+++ b/src/engine/events/Connect.cpp
@@ -47,8 +47,6 @@ Connect::Connect(Engine& engine, SharedPtr<Request> request, SampleCount timesta
, _src_port_path(src_port_path)
, _dst_port_path(dst_port_path)
, _patch(NULL)
- , _src_port(NULL)
- , _dst_port(NULL)
, _src_output_port(NULL)
, _dst_input_port(NULL)
, _compiled_patch(NULL)
@@ -61,58 +59,46 @@ Connect::Connect(Engine& engine, SharedPtr<Request> request, SampleCount timesta
void
Connect::pre_process()
{
- if (_src_port_path.parent().parent() != _dst_port_path.parent().parent()
- && _src_port_path.parent() != _dst_port_path.parent().parent()
- && _src_port_path.parent().parent() != _dst_port_path.parent()) {
- _error = PARENT_PATCH_DIFFERENT;
+ PortImpl* src_port = _engine.engine_store()->find_port(_src_port_path);
+ PortImpl* dst_port = _engine.engine_store()->find_port(_dst_port_path);
+ if (!src_port || !dst_port) {
+ _error = PORT_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
- _src_port = _engine.engine_store()->find_port(_src_port_path);
- _dst_port = _engine.engine_store()->find_port(_dst_port_path);
-
- if (_src_port == NULL || _dst_port == NULL) {
- _error = PORT_NOT_FOUND;
+ _dst_input_port = dynamic_cast<InputPort*>(dst_port);
+ _src_output_port = dynamic_cast<OutputPort*>(src_port);
+ if (!_dst_input_port || !_src_output_port) {
+ _error = DIRECTION_MISMATCH;
QueuedEvent::pre_process();
return;
}
- const PortType src_type = _src_port->type();
- const PortType dst_type = _dst_port->type();
-
- if ( !(
- // Equal types
- (src_type == dst_type)
-
- || // or Control=>Audio or Audio=>Control
- ((src_type == PortType::CONTROL || src_type == PortType::AUDIO)
- && (dst_type == PortType::CONTROL || dst_type == PortType::AUDIO))
-
- || // or Events=>Message or Message=>Events
- ((src_type == PortType::EVENTS || src_type == PortType::MESSAGE)
- && (dst_type == PortType::EVENTS || dst_type == PortType::MESSAGE))
- )) {
- _error = TYPE_MISMATCH;
+ NodeImpl* const src_node = src_port->parent_node();
+ NodeImpl* const dst_node = dst_port->parent_node();
+ if (!src_node || !dst_node) {
+ _error = PARENTS_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
- _dst_input_port = dynamic_cast<InputPort*>(_dst_port);
- _src_output_port = dynamic_cast<OutputPort*>(_src_port);
-
- if (!_dst_input_port || !_src_output_port) {
- _error = DIRECTION_MISMATCH;
+ if (src_node->parent() != dst_node->parent()
+ && src_node != dst_node->parent()
+ && src_node->parent() != dst_node) {
+ _error = PARENT_PATCH_DIFFERENT;
QueuedEvent::pre_process();
return;
}
- NodeImpl* const src_node = _src_port->parent_node();
- NodeImpl* const dst_node = _dst_port->parent_node();
+ if (!ConnectionImpl::can_connect(_src_output_port, _dst_input_port)) {
+ _error = TYPE_MISMATCH;
+ QueuedEvent::pre_process();
+ return;
+ }
// Connection to a patch port from inside the patch
if (src_node->parent_patch() != dst_node->parent_patch()) {
-
assert(src_node->parent() == dst_node || dst_node->parent() == src_node);
if (src_node->parent() == dst_node)
_patch = dynamic_cast<PatchImpl*>(dst_node);
@@ -128,28 +114,14 @@ Connect::pre_process()
_patch = src_node->parent_patch();
}
- assert(_patch);
-
if (_patch->has_connection(_src_output_port, _dst_input_port)) {
_error = ALREADY_CONNECTED;
QueuedEvent::pre_process();
return;
}
- if (src_node == NULL || dst_node == NULL) {
- _error = PARENTS_NOT_FOUND;
- QueuedEvent::pre_process();
- return;
- }
-
- if (_patch != src_node && src_node->parent() != _patch && dst_node->parent() != _patch) {
- _error = PARENTS_NOT_FOUND;
- QueuedEvent::pre_process();
- return;
- }
-
_connection = SharedPtr<ConnectionImpl>(
- new ConnectionImpl(*_engine.buffer_factory(), _src_port, _dst_port));
+ new ConnectionImpl(*_engine.buffer_factory(), _src_output_port, _dst_input_port));
_port_listnode = new InputPort::Connections::Node(_connection);
diff --git a/src/engine/events/Connect.hpp b/src/engine/events/Connect.hpp
index 322a5dbf..cfb924c2 100644
--- a/src/engine/events/Connect.hpp
+++ b/src/engine/events/Connect.hpp
@@ -70,8 +70,6 @@ private:
Raul::Path _dst_port_path;
PatchImpl* _patch;
- PortImpl* _src_port;
- PortImpl* _dst_port;
OutputPort* _src_output_port;
InputPort* _dst_input_port;
diff --git a/src/engine/events/Disconnect.cpp b/src/engine/events/Disconnect.cpp
index 250dc234..f25c0f4a 100644
--- a/src/engine/events/Disconnect.cpp
+++ b/src/engine/events/Disconnect.cpp
@@ -190,10 +190,12 @@ Disconnect::execute(ProcessContext& context)
_dst_input_port->connect_buffers();
if (_clear_dst_port) {
for (uint32_t v = 0; v < _dst_input_port->poly(); ++v) {
- if (_dst_input_port->type() == PortType::CONTROL) {
- PtrCast<AudioBuffer>(_dst_input_port->buffer(v))->set_value(
- _dst_input_port->value().get_float(),
- context.start(), context.start());
+ if (_dst_input_port->is_a(PortType::CONTROL)) {
+ IntrusivePtr<AudioBuffer> abuf(PtrCast<AudioBuffer>(
+ _dst_input_port->buffer(v)));
+ if (abuf)
+ abuf->set_value(_dst_input_port->value().get_float(),
+ context.start(), context.start());
} else {
_dst_input_port->buffer(v)->clear();
}
diff --git a/src/engine/events/RequestMetadata.cpp b/src/engine/events/RequestMetadata.cpp
index 707398bd..4d879298 100644
--- a/src/engine/events/RequestMetadata.cpp
+++ b/src/engine/events/RequestMetadata.cpp
@@ -15,6 +15,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "raul/IntrusivePtr.hpp"
#include "interface/ClientInterface.hpp"
#include "events/RequestMetadata.hpp"
#include "shared/LV2Object.hpp"
@@ -94,11 +95,15 @@ RequestMetadata::execute(ProcessContext& context)
if (_special_type == PORT_VALUE) {
PortImpl* port = dynamic_cast<PortImpl*>(_resource);
if (port) {
- if (port->type() == PortType::CONTROL || port->type() == PortType::AUDIO)
- _value = ((AudioBuffer*)port->buffer(0).get())->value_at(0); // TODO: offset
- else if (port->type() == PortType::VALUE || port->type() == PortType::MESSAGE)
- LV2Object::to_atom(context.engine().world(),
- ((ObjectBuffer*)port->buffer(0).get())->object(), _value);
+ IntrusivePtr<AudioBuffer> abuf = PtrCast<AudioBuffer>(port->buffer(0));
+ if (abuf) {
+ _value = abuf->value_at(0);
+ } else {
+ IntrusivePtr<ObjectBuffer> obuf = PtrCast<ObjectBuffer>(port->buffer(0));
+ if (obuf) {
+ LV2Object::to_atom(obuf->object(), _value);
+ }
+ }
} else {
_resource = 0;
}
diff --git a/src/engine/events/SetMetadata.cpp b/src/engine/events/SetMetadata.cpp
index c1cc97f0..a44261d4 100644
--- a/src/engine/events/SetMetadata.cpp
+++ b/src/engine/events/SetMetadata.cpp
@@ -193,7 +193,7 @@ SetMetadata::pre_process()
ev->pre_process();
_set_events.push_back(ev);
} else if (key == uris.ingen_controlBinding) {
- if (port->type() == Shared::PortType::CONTROL) {
+ if (port->is_a(Shared::PortType::CONTROL)) {
if (value == uris.wildcard) {
_engine.control_bindings()->learn(port);
} else if (value.type() == Atom::DICT) {
diff --git a/src/engine/events/SetPortValue.cpp b/src/engine/events/SetPortValue.cpp
index 2ad94082..b93783c2 100644
--- a/src/engine/events/SetPortValue.cpp
+++ b/src/engine/events/SetPortValue.cpp
@@ -176,7 +176,7 @@ SetPortValue::apply(Context& context)
ObjectBuffer* const obuf = dynamic_cast<ObjectBuffer*>(buf);
if (obuf) {
obuf->object()->size = obuf->size() - sizeof(LV2_Object);
- if (LV2Object::from_atom(_engine.world(), _value, obuf->object())) {
+ if (LV2Object::from_atom(_value, obuf->object())) {
debug << "Converted atom " << _value << " :: " << obuf->object()->type
<< " * " << obuf->object()->size << " @ " << obuf->object() << endl;
return;