summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-14 04:03:14 +0000
committerDavid Robillard <d@drobilla.net>2008-08-14 04:03:14 +0000
commit58e8d1cddd520ae0ddf39f16210f1500868a2b2e (patch)
tree3da3105ec9c526f36352295b6d75c390e05c26b5 /src/libs/engine
parent2ad7b1dab1cbbc9a35fe84ce784179d78fba3a29 (diff)
downloadingen-58e8d1cddd520ae0ddf39f16210f1500868a2b2e.tar.gz
ingen-58e8d1cddd520ae0ddf39f16210f1500868a2b2e.tar.bz2
ingen-58e8d1cddd520ae0ddf39f16210f1500868a2b2e.zip
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
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/ConnectionImpl.cpp3
-rw-r--r--src/libs/engine/InputPort.cpp26
-rw-r--r--src/libs/engine/InputPort.hpp1
-rw-r--r--src/libs/engine/LADSPANode.cpp6
-rw-r--r--src/libs/engine/LV2Node.cpp4
-rw-r--r--src/libs/engine/NodeBase.cpp29
-rw-r--r--src/libs/engine/PatchImpl.cpp3
-rw-r--r--src/libs/engine/PortImpl.cpp6
8 files changed, 59 insertions, 19 deletions
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
@@ -57,6 +57,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)
{
if (!_polyphonic || !_parent->polyphonic())
@@ -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<NodeImpl*>::iterator i = _nodes.begin(); i != _nodes.end(); ++i)
(*i)->apply_poly(maid, poly);
- for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i)
- PtrCast<ConnectionImpl>(*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;
}