summaryrefslogtreecommitdiffstats
path: root/src/engine/events/Connect.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/events/Connect.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/events/Connect.cpp')
-rw-r--r--src/engine/events/Connect.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/engine/events/Connect.cpp b/src/engine/events/Connect.cpp
index 1654645c..cc870c04 100644
--- a/src/engine/events/Connect.cpp
+++ b/src/engine/events/Connect.cpp
@@ -22,12 +22,14 @@
#include "ClientBroadcaster.hpp"
#include "Connect.hpp"
#include "ConnectionImpl.hpp"
+#include "DuplexPort.hpp"
#include "Engine.hpp"
-#include "InputPort.hpp"
#include "EngineStore.hpp"
+#include "InputPort.hpp"
#include "OutputPort.hpp"
#include "PatchImpl.hpp"
#include "PortImpl.hpp"
+#include "ProcessContext.hpp"
#include "Request.hpp"
#include "types.hpp"
@@ -50,6 +52,7 @@ Connect::Connect(Engine& engine, SharedPtr<Request> request, SampleCount timesta
, _compiled_patch(NULL)
, _patch_listnode(NULL)
, _port_listnode(NULL)
+ , _buffers(NULL)
, _error(NO_ERROR)
{
}
@@ -157,6 +160,18 @@ Connect::pre_process()
}
_patch->add_connection(_patch_listnode);
+ _dst_input_port->increment_num_connections();
+
+ switch (_dst_input_port->num_connections()) {
+ case 1:
+ _connection->allocate_buffer(*_engine.buffer_factory());
+ break;
+ case 2:
+ _buffers = new Raul::Array<BufferFactory::Ref>(_dst_input_port->poly());
+ _dst_input_port->get_buffers(*_engine.buffer_factory(), _buffers, _dst_input_port->poly());
+ default:
+ break;
+ }
if (_patch->enabled())
_compiled_patch = _patch->compile();
@@ -173,8 +188,12 @@ Connect::execute(ProcessContext& context)
if (_error == NO_ERROR) {
// This must be inserted here, since they're actually used by the audio thread
_dst_input_port->add_connection(_port_listnode);
- if (_patch->compiled_patch() != NULL)
- _engine.maid()->push(_patch->compiled_patch());
+ if (_buffers)
+ _engine.maid()->push(_dst_input_port->set_buffers(_buffers));
+ else
+ _dst_input_port->setup_buffers(*_engine.buffer_factory(), _dst_input_port->poly());
+ _dst_input_port->connect_buffers();
+ _engine.maid()->push(_patch->compiled_patch());
_patch->compiled_patch(_compiled_patch);
}
}