From a603f4a917bd5a7d806ff8394e2bfbe0f64acc64 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 21 Jun 2006 03:27:16 +0000 Subject: Got the audio flowing git-svn-id: http://svn.drobilla.net/lad/grauph@70 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/Buffer.cpp | 30 +++++++++-- src/libs/engine/Buffer.h | 5 +- src/libs/engine/Connection.cpp | 1 - src/libs/engine/Connection.h | 1 - src/libs/engine/DSSIPlugin.h.orig | 84 ------------------------------ src/libs/engine/DataType.h | 3 +- src/libs/engine/DuplexPort.cpp | 1 + src/libs/engine/GraphObject.h | 4 +- src/libs/engine/InputPort.cpp | 13 +++-- src/libs/engine/JackAudioDriver.cpp | 29 +++++++---- src/libs/engine/JackAudioDriver.h | 7 +-- src/libs/engine/LADSPANode.cpp | 3 +- src/libs/engine/List.h | 6 +-- src/libs/engine/Patch.cpp | 23 ++++++-- src/libs/engine/TypedConnection.cpp | 14 +++-- src/libs/engine/TypedConnection.h | 4 +- src/libs/engine/TypedPort.cpp | 11 +--- src/libs/engine/TypedPort.h | 2 +- src/libs/engine/events/AddPortEvent.cpp | 41 ++++++++++----- src/libs/engine/events/AddPortEvent.h | 16 ++---- src/libs/engine/events/ConnectionEvent.cpp | 8 ++- 21 files changed, 143 insertions(+), 163 deletions(-) delete mode 100644 src/libs/engine/DSSIPlugin.h.orig (limited to 'src') diff --git a/src/libs/engine/Buffer.cpp b/src/libs/engine/Buffer.cpp index 4e94a943..9d88f806 100644 --- a/src/libs/engine/Buffer.cpp +++ b/src/libs/engine/Buffer.cpp @@ -180,7 +180,7 @@ Buffer::copy(const Buffer* src, size_t start_sample, size_t end_sample) assert(src->data() != NULL); assert(m_data != NULL); - const T* const src_data = src->data(); + register const T* const src_data = src->data(); for (size_t i=start_sample; i <= end_sample; ++i) m_data[i] = src_data[i]; @@ -205,7 +205,7 @@ Buffer::accumulate(const Buffer* const src, size_t start_sample, size_t en assert(src->data() != NULL); assert(m_data != NULL); - const T* const src_data = src->data(); + register const T* const src_data = src->data(); for (size_t i=start_sample; i <= end_sample; ++i) m_data[i] += src_data[i]; @@ -267,8 +267,30 @@ Buffer::prepare(samplecount nframes) } -////// DriverBuffer //////// +template<> +void +Buffer::prepare(samplecount nframes) +{ +} + + +/** Set the buffer (data) used. + * + * This is only to be used by Drivers (to provide zero-copy processing). + */ +template +void +Buffer::set_data(T* data) +{ + assert(!m_is_joined); + m_data = data; +} +template void Buffer::set_data(sample* data); +template void Buffer::set_data(MidiMessage* data); + +////// DriverBuffer //////// +#if 0 template DriverBuffer::DriverBuffer(size_t size) : Buffer(size) @@ -293,6 +315,6 @@ DriverBuffer::set_data(T* data) } template void DriverBuffer::set_data(sample* data); template void DriverBuffer::set_data(MidiMessage* data); - +#endif } // namespace Om diff --git a/src/libs/engine/Buffer.h b/src/libs/engine/Buffer.h index 1f5ad1dd..41cab494 100644 --- a/src/libs/engine/Buffer.h +++ b/src/libs/engine/Buffer.h @@ -40,6 +40,9 @@ public: void join(Buffer* buf); void unjoin(); + /** For driver use only!! */ + void set_data(T* data); + inline T& value_at(size_t offset) { assert(offset < m_size); return m_data[offset]; } void prepare(samplecount nframes); @@ -78,7 +81,7 @@ class DriverBuffer : public Buffer public: DriverBuffer(size_t size); - void set_data(T* data); + private: using Buffer::m_data; diff --git a/src/libs/engine/Connection.cpp b/src/libs/engine/Connection.cpp index d1592009..ad0cb486 100644 --- a/src/libs/engine/Connection.cpp +++ b/src/libs/engine/Connection.cpp @@ -31,7 +31,6 @@ namespace Om { Connection::Connection(Port* const src_port, Port* const dst_port) : m_src_port(src_port), m_dst_port(dst_port), - m_is_poly_to_mono( (src_port->parent_node()->poly() > dst_port->parent_node()->poly()) ), m_pending_disconnection(false) { assert(src_port != NULL); diff --git a/src/libs/engine/Connection.h b/src/libs/engine/Connection.h index a0c43f89..b7b17a0a 100644 --- a/src/libs/engine/Connection.h +++ b/src/libs/engine/Connection.h @@ -56,7 +56,6 @@ protected: Port* const m_src_port; Port* const m_dst_port; - bool m_is_poly_to_mono; bool m_pending_disconnection; }; diff --git a/src/libs/engine/DSSIPlugin.h.orig b/src/libs/engine/DSSIPlugin.h.orig deleted file mode 100644 index 816c65a7..00000000 --- a/src/libs/engine/DSSIPlugin.h.orig +++ /dev/null @@ -1,84 +0,0 @@ -/* This file is part of Om. Copyright (C) 2005 Dave Robillard. - * - * Om 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. - * - * Om 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., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DSSIPLUGIN_H -#define DSSIPLUGIN_H - -#include -#include -#include "LADSPAPlugin.h" - -namespace Om { - -class MidiMessage; -template class InputPort; - - -/** An instance of a DSSI plugin. - */ -class DSSIPlugin : public LADSPAPlugin -{ -public: - DSSIPlugin(const string& name, uint poly, Patch* parent, DSSI_Descriptor* descriptor, samplerate srate, size_t buffer_size); - ~DSSIPlugin(); - - void activate(); - - void set_ui_url(const string& url); - void send_update(); - - void set_control(uint port_num, sample val); - void configure(const string& key, const string& val); - void program(int bank, int program); - - void run(size_t nframes); - - const Plugin* const plugin() const { return m_plugin; } - void plugin(const Plugin* const pi) { m_plugin = pi; } - -private: - // Prevent copies - DSSIPlugin(const DSSIPlugin& copy) : LADSPAPlugin(copy) { exit(EXIT_FAILURE); } - DSSIPlugin& operator=(const DSSIPlugin& copy) { exit(EXIT_FAILURE); } - - // DSSI GUI messages - void send_control(int port_num, float value); - void send_program(int bank, int value); - void send_configure(const string& key, const string& val); - void send_show(); - void send_hide(); - void send_quit(); - - string m_ui_url; - string m_ui_base_path; - lo_address m_ui_addr; - - // Current values - int m_bank; - int m_program; - map m_configures; - - DSSI_Descriptor* m_dssi_descriptor; - - InputPort* m_midi_in_port; -}; - - -} // namespace Om - - -#endif // DSSIPLUGIN_H - diff --git a/src/libs/engine/DataType.h b/src/libs/engine/DataType.h index acb6990b..bd43a8a7 100644 --- a/src/libs/engine/DataType.h +++ b/src/libs/engine/DataType.h @@ -49,7 +49,8 @@ public: : _symbol(symbol) {} - const char* const uri() const { return type_uris[_symbol]; } + const char* const uri() const { return type_uris[_symbol]; } + const Symbol& symbol() const { return _symbol; } inline bool operator==(const Symbol& symbol) const { return (_symbol == symbol); } inline bool operator!=(const Symbol& symbol) const { return (_symbol != symbol); } diff --git a/src/libs/engine/DuplexPort.cpp b/src/libs/engine/DuplexPort.cpp index 27be5056..4478d90c 100644 --- a/src/libs/engine/DuplexPort.cpp +++ b/src/libs/engine/DuplexPort.cpp @@ -37,6 +37,7 @@ DuplexPort::DuplexPort(Node* parent, const string& name, size_t index, size_t , OutputPort(parent, name, index, poly, type, buffer_size) , _is_output(is_output) { + assert(TypedPort::_parent == parent); } template DuplexPort::DuplexPort(Node* parent, const string& name, size_t index, size_t poly, DataType type, size_t buffer_size, bool is_output); template DuplexPort::DuplexPort(Node* parent, const string& name, size_t index, size_t poly, DataType type, size_t buffer_size, bool is_output); diff --git a/src/libs/engine/GraphObject.h b/src/libs/engine/GraphObject.h index cf46f895..ffe6076b 100644 --- a/src/libs/engine/GraphObject.h +++ b/src/libs/engine/GraphObject.h @@ -48,8 +48,8 @@ public: : _parent(parent), _name(name) { assert(parent == NULL || _name.length() > 0); - assert(parent == NULL || _name.find("/") == string::npos); - assert(((string)path()).find("//") == string::npos); + assert(_name.find("/") == string::npos); + assert(path().find("//") == string::npos); } virtual ~GraphObject() {} diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index 960972e5..ab7ca562 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -235,12 +235,14 @@ InputPort::process(samplecount nframes) m_buffers.at(0)->join((*m_connections.begin())->buffer(0)); do_mixdown = false; } + update_buffers(); } else { do_mixdown = false; } - update_buffers(); } + //cerr << path() << " mixing: " << do_mixdown << endl; + if (!do_mixdown) { assert(m_buffers.at(0)->data() == (*m_connections.begin())->buffer(0)->data()); return; @@ -250,13 +252,14 @@ InputPort::process(samplecount nframes) assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data());*/ for (size_t voice=0; voice < _poly; ++voice) { + // Copy first connection m_buffers.at(voice)->copy((*m_connections.begin())->buffer(voice), 0, _buffer_size-1); + // Accumulate the rest if (m_connections.size() > 1) { - // Copy first connection + TypedConnectionListIterator c = m_connections.begin(); - - // Add all other connections + for (++c; c != m_connections.end(); ++c) m_buffers.at(voice)->accumulate((*c)->buffer(voice), 0, _buffer_size-1); } @@ -271,7 +274,7 @@ InputPort::process(samplecount nframes) template <> void InputPort::process(samplecount nframes) -{ +{ //assert(!m_is_tied || m_tied_port != NULL); const size_t num_ins = m_connections.size(); diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp index 59e30e5c..39747f9a 100644 --- a/src/libs/engine/JackAudioDriver.cpp +++ b/src/libs/engine/JackAudioDriver.cpp @@ -51,6 +51,7 @@ JackAudioPort::JackAudioPort(JackAudioDriver* driver, DuplexPort* patch_ m_driver(driver), m_jack_port(NULL), m_jack_buffer(NULL), + //m_jack_buffer(NULL), m_patch_port(patch_port) { //assert(patch_port->tied_port() != NULL); @@ -61,7 +62,7 @@ JackAudioPort::JackAudioPort(JackAudioDriver* driver, DuplexPort* patch_ (patch_port->is_input()) ? JackPortIsInput : JackPortIsOutput, 0); - m_jack_buffer = new DriverBuffer(driver->buffer_size()); + //m_jack_buffer = new DriverBuffer(driver->buffer_size()); patch_port->fixed_buffers(true); } @@ -89,22 +90,32 @@ JackAudioPort::remove_from_driver() void JackAudioPort::prepare_buffer(jack_nframes_t nframes) { - // Technically this doesn't need to be done every time for output ports - m_jack_buffer->set_data((jack_default_audio_sample_t*) + // FIXME: Technically this doesn't need to be done every time for output ports + /*m_jack_buffer->set_data((jack_default_audio_sample_t*) jack_port_get_buffer(m_jack_port, nframes)); + m_patch_port->buffer(0)->join(m_jack_buffer); +*/ + jack_sample_t* jack_buf = (jack_sample_t*)jack_port_get_buffer(m_jack_port, nframes); + + if (jack_buf != m_jack_buffer) { + //cerr << "Jack buffer: " << jack_buf << endl; + m_patch_port->buffer(0)->set_data(jack_buf); + m_jack_buffer = jack_buf; + } + //assert(m_patch_port->tied_port() != NULL); - // FIXME: fixed_buffers switch on/off thing can be removed once this shit + // FIXME: fixed_buffers switch on/off thing can be removed once this // gets figured out and assertions can go away - m_patch_port->fixed_buffers(false); - m_patch_port->buffer(0)->join(m_jack_buffer); + //m_patch_port->fixed_buffers(false); + //m_patch_port->buffer(0)->join(m_jack_buffer); //m_patch_port->tied_port()->buffer(0)->join(m_jack_buffer); - m_patch_port->fixed_buffers(true); + //m_patch_port->fixed_buffers(true); //assert(m_patch_port->buffer(0)->data() == m_patch_port->tied_port()->buffer(0)->data()); - assert(m_patch_port->buffer(0)->data() == m_jack_buffer->data()); + assert(m_patch_port->buffer(0)->data() == jack_buf); } @@ -329,7 +340,7 @@ JackAudioDriver::m_process_cb(jack_nframes_t nframes) // Run root patch assert(m_root_patch != NULL); m_root_patch->process(nframes); - + return 0; } diff --git a/src/libs/engine/JackAudioDriver.h b/src/libs/engine/JackAudioDriver.h index abb74825..89db2454 100644 --- a/src/libs/engine/JackAudioDriver.h +++ b/src/libs/engine/JackAudioDriver.h @@ -49,8 +49,8 @@ public: void prepare_buffer(jack_nframes_t nframes); jack_port_t* jack_port() const { return m_jack_port; } - DriverBuffer* buffer() const { return m_jack_buffer; } - void jack_buffer(jack_sample_t* s) { m_jack_buffer->set_data(s); } + //DriverBuffer* buffer() const { return m_jack_buffer; } + //void jack_buffer(jack_sample_t* s) { m_jack_buffer->set_data(s); } DuplexPort* patch_port() const { return m_patch_port; } private: @@ -60,7 +60,8 @@ private: JackAudioDriver* m_driver; jack_port_t* m_jack_port; - DriverBuffer* m_jack_buffer; + jack_sample_t* m_jack_buffer; ///< Cached for output ports + //DriverBuffer* m_jack_buffer; DuplexPort* m_patch_port; }; diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp index 1c36177c..7d39399d 100644 --- a/src/libs/engine/LADSPANode.cpp +++ b/src/libs/engine/LADSPANode.cpp @@ -185,9 +185,8 @@ LADSPANode::set_port_buffer(size_t voice, size_t port_num, void* buf) assert(voice < _poly); // Could be a MIDI port after this - if (port_num < _descriptor->PortCount) { + if (port_num < _descriptor->PortCount) _descriptor->connect_port(_instances[voice], port_num, (sample*)buf); - } } #if 0 diff --git a/src/libs/engine/List.h b/src/libs/engine/List.h index 68405eda..964bd8e2 100644 --- a/src/libs/engine/List.h +++ b/src/libs/engine/List.h @@ -136,10 +136,10 @@ private: List(const List& copy); List& operator=(const List& copy); - ListNode* m_head; - ListNode* m_tail; + ListNode* m_head; + ListNode* m_tail; size_t m_size; - iterator m_end_iter; + iterator m_end_iter; const_iterator m_const_end_iter; }; diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp index 8a8ca60a..634b3bbd 100644 --- a/src/libs/engine/Patch.cpp +++ b/src/libs/engine/Patch.cpp @@ -348,14 +348,14 @@ Patch::remove_port(const Port* port) Array* Patch::build_process_order() const { - Node* node = NULL; Array* const process_order = new Array(_nodes.size()); + // FIXME: tweak algorithm so it just ends up like this and save the iteration? for (List::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i) (*i)->traversed(false); // Traverse backwards starting at outputs - for (List::const_iterator p = _output_ports.begin(); p != _output_ports.end(); ++p) { + //for (List::const_iterator p = _output_ports.begin(); p != _output_ports.end(); ++p) { /*const Port* const port = (*p); for (List::const_iterator c = port->connections().begin(); @@ -366,16 +366,31 @@ Patch::build_process_order() const assert(connection->src_port()->parent_node()); build_process_order_recursive(connection->src_port()->parent_node(), process_order); }*/ - } + //} + // Add any (disjoint) nodes that weren't hit by the traversal - for (List::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i) { + /*for (List::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i) { node = (*i); if ( ! node->traversed()) { process_order->push_back(*i); node->traversed(true); } + }*/ + + for (List::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i) { + Node* const node = (*i); + // Either a sink or connected to our output ports: + if ( (!node->traversed()) && node->dependants()->size() == 0) + build_process_order_recursive(node, process_order); + } + + cerr << "----------------------------------------\n"; + for (size_t i=0; i < process_order->size(); ++i) { + assert(process_order->at(i)); + cerr << process_order->at(i)->path() << endl; } + cerr << "----------------------------------------\n"; assert(process_order->size() == _nodes.size()); diff --git a/src/libs/engine/TypedConnection.cpp b/src/libs/engine/TypedConnection.cpp index 94806f85..66c3a244 100644 --- a/src/libs/engine/TypedConnection.cpp +++ b/src/libs/engine/TypedConnection.cpp @@ -34,15 +34,20 @@ template TypedConnection::TypedConnection(OutputPort* const src_port, InputPort* const dst_port) : Connection(src_port, dst_port), m_local_buffer(NULL), - m_is_poly_to_mono( (src_port->parent_node()->poly() > dst_port->parent_node()->poly()) ), + m_must_mix(true), m_buffer_size(src_port->buffer_size()), m_pending_disconnection(false) { assert((src_port->parent_node()->poly() == dst_port->parent_node()->poly()) || (src_port->parent_node()->poly() == 1 || dst_port->parent_node()->poly() == 1)); - if (m_is_poly_to_mono) // Poly -> Mono connection, need a buffer to mix in to + if (src_port->poly() == dst_port->poly()) + m_must_mix = false; + else // Poly -> Mono connection, need a buffer to mix into m_local_buffer = new Buffer(m_buffer_size); + + //cerr << "Connection " << src_port->path() << " -> " << dst_port->path() + // << "\t mixing: " << m_must_mix << endl; } template TypedConnection::TypedConnection(OutputPort* const src_port, InputPort* const dst_port); template TypedConnection::TypedConnection(OutputPort* const src_port, InputPort* const dst_port); @@ -71,7 +76,10 @@ TypedConnection::process(samplecount nframes) * would avoid having to mix multiple times. Probably not a very common * case, but it would be faster anyway. */ - if (m_is_poly_to_mono) { + if (m_must_mix) { + //cerr << "Mixing " << src_port()->buffer(0)->data() + // << " -> " << m_local_buffer->data() << endl; + m_local_buffer->copy(src_port()->buffer(0), 0, m_buffer_size-1); // Mix all the source's voices down into local buffer starting at the second diff --git a/src/libs/engine/TypedConnection.h b/src/libs/engine/TypedConnection.h index c75ece6e..9bd339bb 100644 --- a/src/libs/engine/TypedConnection.h +++ b/src/libs/engine/TypedConnection.h @@ -61,7 +61,7 @@ private: TypedConnection& operator=(const TypedConnection&); Buffer* m_local_buffer; ///< Only used for poly->mono connections - bool m_is_poly_to_mono; + bool m_must_mix; size_t m_buffer_size; bool m_pending_disconnection; }; @@ -73,7 +73,7 @@ TypedConnection::buffer(size_t voice) const { TypedPort* const src_port = (TypedPort*)m_src_port; - if (m_is_poly_to_mono) { + if (m_must_mix) { return m_local_buffer; } else { if (src_port->poly() == 1) diff --git a/src/libs/engine/TypedPort.cpp b/src/libs/engine/TypedPort.cpp index a5d954c6..fdbd7956 100644 --- a/src/libs/engine/TypedPort.cpp +++ b/src/libs/engine/TypedPort.cpp @@ -98,21 +98,14 @@ template void TypedPort::allocate_buffers(); template void TypedPort::allocate_buffers(); -/* -template<> +template void -TypedPort::process(samplecount nframes) +TypedPort::process(samplecount nframes) { for (size_t i=0; i < _poly; ++i) m_buffers.at(i)->prepare(nframes); } -template<> -void -TypedPort::process(samplecount nframes) -{ -} -*/ template void diff --git a/src/libs/engine/TypedPort.h b/src/libs/engine/TypedPort.h index 1fd51fb0..bcfad10a 100644 --- a/src/libs/engine/TypedPort.h +++ b/src/libs/engine/TypedPort.h @@ -49,7 +49,7 @@ public: Buffer* buffer(size_t voice) const { return m_buffers.at(voice); } - virtual void process(samplecount nframes) {} + virtual void process(samplecount nframes); virtual void clear_buffers(); //TypedPort* tied_port() const { return m_tied_port; } diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp index 0318c5c0..43cc797a 100644 --- a/src/libs/engine/events/AddPortEvent.cpp +++ b/src/libs/engine/events/AddPortEvent.cpp @@ -29,7 +29,10 @@ #include "util/Path.h" #include "Port.h" #include "AudioDriver.h" +#include "MidiDriver.h" #include "List.h" +#include "Driver.h" +#include "DuplexPort.h" namespace Om { @@ -41,7 +44,8 @@ AddPortEvent::AddPortEvent(CountedPtr responder, const string& path, _is_output(is_output), _data_type(DataType::UNKNOWN), _patch(NULL), - _port(NULL), + _patch_port(NULL), + _driver_port(NULL), _succeeded(true) { string type_str; @@ -52,11 +56,6 @@ AddPortEvent::AddPortEvent(CountedPtr responder, const string& path, } -AddPortEvent::~AddPortEvent() -{ -} - - void AddPortEvent::pre_process() { @@ -65,6 +64,8 @@ AddPortEvent::pre_process() return; } + // FIXME: this is just a mess :/ + _patch = om->object_store()->find_patch(_path.parent()); if (_patch != NULL) { @@ -74,15 +75,24 @@ AddPortEvent::pre_process() if (_type == "AUDIO" || _type == "MIDI") buffer_size = om->audio_driver()->buffer_size(); - _port = _patch->create_port(_path.name(), _data_type, buffer_size, _is_output); - if (_port) { + _patch_port = _patch->create_port(_path.name(), _data_type, buffer_size, _is_output); + if (_patch_port) { if (_is_output) - _patch->add_output(new ListNode(_port)); + _patch->add_output(new ListNode(_patch_port)); else - _patch->add_input(new ListNode(_port)); + _patch->add_input(new ListNode(_patch_port)); _ports_array = new Array(_patch->num_ports() + 1, _patch->external_ports()); - _ports_array->at(_patch->num_ports()) = _port; - om->object_store()->add(_port); + _ports_array->at(_patch->num_ports()) = _patch_port; + om->object_store()->add(_patch_port); + + if (!_patch->parent()) { + if (_type == "AUDIO") + _driver_port = om->audio_driver()->create_port( + dynamic_cast*>(_patch_port)); + else if (_type == "MIDI") + _driver_port = om->midi_driver()->create_port( + dynamic_cast*>(_patch_port)); + } } } QueuedEvent::pre_process(); @@ -94,11 +104,14 @@ AddPortEvent::execute(samplecount offset) { QueuedEvent::execute(offset); - if (_port) { + if (_patch_port) { om->maid()->push(_patch->external_ports()); //_patch->add_port(_port); _patch->external_ports(_ports_array); } + + if (_driver_port) + _driver_port->add_to_driver(); } @@ -110,7 +123,7 @@ AddPortEvent::post_process() m_responder->respond_error(msg); } else { m_responder->respond_ok(); - om->client_broadcaster()->send_port(_port); + om->client_broadcaster()->send_port(_patch_port); } } diff --git a/src/libs/engine/events/AddPortEvent.h b/src/libs/engine/events/AddPortEvent.h index 6ebe262c..b0913719 100644 --- a/src/libs/engine/events/AddPortEvent.h +++ b/src/libs/engine/events/AddPortEvent.h @@ -31,6 +31,7 @@ namespace Om { class Patch; class Port; class Plugin; +class DriverPort; /** An event to add a Port to a Patch. @@ -41,7 +42,6 @@ class AddPortEvent : public QueuedEvent { public: AddPortEvent(CountedPtr responder, const string& path, const string& type, bool is_output); - ~AddPortEvent(); void pre_process(); void execute(samplecount offset); @@ -53,18 +53,10 @@ private: bool _is_output; DataType _data_type; Patch* _patch; - Port* _port; - Array* _ports_array; // New (external) ports array for Patch + Port* _patch_port; + Array* _ports_array; ///< New (external) ports array for Patch + DriverPort* _driver_port; ///< Driver (eg Jack) port if this is a toplevel port bool _succeeded; - /* - string m_patch_name; - Path m_path; - Plugin* m_plugin; - bool m_poly; - Patch* m_patch; - Node* m_node; - Array* m_process_order; // Patch's new process order - bool m_node_already_exists;*/ }; diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp index 1d5b3ba1..74fa4e97 100644 --- a/src/libs/engine/events/ConnectionEvent.cpp +++ b/src/libs/engine/events/ConnectionEvent.cpp @@ -212,8 +212,12 @@ TypedConnectionEvent::pre_process() m_port_listnode = new ListNode*>(m_connection); m_patch_listnode = new ListNode(m_connection); - dst_node->providers()->push_back(new ListNode(src_node)); - src_node->dependants()->push_back(new ListNode(dst_node)); + // Need to be careful about patch port connections here and adding a node's + // parent as a dependant/provider... + if (src_node->parent() == dst_node->parent()) { + dst_node->providers()->push_back(new ListNode(src_node)); + src_node->dependants()->push_back(new ListNode(dst_node)); + } if (m_patch->process()) m_process_order = m_patch->build_process_order(); -- cgit v1.2.1