summaryrefslogtreecommitdiffstats
path: root/src/engine/ConnectionImpl.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-20 21:52:36 +0000
committerDavid Robillard <d@drobilla.net>2010-02-20 21:52:36 +0000
commit46e5de590817756b21a7a5d99bd4963df343f455 (patch)
tree7d7b3b63297b24d84e5b42cc8aeb22d4212738b5 /src/engine/ConnectionImpl.cpp
parentb96a4015ae39b5bdd9afbd82898c0168a0a8e613 (diff)
downloadingen-46e5de590817756b21a7a5d99bd4963df343f455.tar.gz
ingen-46e5de590817756b21a7a5d99bd4963df343f455.tar.bz2
ingen-46e5de590817756b21a7a5d99bd4963df343f455.zip
Heavy overhaul of buffer management and polyphony.
* Working polyphony when nodes are instantiated at desired polyphony level (dynamic still doesn't work) * Use shared silent buffer for disconnected audio inputs (save memory) * Eliminate redundant patch compiling on delete and disconnect-all events that have child events * Fix a ton of crash bugs and other issues I've since forgotten git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2468 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/ConnectionImpl.cpp')
-rw-r--r--src/engine/ConnectionImpl.cpp43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/engine/ConnectionImpl.cpp b/src/engine/ConnectionImpl.cpp
index 3beca4c8..4a154809 100644
--- a/src/engine/ConnectionImpl.cpp
+++ b/src/engine/ConnectionImpl.cpp
@@ -55,11 +55,8 @@ ConnectionImpl::ConnectionImpl(BufferFactory& bufs, PortImpl* src_port, PortImpl
if (must_mix() || must_queue())
_local_buffer = bufs.get(dst_port->type(), dst_port->buffer_size(), true);
-
if (must_queue())
_queue = new Raul::RingBuffer<LV2_Object>(src_port->buffer_size() * 2);
-
- //dump();
}
@@ -68,24 +65,38 @@ ConnectionImpl::dump() const
{
debug << _src_port->path() << " -> " << _dst_port->path()
<< (must_mix() ? " (MIX) " : " (DIRECT) ")
- << (must_queue() ? " (QUEUE)" : " (NOQUEUE)") << endl;
+ << (must_queue() ? " (QUEUE)" : " (NOQUEUE) ")
+ << "POLY: " << _src_port->poly() << " => " << _dst_port->poly() << endl;
}
void
-ConnectionImpl::set_buffer_size(BufferFactory& bufs, size_t size)
+ConnectionImpl::update_buffer_size(Context& context, BufferFactory& bufs)
{
- if (must_mix())
- _local_buffer = bufs.get(_dst_port->type(), _dst_port->buffer(0)->size());
+ if (must_mix() || must_queue())
+ allocate_buffer(bufs);
+}
+
+
+void
+ConnectionImpl::allocate_buffer(BufferFactory& bufs)
+{
+ if (!_local_buffer)
+ _local_buffer = bufs.get(_dst_port->type(), _dst_port->buffer_size());
}
void
ConnectionImpl::prepare_poly(BufferFactory& bufs, uint32_t poly)
{
- _src_port->prepare_poly(bufs, poly);
+ ThreadManager::assert_thread(THREAD_PRE_PROCESS);
- if (must_mix())
+ assert(_src_port->prepared_poly() == _dst_port->prepared_poly()
+ || _src_port->prepared_poly() == 1
+ || _dst_port->prepared_poly() == 1);
+
+ const bool mix = _src_port->prepared_poly() > _dst_port->prepared_poly();
+ if ((mix || must_queue()) && !_local_buffer)
_local_buffer = bufs.get(_dst_port->type(), _dst_port->buffer(0)->size());
}
@@ -93,12 +104,15 @@ ConnectionImpl::prepare_poly(BufferFactory& bufs, uint32_t poly)
void
ConnectionImpl::apply_poly(Raul::Maid& maid, uint32_t poly)
{
- _src_port->apply_poly(maid, poly);
+ ThreadManager::assert_thread(THREAD_PROCESS);
+
+ assert(_src_port->poly() == _dst_port->poly()
+ || _src_port->poly() == 1
+ || _dst_port->poly() == 1);
// Recycle buffer if it's no longer needed
- if (!must_mix() && _local_buffer)
- _local_buffer.reset(NULL);
- //_local_buffer.reset(); // old boost is missing this
+ if (!(must_mix() || must_queue()))
+ _local_buffer = NULL;
}
@@ -118,6 +132,8 @@ ConnectionImpl::process(Context& context)
return;
}
+ local_buf->clear();
+
if (_queue->read_space()) {
LV2_Object obj;
_queue->full_peek(sizeof(LV2_Object), &obj);
@@ -130,6 +146,7 @@ ConnectionImpl::process(Context& context)
for (uint32_t v = 0; v < num_srcs; ++v)
srcs[v] = src_port()->buffer(v).get();
+ _local_buffer->clear();
mix(context, _local_buffer.get(), srcs, num_srcs);
}
}