From bb12144cbfb8c06f502ce0f963edefbb6009aea9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 6 Oct 2011 17:51:43 +0000 Subject: Use an intrusive linked list for InputPort connections. This simplifies the code and avoids the overhead of allocating list nodes. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3532 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/ConnectionImpl.hpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src/server/ConnectionImpl.hpp') diff --git a/src/server/ConnectionImpl.hpp b/src/server/ConnectionImpl.hpp index 33ec0608..35441d7d 100644 --- a/src/server/ConnectionImpl.hpp +++ b/src/server/ConnectionImpl.hpp @@ -20,6 +20,7 @@ #include +#include #include #include @@ -28,7 +29,8 @@ #include "raul/Deletable.hpp" #include "raul/log.hpp" -#include "PortImpl.hpp" +#include "BufferFactory.hpp" +#include "Context.hpp" using namespace std; @@ -51,7 +53,10 @@ class BufferFactory; * * \ingroup engine */ -class ConnectionImpl : public Raul::Deletable, public Connection +class ConnectionImpl : public Raul::Deletable + , private Raul::Noncopyable + , public Connection + , public boost::intrusive::list_base_hook<> { public: ConnectionImpl(BufferFactory& bufs, PortImpl* src_port, PortImpl* dst_port); @@ -59,8 +64,8 @@ public: PortImpl* src_port() const { return _src_port; } PortImpl* dst_port() const { return _dst_port; } - const Raul::Path& src_port_path() const { return _src_port->path(); } - const Raul::Path& dst_port_path() const { return _dst_port->path(); } + const Raul::Path& src_port_path() const; + const Raul::Path& dst_port_path() const; /** Used by some (recursive) events to prevent double disconnections */ bool pending_disconnection() { return _pending_disconnection; } @@ -68,30 +73,24 @@ public: void queue(Context& context); - void get_sources(Context& context, uint32_t voice, - boost::intrusive_ptr* srcs, uint32_t max_num_srcs, uint32_t& num_srcs); + void get_sources(Context& context, + uint32_t voice, + boost::intrusive_ptr* srcs, + uint32_t max_num_srcs, + uint32_t& num_srcs); /** Get the buffer for a particular voice. * A Connection is smart - it knows the destination port requesting the * buffer, and will return accordingly (e.g. the same buffer for every * voice in a mono->poly connection). */ - inline BufferFactory::Ref buffer(uint32_t voice) const { - assert(!must_mix()); - assert(!must_queue()); - assert(_src_port->poly() == 1 || _src_port->poly() > voice); - if (_src_port->poly() == 1) { - return _src_port->buffer(0); - } else { - return _src_port->buffer(voice); - } - } + BufferFactory::Ref buffer(uint32_t voice) const; /** 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(); } + bool must_mix() const; /** Returns true if this connection crosses contexts and must buffer */ - inline bool must_queue() const { return _src_port->context() != _dst_port->context(); } + bool must_queue() const; static bool can_connect(const OutputPort* src, const InputPort* dst); -- cgit v1.2.1