summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/events/ConnectionEvent.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-04-08 06:04:32 +0000
committerDavid Robillard <d@drobilla.net>2007-04-08 06:04:32 +0000
commite96c36c1a7abb062e36efc0ac95c35fedcef922e (patch)
tree826d5caa0392201472d12c02a1c3df4cf7b275be /src/libs/engine/events/ConnectionEvent.cpp
parent7d69e89f22304e37fa325ce4f39a374a02072a69 (diff)
downloadingen-e96c36c1a7abb062e36efc0ac95c35fedcef922e.tar.gz
ingen-e96c36c1a7abb062e36efc0ac95c35fedcef922e.tar.bz2
ingen-e96c36c1a7abb062e36efc0ac95c35fedcef922e.zip
De-template-ification of port types (req. for LV2 MIDI, but nice code size reduction).
LV2 MIDI patching support (LV2 style MIDI throughout, inc. internal plugins). git-svn-id: http://svn.drobilla.net/lad/ingen@415 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/events/ConnectionEvent.cpp')
-rw-r--r--src/libs/engine/events/ConnectionEvent.cpp146
1 files changed, 33 insertions, 113 deletions
diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp
index da723a8c..af35265b 100644
--- a/src/libs/engine/events/ConnectionEvent.cpp
+++ b/src/libs/engine/events/ConnectionEvent.cpp
@@ -22,7 +22,7 @@
#include "Responder.h"
#include "types.h"
#include "Engine.h"
-#include "TypedConnection.h"
+#include "Connection.h"
#include "InputPort.h"
#include "OutputPort.h"
#include "Patch.h"
@@ -34,9 +34,6 @@ using std::string;
namespace Ingen {
-//// ConnectionEvent ////
-
-
ConnectionEvent::ConnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& src_port_path, const string& dst_port_path)
: QueuedEvent(engine, responder, timestamp),
_src_port_path(src_port_path),
@@ -44,18 +41,15 @@ ConnectionEvent::ConnectionEvent(Engine& engine, SharedPtr<Responder> responder,
_patch(NULL),
_src_port(NULL),
_dst_port(NULL),
- _typed_event(NULL),
+ _process_order(NULL),
+ _connection(NULL),
+ _patch_listnode(NULL),
+ _port_listnode(NULL),
_error(NO_ERROR)
{
}
-ConnectionEvent::~ConnectionEvent()
-{
- delete _typed_event;
-}
-
-
void
ConnectionEvent::pre_process()
{
@@ -67,14 +61,6 @@ ConnectionEvent::pre_process()
return;
}
- /*_patch = _engine.object_store()->find_patch(_src_port_path.parent().parent());
-
- if (_patch == NULL) {
- _error = PORT_NOT_FOUND;
- QueuedEvent::pre_process();
- return;
- }*/
-
_src_port = _engine.object_store()->find_port(_src_port_path);
_dst_port = _engine.object_store()->find_port(_dst_port_path);
@@ -84,96 +70,33 @@ ConnectionEvent::pre_process()
return;
}
- if (_src_port->type() != _dst_port->type() || _src_port->buffer_size() != _dst_port->buffer_size()) {
+ if (_src_port->type() != _dst_port->type()) {
_error = TYPE_MISMATCH;
QueuedEvent::pre_process();
return;
}
-
- /*if (port1->is_output() && port2->is_input()) {
- _src_port = port1;
- _dst_port = port2;
- } else if (port2->is_output() && port1->is_input()) {
- _src_port = port2;
- _dst_port = port1;
- } else {
+
+ // FIXME: MIDI buffer size is a kluge all around
+ if (_src_port->type() == DataType::FLOAT
+ && _src_port->buffer_size() != _dst_port->buffer_size()) {
_error = TYPE_MISMATCH;
QueuedEvent::pre_process();
return;
- }*/
-
- // Create the typed event to actually do the work
- const DataType type = _src_port->type();
- if (type == DataType::FLOAT) {
- _typed_event = new TypedConnectionEvent<Sample>(_engine, _responder, _time,
- dynamic_cast<OutputPort<Sample>*>(_src_port), dynamic_cast<InputPort<Sample>*>(_dst_port));
- } else if (type == DataType::MIDI) {
- _typed_event = new TypedConnectionEvent<MidiMessage>(_engine, _responder, _time,
- dynamic_cast<OutputPort<MidiMessage>*>(_src_port), dynamic_cast<InputPort<MidiMessage>*>(_dst_port));
- } else {
+ }
+
+ /*if ( !( _src_port->is_output() && _dst_port->is_input() ) ) {
_error = TYPE_MISMATCH;
QueuedEvent::pre_process();
return;
- }
-
- assert(_typed_event);
- _typed_event->pre_process();
- assert(_typed_event->is_prepared());
-
- QueuedEvent::pre_process();
-}
-
-
-void
-ConnectionEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
-{
- QueuedEvent::execute(nframes, start, end);
-
- if (_error == NO_ERROR)
- _typed_event->execute(nframes, start, end);
-}
-
-
-void
-ConnectionEvent::post_process()
-{
- if (_error == NO_ERROR) {
- _typed_event->post_process();
- } else {
- // FIXME: better error messages
- string msg = "Unable to make connection ";
- msg.append(_src_port_path + " -> " + _dst_port_path);
- _responder->respond_error(msg);
- }
-}
-
-
-
-//// TypedConnectionEvent ////
-
-
-template <typename T>
-TypedConnectionEvent<T>::TypedConnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, OutputPort<T>* src_port, InputPort<T>* dst_port)
-: QueuedEvent(engine, responder, timestamp),
- _src_port(src_port),
- _dst_port(dst_port),
- _patch(NULL),
- _process_order(NULL),
- _connection(NULL),
- _port_listnode(NULL),
- _succeeded(true)
-{
- assert(src_port != NULL);
- assert(dst_port != NULL);
-}
+ }*/
+ _dst_input_port = dynamic_cast<InputPort*>(_dst_port);
+ _src_output_port = dynamic_cast<OutputPort*>(_src_port);
+ assert(_src_output_port);
+ assert(_dst_input_port);
-template <typename T>
-void
-TypedConnectionEvent<T>::pre_process()
-{
- if (_dst_port->is_connected_to(_src_port)) {
- _succeeded = false;
+ if (_dst_input_port->is_connected_to(_src_output_port)) {
+ _error = ALREADY_CONNECTED;
QueuedEvent::pre_process();
return;
}
@@ -202,19 +125,19 @@ TypedConnectionEvent<T>::pre_process()
assert(_patch);
if (src_node == NULL || dst_node == NULL) {
- _succeeded = false;
+ _error = PARENTS_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
if (_patch != src_node && src_node->parent() != _patch && dst_node->parent() != _patch) {
- _succeeded = false;
+ _error = PARENTS_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
- _connection = new TypedConnection<T>(_src_port, _dst_port);
- _port_listnode = new Raul::ListNode<TypedConnection<T>*>(_connection);
+ _connection = new Connection(_src_port, _dst_port);
+ _port_listnode = new Raul::ListNode<Connection*>(_connection);
_patch_listnode = new Raul::ListNode<Connection*>(_connection);
// Need to be careful about patch port connections here and adding a node's
@@ -227,20 +150,18 @@ TypedConnectionEvent<T>::pre_process()
if (_patch->enabled())
_process_order = _patch->build_process_order();
- _succeeded = true;
QueuedEvent::pre_process();
}
-template <typename T>
void
-TypedConnectionEvent<T>::execute(SampleCount nframes, FrameTime start, FrameTime end)
+ConnectionEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
QueuedEvent::execute(nframes, start, end);
- if (_succeeded) {
+ if (_error == NO_ERROR) {
// These must be inserted here, since they're actually used by the audio thread
- _dst_port->add_connection(_port_listnode);
+ _dst_input_port->add_connection(_port_listnode);
_patch->add_connection(_patch_listnode);
if (_patch->process_order() != NULL)
_engine.maid()->push(_patch->process_order());
@@ -249,18 +170,17 @@ TypedConnectionEvent<T>::execute(SampleCount nframes, FrameTime start, FrameTime
}
-template <typename T>
void
-TypedConnectionEvent<T>::post_process()
+ConnectionEvent::post_process()
{
- if (_succeeded) {
- assert(_connection != NULL);
-
+ if (_error == NO_ERROR) {
_responder->respond_ok();
-
_engine.broadcaster()->send_connection(_connection);
} else {
- _responder->respond_error("Unable to make connection.");
+ // FIXME: better error messages
+ string msg = "Unable to make connection ";
+ msg.append(_src_port_path + " -> " + _dst_port_path);
+ _responder->respond_error(msg);
}
}