From 58e8d1cddd520ae0ddf39f16210f1500868a2b2e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 14 Aug 2008 04:03:14 +0000 Subject: Lock RDF world mutex in all places slv2 or redland is accessed (fix random segfaults usually on patch loading). git-svn-id: http://svn.drobilla.net/lad/ingen@1367 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/ConnectionImpl.cpp | 3 +++ src/libs/engine/InputPort.cpp | 26 +++++++++++++++++++++++++- src/libs/engine/InputPort.hpp | 1 + src/libs/engine/LADSPANode.cpp | 6 ++---- src/libs/engine/LV2Node.cpp | 4 +--- src/libs/engine/NodeBase.cpp | 29 +++++++++++++++++++++++------ src/libs/engine/PatchImpl.cpp | 3 --- src/libs/engine/PortImpl.cpp | 6 ++++-- 8 files changed, 59 insertions(+), 19 deletions(-) (limited to 'src/libs/engine') diff --git a/src/libs/engine/ConnectionImpl.cpp b/src/libs/engine/ConnectionImpl.cpp index a6f573a8..d226b4dd 100644 --- a/src/libs/engine/ConnectionImpl.cpp +++ b/src/libs/engine/ConnectionImpl.cpp @@ -92,6 +92,8 @@ ConnectionImpl::set_buffer_size(size_t size) void ConnectionImpl::prepare_poly(uint32_t poly) { + _src_port->prepare_poly(poly); + if (type() == DataType::CONTROL || type() == DataType::AUDIO) _must_mix = (poly > 1) && ( (_src_port->poly() != _dst_port->poly()) @@ -110,6 +112,7 @@ ConnectionImpl::prepare_poly(uint32_t poly) void ConnectionImpl::apply_poly(Raul::Maid& maid, uint32_t poly) { + _src_port->apply_poly(maid, poly); if (poly == 1 && _local_buffer && !_must_mix) { maid.push(_local_buffer); _local_buffer = NULL; diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index b778579d..cf5501ca 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -56,6 +56,19 @@ InputPort::set_buffer_size(size_t size) } +bool +InputPort::prepare_poly(uint32_t poly) +{ + PortImpl::prepare_poly(poly); + + for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c) + ((ConnectionImpl*)c->get())->prepare_poly(poly); + + connect_buffers(); + return true; +} + + bool InputPort::apply_poly(Raul::Maid& maid, uint32_t poly) { @@ -65,7 +78,18 @@ InputPort::apply_poly(Raul::Maid& maid, uint32_t poly) for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c) ((ConnectionImpl*)c->get())->apply_poly(maid, poly); - return PortImpl::apply_poly(maid, poly); + PortImpl::apply_poly(maid, poly); + assert(this->poly() == poly); + + if (_connections.size() == 1) { + ConnectionImpl* c = _connections.begin()->get(); + for (uint32_t i=0; i < _poly; ++i) + _buffers->at(i)->join(c->buffer(i)); + } + + connect_buffers(); + + return true; } diff --git a/src/libs/engine/InputPort.hpp b/src/libs/engine/InputPort.hpp index ffba2a30..2617882f 100644 --- a/src/libs/engine/InputPort.hpp +++ b/src/libs/engine/InputPort.hpp @@ -64,6 +64,7 @@ public: const Connections& connections() { return _connections; } + bool prepare_poly(uint32_t poly); bool apply_poly(Raul::Maid& maid, uint32_t poly); void pre_process(ProcessContext& context); diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp index e922de7c..83c3d6af 100644 --- a/src/libs/engine/LADSPANode.cpp +++ b/src/libs/engine/LADSPANode.cpp @@ -99,9 +99,7 @@ LADSPANode::apply_poly(Raul::Maid& maid, uint32_t poly) assert(poly <= _instances->size()); _polyphony = poly; - NodeBase::apply_poly(maid, poly); - - return true; + return NodeBase::apply_poly(maid, poly); } @@ -272,7 +270,7 @@ void LADSPANode::process(ProcessContext& context) { NodeBase::pre_process(context); - + for (uint32_t i=0; i < _polyphony; ++i) _descriptor->run((*_instances)[i], context.nframes()); diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp index 59d30c7e..974c5858 100644 --- a/src/libs/engine/LV2Node.cpp +++ b/src/libs/engine/LV2Node.cpp @@ -108,9 +108,7 @@ LV2Node::apply_poly(Raul::Maid& maid, uint32_t poly) assert(poly <= _instances->size()); _polyphony = poly; - NodeBase::apply_poly(maid, poly); - - return true; + return NodeBase::apply_poly(maid, poly); } diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp index a6bfa9ce..f8891f68 100644 --- a/src/libs/engine/NodeBase.cpp +++ b/src/libs/engine/NodeBase.cpp @@ -122,9 +122,14 @@ NodeBase::apply_poly(Raul::Maid& maid, uint32_t poly) if (!_polyphonic) return true; - if (_ports) - for (size_t i=0; i < _ports->size(); ++i) - _ports->at(i)->apply_poly(maid, poly); + for (size_t i=0; i < num_ports(); ++i) { + _ports->at(i)->apply_poly(maid, poly); + assert(_ports->at(i)->poly() == poly); + } + + for (uint32_t i=0; i < num_ports(); ++i) + for (uint32_t j=0; j < _polyphony; ++j) + set_port_buffer(j, i, _ports->at(i)->buffer(j)); return true; } @@ -202,9 +207,21 @@ NodeBase::pre_process(ProcessContext& context) assert(ThreadManager::current_thread_id() == THREAD_PROCESS); // Mix down any ports with multiple inputs - if (_ports) - for (size_t i=0; i < _ports->size(); ++i) - _ports->at(i)->pre_process(context); + for (size_t i=0; i < num_ports(); ++i) + _ports->at(i)->pre_process(context); + + // Connect port buffers (FIXME: NOT NECESSARY!) + if (polyphonic()) { + for (uint32_t i=0; i < _polyphony; ++i) { + for (uint32_t j=0; j < num_ports(); ++j) { + assert(_ports->at(j)->poly() == _polyphony); + set_port_buffer(i, j, _ports->at(j)->buffer(i)); + } + } + } else { + for (uint32_t j=0; j < num_ports(); ++j) + set_port_buffer(0, j, _ports->at(j)->buffer(0)); + } } diff --git a/src/libs/engine/PatchImpl.cpp b/src/libs/engine/PatchImpl.cpp index 2d33dd0d..aedaacbf 100644 --- a/src/libs/engine/PatchImpl.cpp +++ b/src/libs/engine/PatchImpl.cpp @@ -123,9 +123,6 @@ PatchImpl::apply_internal_poly(Raul::Maid& maid, uint32_t poly) for (List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) (*i)->apply_poly(maid, poly); - for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i) - PtrCast(*i)->apply_poly(maid, poly); - _internal_poly = poly; return true; diff --git a/src/libs/engine/PortImpl.cpp b/src/libs/engine/PortImpl.cpp index 9061ffc5..9b609323 100644 --- a/src/libs/engine/PortImpl.cpp +++ b/src/libs/engine/PortImpl.cpp @@ -58,6 +58,8 @@ PortImpl::PortImpl(NodeImpl* const node, if (node->parent() == NULL) _polyphonic = false; + else + _polyphonic = true; if (type == DataType::EVENT) _broadcast = true; // send activity blips @@ -117,8 +119,8 @@ PortImpl::apply_poly(Raul::Maid& maid, uint32_t poly) } _poly = poly; - - connect_buffers(); + assert(_buffers->size() >= poly); + assert(this->poly() == poly); return true; } -- cgit v1.2.1