diff options
author | David Robillard <d@drobilla.net> | 2009-11-16 00:30:35 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-11-16 00:30:35 +0000 |
commit | 3d89115a67a9c947a28539ffdd2399808a53279b (patch) | |
tree | 826b900de3979eed9c31aae0d3ac560d39b53460 /src/engine/ConnectionImpl.hpp | |
parent | 597fa9212f27d2448c0cdd20fbf616928c662cc1 (diff) | |
download | ingen-3d89115a67a9c947a28539ffdd2399808a53279b.tar.gz ingen-3d89115a67a9c947a28539ffdd2399808a53279b.tar.bz2 ingen-3d89115a67a9c947a28539ffdd2399808a53279b.zip |
Rework objects extension to have "value ports" and "message ports".
Make audio and control buffers in ingen actually object buffers (towards interop).
Overhaul the hell out of ingen buffer and mixing stuff.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2266 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/ConnectionImpl.hpp')
-rw-r--r-- | src/engine/ConnectionImpl.hpp | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/src/engine/ConnectionImpl.hpp b/src/engine/ConnectionImpl.hpp index a4ad281b..c9101304 100644 --- a/src/engine/ConnectionImpl.hpp +++ b/src/engine/ConnectionImpl.hpp @@ -18,17 +18,22 @@ #ifndef CONNECTIONIMPL_H #define CONNECTIONIMPL_H +#include <iostream> #include <cstdlib> #include <boost/utility.hpp> #include "raul/Deletable.hpp" #include "interface/DataType.hpp" #include "interface/Connection.hpp" #include "PortImpl.hpp" +#include "PortImpl.hpp" + +using namespace std; namespace Ingen { class PortImpl; class Buffer; +class BufferFactory; /** Represents a single inbound connection for an InputPort. @@ -44,8 +49,7 @@ class Buffer; class ConnectionImpl : public Raul::Deletable, public Shared::Connection { public: - ConnectionImpl(PortImpl* src_port, PortImpl* dst_port); - virtual ~ConnectionImpl(); + ConnectionImpl(BufferFactory& bufs, PortImpl* src_port, PortImpl* dst_port); PortImpl* src_port() const { return _src_port; } PortImpl* dst_port() const { return _dst_port; } @@ -61,49 +65,35 @@ public: /** Get the buffer for a particular voice. * A Connection is smart - it knows the destination port requesting the - * buffer, and will return accordingly (ie the same buffer for every voice - * in a mono->poly connection). + * buffer, and will return accordingly (e.g. the same buffer for every + * voice in a mono->poly connection). */ - inline Buffer* buffer(uint32_t voice) const; - - inline size_t buffer_size() const { return _buffer_size; } + inline SharedPtr<Buffer> buffer(uint32_t voice) const { + if (must_mix()) { + return _local_buffer; + } else if ( ! _src_port->polyphonic()) { + return _src_port->buffer(0); + } else { + return _src_port->buffer(voice); + } + } - void set_buffer_size(size_t size); - void prepare_poly(uint32_t poly); + void set_buffer_size(BufferFactory& bufs, size_t size); + void prepare_poly(BufferFactory& bufs, uint32_t poly); void apply_poly(Raul::Maid& maid, uint32_t poly); - inline bool need_buffer() const { return must_mix(); } - inline bool can_direct() const { return _mode == DIRECT; } - - Shared::DataType type() const { return _src_port->type(); } + /** Returns true if this connection must mix down voices into a local buffer */ + inline bool must_mix() const { return _src_port->poly() > _dst_port->poly(); } protected: - enum { DIRECT, MIX, COPY, EXTEND } _mode; - void set_mode(); - - bool must_copy() const; - bool must_mix() const; - bool must_extend() const; - - PortImpl* const _src_port; - PortImpl* const _dst_port; - Buffer* _local_buffer; - size_t _buffer_size; - bool _pending_disconnection; -}; - + void dump() const; -inline Buffer* -ConnectionImpl::buffer(uint32_t voice) const -{ - if (_mode == MIX) { - return _local_buffer; - } else if ( ! _src_port->polyphonic()) { - return _src_port->buffer(0); - } else { - return _src_port->buffer(voice); - } -} + BufferFactory& _bufs; + PortImpl* const _src_port; + PortImpl* const _dst_port; + SharedPtr<Buffer> _local_buffer; + bool _pending_disconnection; +}; } // namespace Ingen |