From 2db1897709eba0e80677bd09e8444e7320e15120 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 19 Jun 2006 06:17:49 +0000 Subject: Connecting of patch ports internally (seemingly anyway, data not flowing yet) git-svn-id: http://svn.drobilla.net/lad/grauph@61 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/InputPort.cpp | 101 +++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 50 deletions(-) (limited to 'src/libs/engine/InputPort.cpp') diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index 0e7a349d..752efde4 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -18,7 +18,7 @@ #include #include #include -#include "ConnectionBase.h" +#include "TypedConnection.h" #include "OutputPort.h" #include "Node.h" #include "Om.h" @@ -46,21 +46,21 @@ template InputPort::InputPort(Node* parent, const string& name, siz */ template void -InputPort::add_connection(ListNode*>* const c) +InputPort::add_connection(ListNode*>* const c) { m_connections.push_back(c); bool modify_buffers = !m_fixed_buffers; - if (modify_buffers && m_is_tied) - modify_buffers = !m_tied_port->fixed_buffers(); + //if (modify_buffers && m_is_tied) + // modify_buffers = !m_tied_port->fixed_buffers(); if (modify_buffers) { if (m_connections.size() == 1) { // Use buffer directly to avoid copying for (size_t i=0; i < _poly; ++i) { m_buffers.at(i)->join(c->elem()->buffer(i)); - if (m_is_tied) - m_tied_port->buffer(i)->join(m_buffers.at(i)); + //if (m_is_tied) + // m_tied_port->buffer(i)->join(m_buffers.at(i)); assert(m_buffers.at(i)->data() == c->elem()->buffer(i)->data()); } } else if (m_connections.size() == 2) { @@ -68,34 +68,34 @@ InputPort::add_connection(ListNode*>* const c) // so have to use local ones again and mix down for (size_t i=0; i < _poly; ++i) { m_buffers.at(i)->unjoin(); - if (m_is_tied) - m_tied_port->buffer(i)->join(m_buffers.at(i)); + //if (m_is_tied) + // m_tied_port->buffer(i)->join(m_buffers.at(i)); } } update_buffers(); } - assert( ! m_is_tied || m_tied_port != NULL); - assert( ! m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); + //assert( ! m_is_tied || m_tied_port != NULL); + //assert( ! m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); } -template void InputPort::add_connection(ListNode*>* const c); -template void InputPort::add_connection(ListNode*>* const c); +template void InputPort::add_connection(ListNode*>* const c); +template void InputPort::add_connection(ListNode*>* const c); /** Remove a connection. Realtime safe. */ template -ListNode*>* +ListNode*>* InputPort::remove_connection(const OutputPort* const src_port) { bool modify_buffers = !m_fixed_buffers; - if (modify_buffers && m_is_tied) - modify_buffers = !m_tied_port->fixed_buffers(); + //if (modify_buffers && m_is_tied) + // modify_buffers = !m_tied_port->fixed_buffers(); - typedef typename List*>::iterator ConnectionBaseListIterator; + typedef typename List*>::iterator TypedConnectionListIterator; bool found = false; - ListNode*>* connection = NULL; - for (ConnectionBaseListIterator i = m_connections.begin(); i != m_connections.end(); ++i) { + ListNode*>* connection = NULL; + for (TypedConnectionListIterator i = m_connections.begin(); i != m_connections.end(); ++i) { if ((*i)->src_port()->path() == src_port->path()) { connection = m_connections.remove(i); found = true; @@ -112,15 +112,15 @@ InputPort::remove_connection(const OutputPort* const src_port) if (modify_buffers && m_buffers.at(i)->is_joined()) m_buffers.at(i)->unjoin(); m_buffers.at(i)->clear(); // Write silence - if (m_is_tied) - m_tied_port->buffer(i)->join(m_buffers.at(i)); + //if (m_is_tied) + //m_tied_port->buffer(i)->join(m_buffers.at(i)); } } else if (modify_buffers && m_connections.size() == 1) { // Share a buffer for (size_t i=0; i < _poly; ++i) { m_buffers.at(i)->join((*m_connections.begin())->buffer(i)); - if (m_is_tied) - m_tied_port->buffer(i)->join(m_buffers.at(i)); + //if (m_is_tied) + // m_tied_port->buffer(i)->join(m_buffers.at(i)); } } } @@ -128,14 +128,14 @@ InputPort::remove_connection(const OutputPort* const src_port) if (modify_buffers) update_buffers(); - assert( ! m_is_tied || m_tied_port != NULL); - assert( ! m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); + //assert( ! m_is_tied || m_tied_port != NULL); + //assert( ! m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); return connection; } -template ListNode*>* +template ListNode*>* InputPort::remove_connection(const OutputPort* const src_port); -template ListNode*>* +template ListNode*>* InputPort::remove_connection(const OutputPort* const src_port); @@ -161,8 +161,8 @@ template bool InputPort::is_connected_to(const OutputPort* const port) const { - typedef typename List*>::const_iterator ConnectionBaseListIterator; - for (ConnectionBaseListIterator i = m_connections.begin(); i != m_connections.end(); ++i) + typedef typename List*>::const_iterator TypedConnectionListIterator; + for (TypedConnectionListIterator i = m_connections.begin(); i != m_connections.end(); ++i) if ((*i)->src_port() == port) return true; @@ -177,6 +177,7 @@ template bool InputPort::is_connected_to(const OutputPort void InputPort::tie(OutputPort* const port) @@ -202,7 +203,7 @@ InputPort::tie(OutputPort* const port) } template void InputPort::tie(OutputPort* const port); template void InputPort::tie(OutputPort* const port); - +*/ /** Prepare buffer for access, mixing if necessary. Realtime safe. * FIXME: nframes parameter not used, @@ -211,21 +212,21 @@ template<> void InputPort::prepare_buffers(size_t nframes) { - assert(!m_is_tied || m_tied_port != NULL); + //assert(!m_is_tied || m_tied_port != NULL); - typedef List*>::iterator ConnectionBaseListIterator; + typedef List*>::iterator TypedConnectionListIterator; bool do_mixdown = true; if (m_connections.size() == 0) return; - for (ConnectionBaseListIterator c = m_connections.begin(); c != m_connections.end(); ++c) + for (TypedConnectionListIterator c = m_connections.begin(); c != m_connections.end(); ++c) (*c)->prepare_buffers(); // If only one connection, buffer is (maybe) used directly (no copying) if (m_connections.size() == 1) { // Buffer changed since connection if (m_buffers.at(0)->data() != (*m_connections.begin())->buffer(0)->data()) { - if (m_fixed_buffers || (m_is_tied && m_tied_port->fixed_buffers())) { + if (m_fixed_buffers) { // || (m_is_tied && m_tied_port->fixed_buffers())) { // can't change buffer, must copy do_mixdown = true; } else { @@ -245,15 +246,15 @@ InputPort::prepare_buffers(size_t nframes) return; } - assert(!m_is_tied || m_tied_port != NULL); - assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); + /*assert(!m_is_tied || m_tied_port != NULL); + assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data());*/ for (size_t voice=0; voice < _poly; ++voice) { m_buffers.at(voice)->copy((*m_connections.begin())->buffer(voice), 0, _buffer_size-1); if (m_connections.size() > 1) { // Copy first connection - ConnectionBaseListIterator c = m_connections.begin(); + TypedConnectionListIterator c = m_connections.begin(); // Add all other connections for (++c; c != m_connections.end(); ++c) @@ -271,17 +272,17 @@ template <> void InputPort::prepare_buffers(size_t nframes) { - assert(!m_is_tied || m_tied_port != NULL); + //assert(!m_is_tied || m_tied_port != NULL); const size_t num_ins = m_connections.size(); bool do_mixdown = true; assert(num_ins == 0 || num_ins == 1); - typedef List*>::iterator ConnectionBaseListIterator; + typedef List*>::iterator TypedConnectionListIterator; assert(_poly == 1); - for (ConnectionBaseListIterator c = m_connections.begin(); c != m_connections.end(); ++c) + for (TypedConnectionListIterator c = m_connections.begin(); c != m_connections.end(); ++c) (*c)->prepare_buffers(); @@ -289,24 +290,24 @@ InputPort::prepare_buffers(size_t nframes) if (num_ins == 1) { // Buffer changed since connection if (m_buffers.at(0) != (*m_connections.begin())->buffer(0)) { - if (m_fixed_buffers || (m_is_tied && m_tied_port->fixed_buffers())) { + if (m_fixed_buffers) { // || (m_is_tied && m_tied_port->fixed_buffers())) { // can't change buffer, must copy do_mixdown = true; } else { // zero-copy assert(m_buffers.at(0)->is_joined()); m_buffers.at(0)->join((*m_connections.begin())->buffer(0)); - if (m_is_tied) - m_tied_port->buffer(0)->join(m_buffers.at(0)); + //if (m_is_tied) + // m_tied_port->buffer(0)->join(m_buffers.at(0)); do_mixdown = false; } update_buffers(); } else { do_mixdown = false; } - assert(!m_is_tied || m_tied_port != NULL); - assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); - assert(!m_is_tied || m_buffers.at(0)->filled_size() == m_tied_port->buffer(0)->filled_size()); + //assert(!m_is_tied || m_tied_port != NULL); + //assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); + //assert(!m_is_tied || m_buffers.at(0)->filled_size() == m_tied_port->buffer(0)->filled_size()); assert(do_mixdown || m_buffers.at(0)->filled_size() == (*m_connections.begin())->src_port()->buffer(0)->filled_size()); } @@ -318,8 +319,8 @@ InputPort::prepare_buffers(size_t nframes) m_buffers.at(0)->filled_size( (*m_connections.begin())->src_port()->buffer(0)->filled_size()); - if (m_is_tied) - m_tied_port->buffer(0)->filled_size(m_buffers.at(0)->filled_size()); + //if (m_is_tied) + // m_tied_port->buffer(0)->filled_size(m_buffers.at(0)->filled_size()); assert(m_buffers.at(0)->filled_size() == (*m_connections.begin())->src_port()->buffer(0)->filled_size()); @@ -329,7 +330,7 @@ InputPort::prepare_buffers(size_t nframes) } } - assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); + //assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); if (!do_mixdown || m_buffers.at(0)->filled_size() == 0 || num_ins == 0) return; @@ -337,8 +338,8 @@ InputPort::prepare_buffers(size_t nframes) //cerr << path() << " - Copying MIDI buffer" << endl; // Be sure buffers are the same as tied port's, if joined - assert(!m_is_tied || m_tied_port != NULL); - assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); + //assert(!m_is_tied || m_tied_port != NULL); + //assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); if (num_ins > 0) for (size_t i=0; i < m_buffers.at(0)->filled_size(); ++i) -- cgit v1.2.1