diff options
-rw-r--r-- | src/server/Buffer.cpp | 7 | ||||
-rw-r--r-- | src/server/Buffer.hpp | 11 | ||||
-rw-r--r-- | src/server/OutputPort.cpp | 1 | ||||
-rw-r--r-- | src/server/OutputPort.hpp | 6 | ||||
-rw-r--r-- | src/server/PortImpl.hpp | 41 |
5 files changed, 39 insertions, 27 deletions
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index 2f1062f7..fa8a2c0e 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -30,6 +30,7 @@ #include "raul/log.hpp" #include "Buffer.hpp" +#include "BufferFactory.hpp" #include "Engine.hpp" namespace Ingen { @@ -73,6 +74,12 @@ Buffer::~Buffer() } void +Buffer::recycle() +{ + _factory.recycle(this); +} + +void Buffer::clear() { _atom->size = 0; diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp index 44db0959..11436d9c 100644 --- a/src/server/Buffer.hpp +++ b/src/server/Buffer.hpp @@ -24,11 +24,11 @@ #include <boost/utility.hpp> #include "lv2/lv2plug.in/ns/ext/atom/atom.h" +#include "lv2/lv2plug.in/ns/ext/urid/urid.h" #include "raul/AtomicInt.hpp" #include "raul/Deletable.hpp" #include "raul/SharedPtr.hpp" -#include "BufferFactory.hpp" #include "PortType.hpp" #include "types.hpp" @@ -44,6 +44,8 @@ class Buffer : public boost::noncopyable, public Raul::Deletable public: Buffer(BufferFactory& bufs, LV2_URID type, uint32_t capacity); + typedef boost::intrusive_ptr<Buffer> Ref; + virtual void clear(); virtual void resize(uint32_t size); virtual void copy(Context& context, const Buffer* src); @@ -68,8 +70,9 @@ public: inline void ref() { ++_refs; } inline void deref() { - if ((--_refs) == 0) - _factory.recycle(this); + if ((--_refs) == 0) { + recycle(); + } } protected: @@ -82,6 +85,8 @@ protected: virtual ~Buffer(); private: + void recycle(); + Buffer* _next; ///< Intrusive linked list for BufferFactory Raul::AtomicInt _refs; ///< Intrusive reference count for intrusive_ptr }; diff --git a/src/server/OutputPort.cpp b/src/server/OutputPort.cpp index 1a5e88d9..f7d6de95 100644 --- a/src/server/OutputPort.cpp +++ b/src/server/OutputPort.cpp @@ -17,6 +17,7 @@ #include "ingen/Patch.hpp" #include "Buffer.hpp" +#include "BufferFactory.hpp" #include "NodeImpl.hpp" #include "OutputPort.hpp" #include "ProcessContext.hpp" diff --git a/src/server/OutputPort.hpp b/src/server/OutputPort.hpp index 0f56c606..9fb3ab58 100644 --- a/src/server/OutputPort.hpp +++ b/src/server/OutputPort.hpp @@ -51,9 +51,9 @@ public: virtual ~OutputPort() {} - bool get_buffers(BufferFactory& bufs, - Raul::Array<BufferFactory::Ref>* buffers, - uint32_t poly) const; + bool get_buffers(BufferFactory& bufs, + Raul::Array<Buffer::Ref>* buffers, + uint32_t poly) const; void pre_process(Context& context); void post_process(Context& context); diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp index 033f66e1..2c106f32 100644 --- a/src/server/PortImpl.hpp +++ b/src/server/PortImpl.hpp @@ -37,7 +37,6 @@ namespace Ingen { namespace Server { class NodeImpl; -class Buffer; class BufferFactory; /** A port on a Node. @@ -61,7 +60,7 @@ public: * Audio thread. Returned value must be freed by caller. * \a buffers must be poly() long */ - Raul::Array<BufferFactory::Ref>* set_buffers(Raul::Array<BufferFactory::Ref>* buffers); + Raul::Array<Buffer::Ref>* set_buffers(Raul::Array<Buffer::Ref>* buffers); /** Prepare for a new (external) polyphony value. * @@ -91,10 +90,10 @@ public: void set_minimum(const Raul::Atom& min) { _min = min; } void set_maximum(const Raul::Atom& max) { _max = max; } - inline BufferFactory::Ref buffer(uint32_t voice) const { + inline Buffer::Ref buffer(uint32_t voice) const { return _buffers->at((_poly == 1) ? 0 : voice); } - inline BufferFactory::Ref prepared_buffer(uint32_t voice) const { + inline Buffer::Ref prepared_buffer(uint32_t voice) const { return _prepared_buffers->at(voice); } @@ -105,9 +104,9 @@ public: /** Empty buffer contents completely (ie silence) */ virtual void clear_buffers(); - virtual bool get_buffers(BufferFactory& bufs, - Raul::Array<BufferFactory::Ref>* buffers, - uint32_t poly) const = 0; + virtual bool get_buffers(BufferFactory& bufs, + Raul::Array<Buffer::Ref>* buffers, + uint32_t poly) const = 0; void setup_buffers(BufferFactory& bufs, uint32_t poly) { get_buffers(bufs, _buffers, poly); @@ -159,20 +158,20 @@ protected: const Raul::Atom& value, size_t buffer_size); - BufferFactory& _bufs; - uint32_t _index; - uint32_t _poly; - uint32_t _buffer_size; - PortType _type; - LV2_URID _buffer_type; - Raul::Atom _value; - Raul::Atom _min; - Raul::Atom _max; - Raul::Atom _last_broadcasted_value; - Raul::Array<BufferFactory::Ref>* _buffers; - Raul::Array<BufferFactory::Ref>* _prepared_buffers; - bool _broadcast; - bool _set_by_user; + BufferFactory& _bufs; + uint32_t _index; + uint32_t _poly; + uint32_t _buffer_size; + PortType _type; + LV2_URID _buffer_type; + Raul::Atom _value; + Raul::Atom _min; + Raul::Atom _max; + Raul::Atom _last_broadcasted_value; + Raul::Array<Buffer::Ref>* _buffers; + Raul::Array<Buffer::Ref>* _prepared_buffers; + bool _broadcast; + bool _set_by_user; }; } // namespace Server |