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/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 +- 23 files changed, 336 insertions(+), 334 deletions(-) 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/libs/engine') 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 { -- cgit v1.2.1