summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-10-13 01:59:53 +0000
committerDavid Robillard <d@drobilla.net>2008-10-13 01:59:53 +0000
commitb2d51e16571190becea1476080cff1b0a258a4f6 (patch)
tree14fc29ec1408a43b3a9688cc09aec8733f3d3d54 /src
parentef8f39fedbd51f414f19d1282b21ea4de46cf449 (diff)
downloadingen-b2d51e16571190becea1476080cff1b0a258a4f6.tar.gz
ingen-b2d51e16571190becea1476080cff1b0a258a4f6.tar.bz2
ingen-b2d51e16571190becea1476080cff1b0a258a4f6.zip
Fix various problems with subpatch connecting/disconnecting (and probably introduce new ones).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1668 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/engine/ConnectionImpl.cpp27
-rw-r--r--src/engine/ConnectionImpl.hpp7
-rw-r--r--src/engine/DuplexPort.cpp4
-rw-r--r--src/engine/InputPort.hpp2
-rw-r--r--src/engine/events/ConnectionEvent.cpp21
-rw-r--r--src/engine/events/DisconnectionEvent.cpp20
6 files changed, 49 insertions, 32 deletions
diff --git a/src/engine/ConnectionImpl.cpp b/src/engine/ConnectionImpl.cpp
index 64d51edf..53cef102 100644
--- a/src/engine/ConnectionImpl.cpp
+++ b/src/engine/ConnectionImpl.cpp
@@ -72,7 +72,9 @@ ConnectionImpl::~ConnectionImpl()
void
ConnectionImpl::set_mode()
{
- if (must_mix())
+ if (must_copy())
+ _mode = COPY;
+ else if (must_mix())
_mode = MIX;
else if (must_extend())
_mode = EXTEND;
@@ -97,13 +99,18 @@ ConnectionImpl::set_buffer_size(size_t size)
bool
-ConnectionImpl::must_mix() const
+ConnectionImpl::must_copy() const
{
- bool mix = ( /*(_src_port->poly() != _dst_port->poly())
- ||*/ (_src_port->polyphonic() && !_dst_port->polyphonic())
- || (_src_port->parent()->polyphonic() && !_dst_port->parent()->polyphonic()) );
+ return (_dst_port->fixed_buffers() && (_src_port->poly() == _dst_port->poly()));
+}
- return mix;
+
+bool
+ConnectionImpl::must_mix() const
+{
+ return ( (_src_port->polyphonic() && !_dst_port->polyphonic())
+ || (_src_port->parent()->polyphonic() && !_dst_port->parent()->polyphonic())
+ || (_dst_port->fixed_buffers()) );
}
@@ -164,7 +171,13 @@ ConnectionImpl::process(ProcessContext& context)
<< " -> " << dst_port()->path() << " * " << dst_port()->poly()
<< "\t\tmode: " << (int)_mode << endl;*/
- if (_mode == MIX) {
+ if (_mode == COPY) {
+ assert(src_port()->poly() == dst_port()->poly());
+ const size_t copy_size = std::min(src_port()->buffer_size(), dst_port()->buffer_size());
+ for (uint32_t i=0; i < src_port()->poly(); ++i) {
+ dst_port()->buffer(i)->copy(src_port()->buffer(i), 0, copy_size);
+ }
+ } else if (_mode == MIX) {
assert(type() == DataType::AUDIO || type() == DataType::CONTROL);
const AudioBuffer* const src_buffer = (AudioBuffer*)src_port()->buffer(0);
diff --git a/src/engine/ConnectionImpl.hpp b/src/engine/ConnectionImpl.hpp
index b3d7cf4b..a5a61c85 100644
--- a/src/engine/ConnectionImpl.hpp
+++ b/src/engine/ConnectionImpl.hpp
@@ -65,7 +65,7 @@ public:
* buffer, and will return accordingly (ie the same buffer for every voice
* in a mono->poly connection).
*/
- inline Buffer* buffer(size_t voice) const;
+ inline Buffer* buffer(uint32_t voice) const;
inline size_t buffer_size() const { return _buffer_size; }
@@ -73,6 +73,7 @@ public:
void prepare_poly(uint32_t poly);
void apply_poly(Raul::Maid& maid, uint32_t poly);
+ bool must_copy() const;
bool must_mix() const;
bool must_extend() const;
@@ -82,7 +83,7 @@ public:
DataType type() const { return _src_port->type(); }
protected:
- enum { DIRECT, MIX, EXTEND } _mode;
+ enum { DIRECT, MIX, COPY, EXTEND } _mode;
void set_mode();
PortImpl* const _src_port;
@@ -94,7 +95,7 @@ protected:
inline Buffer*
-ConnectionImpl::buffer(size_t voice) const
+ConnectionImpl::buffer(uint32_t voice) const
{
if (_mode == MIX) {
return _local_buffer;
diff --git a/src/engine/DuplexPort.cpp b/src/engine/DuplexPort.cpp
index 31bfbe09..5f5b8606 100644
--- a/src/engine/DuplexPort.cpp
+++ b/src/engine/DuplexPort.cpp
@@ -38,6 +38,7 @@ DuplexPort::DuplexPort(NodeImpl* parent, const string& name, uint32_t index, uin
, _is_output(is_output)
{
assert(PortImpl::_parent == parent);
+ _fixed_buffers = true;
}
@@ -57,6 +58,9 @@ DuplexPort::pre_process(ProcessContext& context)
<< ((EventBuffer*)buffer(i))->event_count()
<< ", joined: " << _buffers->at(i)->is_joined() << endl;*/
+ for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
+ (*c)->process(context);
+
if (_is_output) {
for (uint32_t i=0; i < _poly; ++i)
diff --git a/src/engine/InputPort.hpp b/src/engine/InputPort.hpp
index abc63a91..23732fa9 100644
--- a/src/engine/InputPort.hpp
+++ b/src/engine/InputPort.hpp
@@ -77,7 +77,7 @@ public:
virtual void set_buffer_size(size_t size);
-private:
+protected:
bool can_direct() const;
Connections _connections;
diff --git a/src/engine/events/ConnectionEvent.cpp b/src/engine/events/ConnectionEvent.cpp
index 772679fa..22bda824 100644
--- a/src/engine/events/ConnectionEvent.cpp
+++ b/src/engine/events/ConnectionEvent.cpp
@@ -15,7 +15,6 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
#include <string>
#include <boost/format.hpp>
#include <raul/Maid.hpp>
@@ -37,16 +36,16 @@ namespace Ingen {
ConnectionEvent::ConnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& src_port_path, const string& dst_port_path)
-: QueuedEvent(engine, responder, timestamp),
- _src_port_path(src_port_path),
- _dst_port_path(dst_port_path),
- _patch(NULL),
- _src_port(NULL),
- _dst_port(NULL),
- _compiled_patch(NULL),
- _patch_listnode(NULL),
- _port_listnode(NULL),
- _error(NO_ERROR)
+ : QueuedEvent(engine, responder, timestamp)
+ , _src_port_path(src_port_path)
+ , _dst_port_path(dst_port_path)
+ , _patch(NULL)
+ , _src_port(NULL)
+ , _dst_port(NULL)
+ , _compiled_patch(NULL)
+ , _patch_listnode(NULL)
+ , _port_listnode(NULL)
+ , _error(NO_ERROR)
{
}
diff --git a/src/engine/events/DisconnectionEvent.cpp b/src/engine/events/DisconnectionEvent.cpp
index d98718e9..fa045639 100644
--- a/src/engine/events/DisconnectionEvent.cpp
+++ b/src/engine/events/DisconnectionEvent.cpp
@@ -37,16 +37,16 @@ namespace Ingen {
DisconnectionEvent::DisconnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& src_port_path, const string& dst_port_path)
-: QueuedEvent(engine, responder, timestamp),
- _src_port_path(src_port_path),
- _dst_port_path(dst_port_path),
- _patch(NULL),
- _src_port(NULL),
- _dst_port(NULL),
- _lookup(true),
- _patch_connection(NULL),
- _compiled_patch(NULL),
- _error(NO_ERROR)
+ : QueuedEvent(engine, responder, timestamp)
+ , _src_port_path(src_port_path)
+ , _dst_port_path(dst_port_path)
+ , _patch(NULL)
+ , _src_port(NULL)
+ , _dst_port(NULL)
+ , _lookup(true)
+ , _patch_connection(NULL)
+ , _compiled_patch(NULL)
+ , _error(NO_ERROR)
{
}