From 9d9efa215c52a6b75eef7e9a8b088b11dfd76a07 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 8 Oct 2007 01:38:38 +0000 Subject: Shared abstract Connection interface. Only Patch to go, now.... git-svn-id: http://svn.drobilla.net/lad/ingen@843 a436a847-0d15-0410-975c-d299462d15a1 --- src/common/interface/Connection.hpp | 42 ++++++ src/common/interface/Makefile.am | 7 +- src/libs/client/ConnectionModel.cpp | 78 ----------- src/libs/client/ConnectionModel.hpp | 30 ++--- src/libs/client/Makefile.am | 1 - src/libs/client/PatchModel.cpp | 2 +- src/libs/client/PatchModel.hpp | 14 +- src/libs/client/Serializer.cpp | 6 +- src/libs/client/Serializer.hpp | 4 +- src/libs/client/Store.cpp | 49 ++++--- src/libs/client/Store.hpp | 6 +- src/libs/engine/ClientBroadcaster.cpp | 4 +- src/libs/engine/ClientBroadcaster.hpp | 4 +- src/libs/engine/Connection.cpp | 171 ------------------------- src/libs/engine/Connection.hpp | 97 -------------- src/libs/engine/ConnectionImpl.cpp | 171 +++++++++++++++++++++++++ src/libs/engine/ConnectionImpl.hpp | 101 +++++++++++++++ src/libs/engine/DuplexPort.cpp | 2 +- src/libs/engine/InputPort.cpp | 10 +- src/libs/engine/InputPort.hpp | 8 +- src/libs/engine/Makefile.am | 4 +- src/libs/engine/OSCClientSender.cpp | 2 +- src/libs/engine/ObjectSender.cpp | 4 +- src/libs/engine/Patch.cpp | 14 +- src/libs/engine/Patch.hpp | 30 ++--- src/libs/engine/events/ClearPatchEvent.cpp | 4 +- src/libs/engine/events/ConnectionEvent.cpp | 8 +- src/libs/engine/events/ConnectionEvent.hpp | 9 +- src/libs/engine/events/DisconnectNodeEvent.cpp | 6 +- src/libs/engine/events/DisconnectPortEvent.cpp | 6 +- src/libs/engine/events/DisconnectionEvent.cpp | 8 +- src/libs/engine/events/DisconnectionEvent.hpp | 3 +- src/libs/engine/events/SetPolyphonicEvent.cpp | 2 +- src/libs/engine/events/SetPolyphonyEvent.cpp | 2 +- src/libs/gui/Connection.hpp | 6 +- src/libs/gui/PatchCanvas.cpp | 2 +- 36 files changed, 442 insertions(+), 475 deletions(-) create mode 100644 src/common/interface/Connection.hpp delete mode 100644 src/libs/client/ConnectionModel.cpp delete mode 100644 src/libs/engine/Connection.cpp delete mode 100644 src/libs/engine/Connection.hpp create mode 100644 src/libs/engine/ConnectionImpl.cpp create mode 100644 src/libs/engine/ConnectionImpl.hpp (limited to 'src') diff --git a/src/common/interface/Connection.hpp b/src/common/interface/Connection.hpp new file mode 100644 index 00000000..4d5ea1aa --- /dev/null +++ b/src/common/interface/Connection.hpp @@ -0,0 +1,42 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef CONNECTION_H +#define CONNECTION_H + +#include + +namespace Ingen { +namespace Shared { + + +/** A connection between two ports. + * + * \ingroup interface + */ +class Connection +{ +public: + virtual const Raul::Path src_port_path() const = 0; + virtual const Raul::Path dst_port_path() const = 0; +}; + + +} // namespace Shared +} // namespace Ingen + +#endif // CONNECTION_H diff --git a/src/common/interface/Makefile.am b/src/common/interface/Makefile.am index 8442df77..7fc68563 100644 --- a/src/common/interface/Makefile.am +++ b/src/common/interface/Makefile.am @@ -1,8 +1,9 @@ EXTRA_DIST = \ - README \ ClientInterface.hpp \ + Connection.hpp \ + DataType.hpp \ EngineInterface.hpp \ - Plugin.hpp \ Node.hpp \ + Plugin.hpp \ Port.hpp \ - DataType.hpp \ + README diff --git a/src/libs/client/ConnectionModel.cpp b/src/libs/client/ConnectionModel.cpp deleted file mode 100644 index d35457d1..00000000 --- a/src/libs/client/ConnectionModel.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007 Dave Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include "ConnectionModel.hpp" -#include "PortModel.hpp" -#include "PatchModel.hpp" - -namespace Ingen { -namespace Client { - - -ConnectionModel::ConnectionModel(const Path& src_port, const Path& dst_port) -: _src_port_path(src_port), - _dst_port_path(dst_port) -{ - // Be sure connection is within one patch - //assert(_src_port_path.parent().parent() - // == _dst_port_path.parent().parent()); -} - - -ConnectionModel::ConnectionModel(SharedPtr src, SharedPtr dst) -: _src_port_path(src->path()), - _dst_port_path(dst->path()), - _src_port(src), - _dst_port(dst) -{ - assert(_src_port); - assert(_dst_port); - assert(_src_port->parent()); - assert(_dst_port->parent()); - - // Be sure connection is within one patch - //assert(_src_port_path.parent().parent() - // == _dst_port_path.parent().parent()); -} - - -const Path -ConnectionModel::src_port_path() const -{ - if (!_src_port) - return _src_port_path; - else - return _src_port->path(); -} - - -const Path -ConnectionModel::dst_port_path() const -{ - if (!_dst_port) - return _dst_port_path; - else - return _dst_port->path(); -} - - -typedef list > ConnectionList; - - -} // namespace Client -} // namespace Ingen diff --git a/src/libs/client/ConnectionModel.hpp b/src/libs/client/ConnectionModel.hpp index 1a73b123..83ddbd58 100644 --- a/src/libs/client/ConnectionModel.hpp +++ b/src/libs/client/ConnectionModel.hpp @@ -18,12 +18,13 @@ #ifndef CONNECTIONMODEL_H #define CONNECTIONMODEL_H +#include #include #include #include #include +#include "interface/Connection.hpp" #include "PortModel.hpp" -#include namespace Ingen { namespace Client { @@ -41,35 +42,32 @@ class Store; * * \ingroup IngenClient */ -class ConnectionModel +class ConnectionModel : public Shared::Connection { public: SharedPtr src_port() const { return _src_port; } SharedPtr dst_port() const { return _dst_port; } - const Path src_port_path() const; - const Path dst_port_path() const; + const Path src_port_path() const { return _src_port->path(); } + const Path dst_port_path() const { return _dst_port->path(); } private: friend class Store; - ConnectionModel(const Path& src_port, const Path& dst_port); - ConnectionModel(SharedPtr src, SharedPtr dst); + ConnectionModel(SharedPtr src, SharedPtr dst) + : _src_port(src) + , _dst_port(dst) + { + assert(_src_port); + assert(_dst_port); + assert(_src_port->parent()); + assert(_dst_port->parent()); + } - void set_src_port(SharedPtr port) { _src_port = port; _src_port_path = port->path(); } - void set_dst_port(SharedPtr port) { _dst_port = port; _dst_port_path = port->path(); } - - void src_port_path(const std::string& s) { _src_port_path = s; } - void dst_port_path(const std::string& s) { _dst_port_path = s; } - - Path _src_port_path; ///< Only used if _src_port == NULL - Path _dst_port_path; ///< Only used if _dst_port == NULL SharedPtr _src_port; SharedPtr _dst_port; }; -typedef std::list > ConnectionList; - } // namespace Client } // namespace Ingen diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am index 45ec0bea..9ee32b84 100644 --- a/src/libs/client/Makefile.am +++ b/src/libs/client/Makefile.am @@ -22,7 +22,6 @@ libingen_client_la_LIBADD = \ libingen_client_la_SOURCES = \ $(top_srcdir)/ingen/src/common/interface/ClientInterface.hpp \ $(top_srcdir)/ingen/src/common/interface/EngineInterface.hpp \ - ConnectionModel.cpp \ ConnectionModel.hpp \ ControlModel.hpp \ DeprecatedLoader.cpp \ diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index b50e4fd0..2bd514f3 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -64,7 +64,7 @@ PatchModel::remove_child(SharedPtr o) // Remove any connections which referred to this object, // since they can't possibly exist anymore - for (ConnectionList::iterator j = _connections.begin(); j != _connections.end() ; ) { + for (Connections::iterator j = _connections.begin(); j != _connections.end() ; ) { list >::iterator next = j; ++next; diff --git a/src/libs/client/PatchModel.hpp b/src/libs/client/PatchModel.hpp index 21e89cee..1c35b959 100644 --- a/src/libs/client/PatchModel.hpp +++ b/src/libs/client/PatchModel.hpp @@ -41,7 +41,9 @@ class Store; class PatchModel : public NodeModel { public: - const ConnectionList& connections() const { return _connections; } + typedef std::list > Connections; + + const Connections& connections() const { return _connections; } SharedPtr get_connection(const string& src_port_path, const string& dst_port_path) const; SharedPtr get_node(const string& node_name) const; @@ -97,11 +99,11 @@ private: void rename_node(const Path& old_path, const Path& new_path); void rename_node_port(const Path& old_path, const Path& new_path); - ConnectionList _connections; - string _filename; - bool _enabled; - size_t _poly; - bool _editable; + Connections _connections; + string _filename; + bool _enabled; + size_t _poly; + bool _editable; }; typedef Table > PatchModelMap; diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp index a5fbb614..a8683d00 100644 --- a/src/libs/client/Serializer.cpp +++ b/src/libs/client/Serializer.cpp @@ -36,7 +36,7 @@ #include #include "interface/EngineInterface.hpp" #include "interface/Port.hpp" -#include "ConnectionModel.hpp" +#include "interface/Connection.hpp" #include "PatchModel.hpp" #include "Serializer.hpp" @@ -311,7 +311,7 @@ Serializer::serialize_patch(SharedPtr patch) serialize_port(p, port_id); } - for (ConnectionList::const_iterator c = patch->connections().begin(); c != patch->connections().end(); ++c) { + for (PatchModel::Connections::const_iterator c = patch->connections().begin(); c != patch->connections().end(); ++c) { serialize_connection(*c); } } @@ -420,7 +420,7 @@ Serializer::serialize_port(const Port* port, const RDF::Node& port_id) void -Serializer::serialize_connection(SharedPtr connection) throw (std::logic_error) +Serializer::serialize_connection(SharedPtr connection) throw (std::logic_error) { if (!_model) throw std::logic_error("serialize_connection called without serialization in progress"); diff --git a/src/libs/client/Serializer.hpp b/src/libs/client/Serializer.hpp index fafedfa5..7a739f94 100644 --- a/src/libs/client/Serializer.hpp +++ b/src/libs/client/Serializer.hpp @@ -39,12 +39,12 @@ namespace Shared { class GraphObject; class Node; class Port; + class Connection; } namespace Client { class PatchModel; -class ConnectionModel; /** Serializes Ingen objects (patches, nodes, etc) to RDF. @@ -61,7 +61,7 @@ public: void start_to_string(); void serialize(SharedPtr object) throw (std::logic_error); - void serialize_connection(SharedPtr c) throw (std::logic_error); + void serialize_connection(SharedPtr c) throw (std::logic_error); string finish(); private: diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index 2838ca12..af6b33c5 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -106,12 +106,12 @@ Store::resolve_plugin_orphans(SharedPtr plugin) void -Store::add_connection_orphan(SharedPtr connection) +Store::add_connection_orphan(std::pair orphan) { - cerr << "WARNING: Orphan connection " << connection->src_port_path() - << " -> " << connection->dst_port_path() << " received." << endl; + cerr << "WARNING: Orphan connection " << orphan.first + << " -> " << orphan.second << " received." << endl; - _connection_orphans.push_back(connection); + _connection_orphans.push_back(orphan); } @@ -120,26 +120,16 @@ Store::resolve_connection_orphans(SharedPtr port) { assert(port->parent()); - for (list >::iterator c = _connection_orphans.begin(); + for (list< pair >::iterator c = _connection_orphans.begin(); c != _connection_orphans.end(); ) { - if ((*c)->src_port_path() == port->path()) - (*c)->set_src_port(port); - - if ((*c)->dst_port_path() == port->path()) - (*c)->set_dst_port(port); - - list >::iterator next = c; + list< pair >::iterator next = c; ++next; - if ((*c)->src_port() && (*c)->dst_port()) { - SharedPtr patch = connection_patch((*c)->src_port_path(), (*c)->dst_port_path()); - if (patch) { - cerr << "Resolved orphan connection " << (*c)->src_port_path() << - (*c)->dst_port_path() << endl; - patch->add_connection(*c); + if (c->first == port->path() || c->second == port->path()) { + bool success = attempt_connection(c->first, c->second); + if (success) _connection_orphans.erase(c); - } } c = next; @@ -553,14 +543,12 @@ Store::connection_patch(const Path& src_port_path, const Path& dst_port_path) } -void -Store::connection_event(const Path& src_port_path, const Path& dst_port_path) +bool +Store::attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan) { SharedPtr src_port = PtrCast(object(src_port_path)); SharedPtr dst_port = PtrCast(object(dst_port_path)); - SharedPtr dangling_cm(new ConnectionModel(src_port_path, dst_port_path)); - if (src_port && dst_port) { assert(src_port->parent()); @@ -575,12 +563,23 @@ Store::connection_event(const Path& src_port_path, const Path& dst_port_path) dst_port->connected_to(src_port); patch->add_connection(cm); + + return true; - } else { + } else if (add_orphan) { - add_connection_orphan(dangling_cm); + add_connection_orphan(make_pair(src_port_path, dst_port_path)); } + + return false; +} + + +void +Store::connection_event(const Path& src_port_path, const Path& dst_port_path) +{ + attempt_connection(src_port_path, dst_port_path, true); } diff --git a/src/libs/client/Store.hpp b/src/libs/client/Store.hpp index af241097..26aac803 100644 --- a/src/libs/client/Store.hpp +++ b/src/libs/client/Store.hpp @@ -81,7 +81,7 @@ private: void add_orphan(SharedPtr orphan); void resolve_orphans(SharedPtr parent); - void add_connection_orphan(SharedPtr orphan); + void add_connection_orphan(std::pair orphan); void resolve_connection_orphans(SharedPtr port); void add_plugin_orphan(SharedPtr orphan); @@ -108,6 +108,8 @@ private: void connection_event(const Path& src_port_path, const Path& dst_port_path); void disconnection_event(const Path& src_port_path, const Path& dst_port_path); + bool attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan=false); + SharedPtr _engine; SharedPtr _emitter; @@ -126,7 +128,7 @@ private: Raul::PathTable > > _metadata_orphans; /** Ditto */ - list > _connection_orphans; + list > _connection_orphans; }; diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp index 3c275e4a..97a78b4e 100644 --- a/src/libs/engine/ClientBroadcaster.cpp +++ b/src/libs/engine/ClientBroadcaster.cpp @@ -27,7 +27,7 @@ #include "NodeImpl.hpp" #include "PluginImpl.hpp" #include "PortImpl.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "AudioDriver.hpp" #include "ObjectSender.hpp" #include "OSCClientSender.hpp" @@ -162,7 +162,7 @@ ClientBroadcaster::send_patch_cleared(const string& patch_path) } void -ClientBroadcaster::send_connection(const Connection* const c) +ClientBroadcaster::send_connection(const ConnectionImpl* const c) { for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->connection(c->src_port()->path(), c->dst_port()->path()); diff --git a/src/libs/engine/ClientBroadcaster.hpp b/src/libs/engine/ClientBroadcaster.hpp index e9e74b3a..79669999 100644 --- a/src/libs/engine/ClientBroadcaster.hpp +++ b/src/libs/engine/ClientBroadcaster.hpp @@ -34,7 +34,7 @@ class NodeImpl; class PortImpl; class PluginImpl; class Patch; -class Connection; +class ConnectionImpl; using Shared::ClientInterface; @@ -68,7 +68,7 @@ public: void send_destroyed(const string& path); void send_polyphonic(const string& path, bool polyphonic); void send_patch_cleared(const string& patch_path); - void send_connection(const Connection* const connection); + void send_connection(const ConnectionImpl* const connection); void send_disconnection(const string& src_port_path, const string& dst_port_path); void send_rename(const string& old_path, const string& new_path); void send_patch_enable(const string& patch_path); diff --git a/src/libs/engine/Connection.cpp b/src/libs/engine/Connection.cpp deleted file mode 100644 index 894a9db7..00000000 --- a/src/libs/engine/Connection.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007 Dave Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include "util.hpp" -#include "Connection.hpp" -#include "NodeImpl.hpp" -#include "PortImpl.hpp" -#include "BufferFactory.hpp" -#include "AudioBuffer.hpp" -#include "ProcessContext.hpp" - -namespace Ingen { - - -/** Constructor for a connection from a node's output port. - * - * This handles both polyphonic and monophonic nodes, transparently to the - * user (InputPort). - */ -Connection::Connection(PortImpl* src_port, PortImpl* dst_port) - : _src_port(src_port) - , _dst_port(dst_port) - , _local_buffer(NULL) - , _buffer_size(dst_port->buffer_size()) - /*, _must_mix( (src_port->poly() != dst_port->poly()) - || (src_port->buffer(0)->size() < dst_port->buffer(0)->size()) )*/ - , _must_mix( (src_port->polyphonic() && (! dst_port->polyphonic())) - || (src_port->poly() != dst_port->poly() ) - || (src_port->buffer(0)->size() < dst_port->buffer(0)->size()) ) - , _pending_disconnection(false) -{ - assert(src_port); - assert(dst_port); - assert(src_port->type() == dst_port->type()); - - /*assert((src_port->parent_node()->poly() == dst_port->parent_node()->poly()) - || (src_port->parent_node()->poly() == 1 || dst_port->parent_node()->poly() == 1));*/ - - if (type() == DataType::MIDI) - _must_mix = false; // FIXME: kludge - - if (_must_mix) - _local_buffer = BufferFactory::create(dst_port->type(), dst_port->buffer(0)->size()); - - //cerr << src_port->path() << " -> " << dst_port->path() << " must mix: " << _must_mix << endl; -} - - -Connection::~Connection() -{ - delete _local_buffer; -} - - -void -Connection::set_buffer_size(size_t size) -{ - if (_must_mix) { - assert(_local_buffer); - delete _local_buffer; - - _local_buffer = BufferFactory::create(_dst_port->type(), _dst_port->buffer(0)->size()); - } - - _buffer_size = size; -} - - -void -Connection::prepare_poly(uint32_t poly) -{ - if (type() == DataType::CONTROL || type() == DataType::AUDIO) - _must_mix = (poly > 1) && ( - (_src_port->poly() != _dst_port->poly()) - || (_src_port->polyphonic() && !_dst_port->polyphonic()) - || (_src_port->parent()->polyphonic() && !_dst_port->parent()->polyphonic()) ); - - /*cerr << src_port()->path() << " * " << src_port()->poly() - << " -> " << dst_port()->path() << " * " << dst_port()->poly() - << "\t\tmust mix: " << _must_mix << " at poly " << poly << endl;*/ - - if (_must_mix && ! _local_buffer) - _local_buffer = BufferFactory::create(_dst_port->type(), _dst_port->buffer(0)->size()); -} - - -void -Connection::apply_poly(Raul::Maid& maid, uint32_t poly) -{ - if (poly == 1 && _local_buffer && !_must_mix) { - maid.push(_local_buffer); - _local_buffer = NULL; - } -} - - -void -Connection::process(ProcessContext& context) -{ - // FIXME: nframes parameter not used - assert(_buffer_size == 1 || _buffer_size == context.nframes()); - - /* Thought: A poly output port can be connected to multiple mono input - * ports, which means this mix down would have to happen many times. - * Adding a method to OutputPort that mixes down all it's outputs into - * a buffer (if it hasn't been done already this cycle) and returns that - * would avoid having to mix multiple times. Probably not a very common - * case, but it would be faster anyway. */ - - if (_must_mix && (type() == DataType::CONTROL || type() == DataType::AUDIO)) { - - const AudioBuffer* const src_buffer = (AudioBuffer*)src_port()->buffer(0); - AudioBuffer* mix_buf = (AudioBuffer*)_local_buffer; - - assert(mix_buf); - - const size_t copy_size = std::min(src_buffer->size(), mix_buf->size()); - - // Copy src buffer to start of mix buffer - mix_buf->copy((AudioBuffer*)src_port()->buffer(0), 0, copy_size-1); - - // Write last value of src buffer to remainder of dst buffer, if necessary - if (copy_size < mix_buf->size()) - mix_buf->set(src_buffer->value_at(copy_size-1), copy_size, mix_buf->size()-1); - - // Accumulate the source's voices into local buffer starting at the second - // voice (buffer is already set to first voice above) - for (uint32_t j=1; j < src_port()->poly(); ++j) { - mix_buf->accumulate((AudioBuffer*)src_port()->buffer(j), 0, copy_size-1); - } - - // Find the summed value and write it to the remainder of dst buffer - if (copy_size < mix_buf->size()) { - float src_value = src_buffer->value_at(copy_size-1); - for (uint32_t j=1; j < src_port()->poly(); ++j) - src_value += ((AudioBuffer*)src_port()->buffer(j))->value_at(copy_size-1); - - mix_buf->set(src_value, copy_size, mix_buf->size()-1); - } - - // Scale the buffer down. - if (src_port()->poly() > 1) - mix_buf->scale(1.0f/(float)src_port()->poly(), 0, _buffer_size-1); - - } else if (_must_mix && type() == DataType::MIDI) { - - cerr << "WARNING: No MIDI mixing." << endl; - - } - -} - - -} // namespace Ingen - diff --git a/src/libs/engine/Connection.hpp b/src/libs/engine/Connection.hpp deleted file mode 100644 index 36dc0ee2..00000000 --- a/src/libs/engine/Connection.hpp +++ /dev/null @@ -1,97 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007 Dave Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef CONNECTION_H -#define CONNECTION_H - -#include -#include -#include -#include "interface/DataType.hpp" -#include "PortImpl.hpp" -#include "types.hpp" - -namespace Ingen { - -class PortImpl; -class Buffer; - - -/** Represents a single inbound connection for an InputPort. - * - * This can be a group of ports (ie coming from a polyphonic Node) or - * a single Port. This class exists basically as an abstraction of mixing - * down polyphonic inputs, so InputPort can just deal with mixing down - * multiple connections (oblivious to the polyphonic situation of the - * connection itself). - * - * \ingroup engine - */ -class Connection : public Raul::Deletable -{ -public: - Connection(PortImpl* src_port, PortImpl* dst_port); - virtual ~Connection(); - - PortImpl* src_port() const { return _src_port; } - PortImpl* dst_port() const { return _dst_port; } - - /** Used by some (recursive) events to prevent double disconnections */ - bool pending_disconnection() { return _pending_disconnection; } - void pending_disconnection(bool b) { _pending_disconnection = b; } - - void process(ProcessContext& context); - - /** Get the buffer for a particular voice. - * A Connection is smart - it knows the destination port requesting the - * buffer, and will return accordingly (ie the same buffer for every voice - * in a mono->poly connection). - */ - inline Buffer* buffer(size_t voice) const; - - void set_buffer_size(size_t size); - void prepare_poly(uint32_t poly); - void apply_poly(Raul::Maid& maid, uint32_t poly); - - DataType type() const { return _src_port->type(); } - -protected: - PortImpl* const _src_port; - PortImpl* const _dst_port; - Buffer* _local_buffer; - size_t _buffer_size; - bool _must_mix; - bool _pending_disconnection; -}; - - -inline Buffer* -Connection::buffer(size_t voice) const -{ - if (_must_mix) { - return _local_buffer; - } else if ( ! _src_port->polyphonic()) { - return _src_port->buffer(0); - } else { - return _src_port->buffer(voice); - } -} - - -} // namespace Ingen - -#endif // CONNECTION_H diff --git a/src/libs/engine/ConnectionImpl.cpp b/src/libs/engine/ConnectionImpl.cpp new file mode 100644 index 00000000..49e8f7f7 --- /dev/null +++ b/src/libs/engine/ConnectionImpl.cpp @@ -0,0 +1,171 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include "util.hpp" +#include "ConnectionImpl.hpp" +#include "NodeImpl.hpp" +#include "PortImpl.hpp" +#include "BufferFactory.hpp" +#include "AudioBuffer.hpp" +#include "ProcessContext.hpp" + +namespace Ingen { + + +/** Constructor for a connection from a node's output port. + * + * This handles both polyphonic and monophonic nodes, transparently to the + * user (InputPort). + */ +ConnectionImpl::ConnectionImpl(PortImpl* src_port, PortImpl* dst_port) + : _src_port(src_port) + , _dst_port(dst_port) + , _local_buffer(NULL) + , _buffer_size(dst_port->buffer_size()) + /*, _must_mix( (src_port->poly() != dst_port->poly()) + || (src_port->buffer(0)->size() < dst_port->buffer(0)->size()) )*/ + , _must_mix( (src_port->polyphonic() && (! dst_port->polyphonic())) + || (src_port->poly() != dst_port->poly() ) + || (src_port->buffer(0)->size() < dst_port->buffer(0)->size()) ) + , _pending_disconnection(false) +{ + assert(src_port); + assert(dst_port); + assert(src_port->type() == dst_port->type()); + + /*assert((src_port->parent_node()->poly() == dst_port->parent_node()->poly()) + || (src_port->parent_node()->poly() == 1 || dst_port->parent_node()->poly() == 1));*/ + + if (type() == DataType::MIDI) + _must_mix = false; // FIXME: kludge + + if (_must_mix) + _local_buffer = BufferFactory::create(dst_port->type(), dst_port->buffer(0)->size()); + + //cerr << src_port->path() << " -> " << dst_port->path() << " must mix: " << _must_mix << endl; +} + + +ConnectionImpl::~ConnectionImpl() +{ + delete _local_buffer; +} + + +void +ConnectionImpl::set_buffer_size(size_t size) +{ + if (_must_mix) { + assert(_local_buffer); + delete _local_buffer; + + _local_buffer = BufferFactory::create(_dst_port->type(), _dst_port->buffer(0)->size()); + } + + _buffer_size = size; +} + + +void +ConnectionImpl::prepare_poly(uint32_t poly) +{ + if (type() == DataType::CONTROL || type() == DataType::AUDIO) + _must_mix = (poly > 1) && ( + (_src_port->poly() != _dst_port->poly()) + || (_src_port->polyphonic() && !_dst_port->polyphonic()) + || (_src_port->parent()->polyphonic() && !_dst_port->parent()->polyphonic()) ); + + /*cerr << src_port()->path() << " * " << src_port()->poly() + << " -> " << dst_port()->path() << " * " << dst_port()->poly() + << "\t\tmust mix: " << _must_mix << " at poly " << poly << endl;*/ + + if (_must_mix && ! _local_buffer) + _local_buffer = BufferFactory::create(_dst_port->type(), _dst_port->buffer(0)->size()); +} + + +void +ConnectionImpl::apply_poly(Raul::Maid& maid, uint32_t poly) +{ + if (poly == 1 && _local_buffer && !_must_mix) { + maid.push(_local_buffer); + _local_buffer = NULL; + } +} + + +void +ConnectionImpl::process(ProcessContext& context) +{ + // FIXME: nframes parameter not used + assert(_buffer_size == 1 || _buffer_size == context.nframes()); + + /* Thought: A poly output port can be connected to multiple mono input + * ports, which means this mix down would have to happen many times. + * Adding a method to OutputPort that mixes down all it's outputs into + * a buffer (if it hasn't been done already this cycle) and returns that + * would avoid having to mix multiple times. Probably not a very common + * case, but it would be faster anyway. */ + + if (_must_mix && (type() == DataType::CONTROL || type() == DataType::AUDIO)) { + + const AudioBuffer* const src_buffer = (AudioBuffer*)src_port()->buffer(0); + AudioBuffer* mix_buf = (AudioBuffer*)_local_buffer; + + assert(mix_buf); + + const size_t copy_size = std::min(src_buffer->size(), mix_buf->size()); + + // Copy src buffer to start of mix buffer + mix_buf->copy((AudioBuffer*)src_port()->buffer(0), 0, copy_size-1); + + // Write last value of src buffer to remainder of dst buffer, if necessary + if (copy_size < mix_buf->size()) + mix_buf->set(src_buffer->value_at(copy_size-1), copy_size, mix_buf->size()-1); + + // Accumulate the source's voices into local buffer starting at the second + // voice (buffer is already set to first voice above) + for (uint32_t j=1; j < src_port()->poly(); ++j) { + mix_buf->accumulate((AudioBuffer*)src_port()->buffer(j), 0, copy_size-1); + } + + // Find the summed value and write it to the remainder of dst buffer + if (copy_size < mix_buf->size()) { + float src_value = src_buffer->value_at(copy_size-1); + for (uint32_t j=1; j < src_port()->poly(); ++j) + src_value += ((AudioBuffer*)src_port()->buffer(j))->value_at(copy_size-1); + + mix_buf->set(src_value, copy_size, mix_buf->size()-1); + } + + // Scale the buffer down. + if (src_port()->poly() > 1) + mix_buf->scale(1.0f/(float)src_port()->poly(), 0, _buffer_size-1); + + } else if (_must_mix && type() == DataType::MIDI) { + + cerr << "WARNING: No MIDI mixing." << endl; + + } + +} + + +} // namespace Ingen + diff --git a/src/libs/engine/ConnectionImpl.hpp b/src/libs/engine/ConnectionImpl.hpp new file mode 100644 index 00000000..87b9f7e7 --- /dev/null +++ b/src/libs/engine/ConnectionImpl.hpp @@ -0,0 +1,101 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef CONNECTIONIMPL_H +#define CONNECTIONIMPL_H + +#include +#include +#include +#include "interface/DataType.hpp" +#include "interface/Connection.hpp" +#include "PortImpl.hpp" +#include "types.hpp" + +namespace Ingen { + +class PortImpl; +class Buffer; + + +/** Represents a single inbound connection for an InputPort. + * + * This can be a group of ports (ie coming from a polyphonic Node) or + * a single Port. This class exists basically as an abstraction of mixing + * down polyphonic inputs, so InputPort can just deal with mixing down + * multiple connections (oblivious to the polyphonic situation of the + * connection itself). + * + * \ingroup engine + */ +class ConnectionImpl : public Raul::Deletable, public Shared::Connection +{ +public: + ConnectionImpl(PortImpl* src_port, PortImpl* dst_port); + virtual ~ConnectionImpl(); + + PortImpl* src_port() const { return _src_port; } + PortImpl* dst_port() const { return _dst_port; } + + const Raul::Path src_port_path() const { return _src_port->path(); } + const Raul::Path dst_port_path() const { return _src_port->path(); } + + /** Used by some (recursive) events to prevent double disconnections */ + bool pending_disconnection() { return _pending_disconnection; } + void pending_disconnection(bool b) { _pending_disconnection = b; } + + void process(ProcessContext& context); + + /** Get the buffer for a particular voice. + * A Connection is smart - it knows the destination port requesting the + * buffer, and will return accordingly (ie the same buffer for every voice + * in a mono->poly connection). + */ + inline Buffer* buffer(size_t voice) const; + + void set_buffer_size(size_t size); + void prepare_poly(uint32_t poly); + void apply_poly(Raul::Maid& maid, uint32_t poly); + + DataType type() const { return _src_port->type(); } + +protected: + PortImpl* const _src_port; + PortImpl* const _dst_port; + Buffer* _local_buffer; + size_t _buffer_size; + bool _must_mix; + bool _pending_disconnection; +}; + + +inline Buffer* +ConnectionImpl::buffer(size_t voice) const +{ + if (_must_mix) { + return _local_buffer; + } else if ( ! _src_port->polyphonic()) { + return _src_port->buffer(0); + } else { + return _src_port->buffer(voice); + } +} + + +} // namespace Ingen + +#endif // CONNECTIONIMPL_H diff --git a/src/libs/engine/DuplexPort.cpp b/src/libs/engine/DuplexPort.cpp index 83ba0e5a..93b61b8c 100644 --- a/src/libs/engine/DuplexPort.cpp +++ b/src/libs/engine/DuplexPort.cpp @@ -20,7 +20,7 @@ #include #include "util.hpp" #include "DuplexPort.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "OutputPort.hpp" #include "NodeImpl.hpp" diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index 6a4de550..05f2de9a 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -20,7 +20,7 @@ #include #include #include "AudioBuffer.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "OutputPort.hpp" #include "NodeImpl.hpp" #include "ProcessContext.hpp" @@ -43,7 +43,7 @@ InputPort::set_buffer_size(size_t size) PortImpl::set_buffer_size(size); assert(_buffer_size = size); - for (Raul::List::iterator c = _connections.begin(); c != _connections.end(); ++c) + for (Raul::List::iterator c = _connections.begin(); c != _connections.end(); ++c) (*c)->set_buffer_size(size); } @@ -55,7 +55,7 @@ InputPort::set_buffer_size(size_t size) * if there is only one connection, since no mixing needs to take place. */ void -InputPort::add_connection(Raul::ListNode* const c) +InputPort::add_connection(Raul::ListNode* const c) { _connections.push_back(c); @@ -85,13 +85,13 @@ InputPort::add_connection(Raul::ListNode* const c) /** Remove a connection. Realtime safe. */ -Raul::ListNode* +Raul::ListNode* InputPort::remove_connection(const OutputPort* src_port) { bool modify_buffers = !_fixed_buffers; bool found = false; - Raul::ListNode* connection = NULL; + Raul::ListNode* connection = NULL; for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i) { if ((*i)->src_port()->path() == src_port->path()) { connection = _connections.erase(i); diff --git a/src/libs/engine/InputPort.hpp b/src/libs/engine/InputPort.hpp index 228371f8..1552642b 100644 --- a/src/libs/engine/InputPort.hpp +++ b/src/libs/engine/InputPort.hpp @@ -28,7 +28,7 @@ using std::string; namespace Ingen { -class Connection; +class ConnectionImpl; class OutputPort; class NodeImpl; @@ -50,10 +50,10 @@ public: InputPort(NodeImpl* parent, const string& name, uint32_t index, uint32_t poly, DataType type, size_t buffer_size); virtual ~InputPort() {} - void add_connection(Raul::ListNode* c); - Raul::ListNode* remove_connection(const OutputPort* src_port); + void add_connection(Raul::ListNode* c); + Raul::ListNode* remove_connection(const OutputPort* src_port); - typedef Raul::List Connections; + typedef Raul::List Connections; const Connections& connections() { return _connections; } void pre_process(ProcessContext& context); diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am index 8b037fb9..a98a1e48 100644 --- a/src/libs/engine/Makefile.am +++ b/src/libs/engine/Makefile.am @@ -28,8 +28,8 @@ libingen_engine_la_SOURCES = \ BufferFactory.hpp \ ClientBroadcaster.cpp \ ClientBroadcaster.hpp \ - Connection.cpp \ - Connection.hpp \ + ConnectionImpl.cpp \ + ConnectionImpl.hpp \ CompiledPatch.hpp \ Driver.hpp \ DuplexPort.cpp \ diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp index ff0b2037..2f63621c 100644 --- a/src/libs/engine/OSCClientSender.cpp +++ b/src/libs/engine/OSCClientSender.cpp @@ -27,7 +27,7 @@ #include "NodeImpl.hpp" #include "PluginImpl.hpp" #include "PortImpl.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "AudioDriver.hpp" #include "interface/ClientInterface.hpp" diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp index fb1039c7..61935207 100644 --- a/src/libs/engine/ObjectSender.cpp +++ b/src/libs/engine/ObjectSender.cpp @@ -22,7 +22,7 @@ #include "NodeImpl.hpp" #include "PortImpl.hpp" #include "PortImpl.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "NodeFactory.hpp" #include "interface/DataType.hpp" #include "AudioBuffer.hpp" @@ -54,7 +54,7 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch, bool recur } // Send connections - for (Raul::List::const_iterator j = patch->connections().begin(); + for (Raul::List::const_iterator j = patch->connections().begin(); j != patch->connections().end(); ++j) { client->connection((*j)->src_port()->path(), (*j)->dst_port()->path()); diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp index 6f3b0a48..83fcf3df 100644 --- a/src/libs/engine/Patch.cpp +++ b/src/libs/engine/Patch.cpp @@ -23,7 +23,7 @@ #include "Patch.hpp" #include "PluginImpl.hpp" #include "PortImpl.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "DuplexPort.hpp" #include "Engine.hpp" #include "ProcessSlave.hpp" @@ -54,7 +54,7 @@ Patch::~Patch() { assert(!_activated); - for (Raul::List::iterator i = _connections.begin(); i != _connections.end(); ++i) { + for (Raul::List::iterator i = _connections.begin(); i != _connections.end(); ++i) { delete (*i); delete _connections.erase(i); } @@ -116,7 +116,7 @@ Patch::prepare_internal_poly(uint32_t poly) for (Raul::List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) (*i)->prepare_poly(poly); - for (Raul::List::iterator i = _connections.begin(); i != _connections.end(); ++i) + for (Raul::List::iterator i = _connections.begin(); i != _connections.end(); ++i) (*i)->prepare_poly(poly); /* FIXME: Deal with failure */ @@ -133,7 +133,7 @@ Patch::apply_internal_poly(Raul::Maid& maid, uint32_t poly) for (Raul::List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) (*i)->apply_poly(maid, poly); - for (Raul::List::iterator i = _connections.begin(); i != _connections.end(); ++i) + for (Raul::List::iterator i = _connections.begin(); i != _connections.end(); ++i) (*i)->apply_poly(maid, poly); _internal_poly = poly; @@ -284,12 +284,12 @@ Patch::remove_node(const string& name) /** Remove a connection. Realtime safe. */ -Raul::ListNode* +Raul::ListNode* Patch::remove_connection(const PortImpl* src_port, const PortImpl* dst_port) { bool found = false; - Raul::ListNode* connection = NULL; - for (Raul::List::iterator i = _connections.begin(); i != _connections.end(); ++i) { + Raul::ListNode* connection = NULL; + for (Raul::List::iterator i = _connections.begin(); i != _connections.end(); ++i) { if ((*i)->src_port() == src_port && (*i)->dst_port() == dst_port) { connection = _connections.erase(i); found = true; diff --git a/src/libs/engine/Patch.hpp b/src/libs/engine/Patch.hpp index 66372c3c..a39106a4 100644 --- a/src/libs/engine/Patch.hpp +++ b/src/libs/engine/Patch.hpp @@ -32,7 +32,7 @@ template class Array; namespace Ingen { -class Connection; +class ConnectionImpl; class Engine; class CompiledPatch; @@ -86,11 +86,11 @@ public: void add_node(Raul::ListNode* tn); Raul::ListNode* remove_node(const string& name); - Raul::List& nodes() { return _nodes; } - Raul::List& connections() { return _connections; } + Raul::List& nodes() { return _nodes; } + Raul::List& connections() { return _connections; } - const Raul::List& nodes() const { return _nodes; } - const Raul::List& connections() const { return _connections; } + const Raul::List& nodes() const { return _nodes; } + const Raul::List& connections() const { return _connections; } uint32_t num_ports() const; @@ -99,8 +99,8 @@ public: void add_output(Raul::ListNode* port) { _output_ports.push_back(port); } ///< Preprocessor thread Raul::ListNode* remove_port(const string& name); - void add_connection(Raul::ListNode* c) { _connections.push_back(c); } - Raul::ListNode* remove_connection(const PortImpl* src_port, const PortImpl* dst_port); + void add_connection(Raul::ListNode* c) { _connections.push_back(c); } + Raul::ListNode* remove_connection(const PortImpl* src_port, const PortImpl* dst_port); CompiledPatch* compiled_patch() { return _compiled_patch; } void compiled_patch(CompiledPatch* cp) { _compiled_patch = cp; } @@ -123,14 +123,14 @@ private: void process_parallel(ProcessContext& context); void process_single(ProcessContext& context); - Engine& _engine; - uint32_t _internal_poly; - CompiledPatch* _compiled_patch; ///< Accessed in audio thread only - Raul::List _connections; ///< Accessed in audio thread only - Raul::List _input_ports; ///< Accessed in preprocessing thread only - Raul::List _output_ports; ///< Accessed in preprocessing thread only - Raul::List _nodes; ///< Accessed in preprocessing thread only - bool _process; + Engine& _engine; + uint32_t _internal_poly; + CompiledPatch* _compiled_patch; ///< Accessed in audio thread only + Raul::List _connections; ///< Accessed in audio thread only + Raul::List _input_ports; ///< Accessed in preprocessing thread only + Raul::List _output_ports; ///< Accessed in preprocessing thread only + Raul::List _nodes; ///< Accessed in preprocessing thread only + bool _process; }; diff --git a/src/libs/engine/events/ClearPatchEvent.cpp b/src/libs/engine/events/ClearPatchEvent.cpp index 1e6c0748..ad35d162 100644 --- a/src/libs/engine/events/ClearPatchEvent.cpp +++ b/src/libs/engine/events/ClearPatchEvent.cpp @@ -25,7 +25,7 @@ #include "ObjectStore.hpp" #include "PortImpl.hpp" #include "NodeImpl.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "QueuedEventSource.hpp" namespace Ingen { @@ -92,7 +92,7 @@ ClearPatchEvent::post_process() _patch->nodes().clear(); // Delete all connections - for (Raul::List::iterator i = _patch->connections().begin(); i != _patch->connections().end(); ++i) + for (Raul::List::iterator i = _patch->connections().begin(); i != _patch->connections().end(); ++i) delete *i; _patch->connections().clear(); diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp index 7f8fa18e..733a46d4 100644 --- a/src/libs/engine/events/ConnectionEvent.cpp +++ b/src/libs/engine/events/ConnectionEvent.cpp @@ -22,7 +22,7 @@ #include "Responder.hpp" #include "types.hpp" #include "Engine.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "InputPort.hpp" #include "OutputPort.hpp" #include "Patch.hpp" @@ -126,9 +126,9 @@ ConnectionEvent::pre_process() return; } - _connection = new Connection(_src_port, _dst_port); - _port_listnode = new Raul::ListNode(_connection); - _patch_listnode = new Raul::ListNode(_connection); + _connection = new ConnectionImpl(_src_port, _dst_port); + _port_listnode = new Raul::ListNode(_connection); + _patch_listnode = new Raul::ListNode(_connection); // Need to be careful about patch port connections here and adding a node's // parent as a dependant/provider, or adding a patch as it's own provider... diff --git a/src/libs/engine/events/ConnectionEvent.hpp b/src/libs/engine/events/ConnectionEvent.hpp index 8fa8c489..d7465566 100644 --- a/src/libs/engine/events/ConnectionEvent.hpp +++ b/src/libs/engine/events/ConnectionEvent.hpp @@ -33,10 +33,9 @@ namespace Ingen { class Patch; class NodeImpl; -class Connection; +class ConnectionImpl; class MidiMessage; class PortImpl; -class Connection; class InputPort; class OutputPort; class CompiledPatch; @@ -78,9 +77,9 @@ private: CompiledPatch* _compiled_patch; ///< New process order for Patch - Connection* _connection; - Raul::ListNode* _patch_listnode; - Raul::ListNode* _port_listnode; + ConnectionImpl* _connection; + Raul::ListNode* _patch_listnode; + Raul::ListNode* _port_listnode; ErrorType _error; }; diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp index 8612d012..e0507b3a 100644 --- a/src/libs/engine/events/DisconnectNodeEvent.cpp +++ b/src/libs/engine/events/DisconnectNodeEvent.cpp @@ -20,7 +20,7 @@ #include #include #include "ClientBroadcaster.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "DisconnectNodeEvent.hpp" #include "DisconnectionEvent.hpp" #include "Engine.hpp" @@ -70,7 +70,7 @@ DisconnectNodeEvent::~DisconnectNodeEvent() void DisconnectNodeEvent::pre_process() { - typedef Raul::List::const_iterator ConnectionListIterator; + typedef Raul::List::const_iterator ConnectionListIterator; if (_lookup) { _patch = _engine.object_store()->find_patch(_node_path.parent()); @@ -90,7 +90,7 @@ DisconnectNodeEvent::pre_process() } } - Connection* c = NULL; + ConnectionImpl* c = NULL; for (ConnectionListIterator i = _patch->connections().begin(); i != _patch->connections().end(); ++i) { c = (*i); if ((c->src_port()->parent_node() == _node || c->dst_port()->parent_node() == _node) && !c->pending_disconnection()) { diff --git a/src/libs/engine/events/DisconnectPortEvent.cpp b/src/libs/engine/events/DisconnectPortEvent.cpp index f7ad9925..76a4cbc4 100644 --- a/src/libs/engine/events/DisconnectPortEvent.cpp +++ b/src/libs/engine/events/DisconnectPortEvent.cpp @@ -23,7 +23,7 @@ #include "Responder.hpp" #include "Engine.hpp" #include "NodeImpl.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "DisconnectionEvent.hpp" #include "PortImpl.hpp" #include "InputPort.hpp" @@ -103,8 +103,8 @@ DisconnectPortEvent::pre_process() return; } - Connection* c = NULL; - for (Raul::List::const_iterator i = _patch->connections().begin(); i != _patch->connections().end(); ++i) { + ConnectionImpl* c = NULL; + for (Raul::List::const_iterator i = _patch->connections().begin(); i != _patch->connections().end(); ++i) { c = (*i); if ((c->src_port() == _port || c->dst_port() == _port) && !c->pending_disconnection()) { DisconnectionEvent* ev = new DisconnectionEvent(_engine, SharedPtr(new Responder()), _time, diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp index 215e0202..68068821 100644 --- a/src/libs/engine/events/DisconnectionEvent.cpp +++ b/src/libs/engine/events/DisconnectionEvent.cpp @@ -21,7 +21,7 @@ #include #include "Responder.hpp" #include "Engine.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "InputPort.hpp" #include "OutputPort.hpp" #include "Patch.hpp" @@ -157,15 +157,15 @@ DisconnectionEvent::execute(ProcessContext& context) QueuedEvent::execute(context); if (_error == NO_ERROR) { - Raul::ListNode* const port_connection + Raul::ListNode* const port_connection = _dst_input_port->remove_connection(_src_output_port); if (port_connection != NULL) { - Raul::ListNode* const patch_connection + Raul::ListNode* const patch_connection = _patch->remove_connection(_src_port, _dst_port); assert(patch_connection); - assert((Connection*)port_connection->elem() == patch_connection->elem()); + assert((ConnectionImpl*)port_connection->elem() == patch_connection->elem()); // Clean up both the list node and the connection itself... _engine.maid()->push(port_connection); diff --git a/src/libs/engine/events/DisconnectionEvent.hpp b/src/libs/engine/events/DisconnectionEvent.hpp index aacb5082..603eaf47 100644 --- a/src/libs/engine/events/DisconnectionEvent.hpp +++ b/src/libs/engine/events/DisconnectionEvent.hpp @@ -33,10 +33,9 @@ namespace Ingen { class Patch; class NodeImpl; -class Connection; +class ConnectionImpl; class MidiMessage; class PortImpl; -class Connection; class InputPort; class OutputPort; class CompiledPatch; diff --git a/src/libs/engine/events/SetPolyphonicEvent.cpp b/src/libs/engine/events/SetPolyphonicEvent.cpp index 8cca2373..51ab2dc8 100644 --- a/src/libs/engine/events/SetPolyphonicEvent.cpp +++ b/src/libs/engine/events/SetPolyphonicEvent.cpp @@ -25,7 +25,7 @@ #include "ObjectStore.hpp" #include "PortImpl.hpp" #include "NodeImpl.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "QueuedEventSource.hpp" namespace Ingen { diff --git a/src/libs/engine/events/SetPolyphonyEvent.cpp b/src/libs/engine/events/SetPolyphonyEvent.cpp index 8e0d12cd..56e95486 100644 --- a/src/libs/engine/events/SetPolyphonyEvent.cpp +++ b/src/libs/engine/events/SetPolyphonyEvent.cpp @@ -25,7 +25,7 @@ #include "ObjectStore.hpp" #include "PortImpl.hpp" #include "NodeImpl.hpp" -#include "Connection.hpp" +#include "ConnectionImpl.hpp" #include "QueuedEventSource.hpp" namespace Ingen { diff --git a/src/libs/gui/Connection.hpp b/src/libs/gui/Connection.hpp index f6072068..55378891 100644 --- a/src/libs/gui/Connection.hpp +++ b/src/libs/gui/Connection.hpp @@ -15,8 +15,8 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef CONNECTION_H -#define CONNECTION_H +#ifndef GUI_CONNECTION_H +#define GUI_CONNECTION_H #include #include @@ -57,4 +57,4 @@ private: } // namespace GUI } // namespace Ingen -#endif // CONNECTION_H +#endif // GUI_CONNECTION_H diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index e2e176cb..bbff476f 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -310,7 +310,7 @@ PatchCanvas::connection(SharedPtr cm) const SharedPtr dst = get_port_view(cm->dst_port()); if (src && dst) - add_connection(boost::shared_ptr(new Connection(shared_from_this(), + add_connection(boost::shared_ptr(new GUI::Connection(shared_from_this(), cm, src, dst, src->color() + 0x22222200))); else cerr << "[PatchCanvas] ERROR: Unable to find ports to connect " -- cgit v1.2.1