summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-23 02:32:33 +0000
committerDavid Robillard <d@drobilla.net>2012-04-23 02:32:33 +0000
commit8d1e92ab0655d4ede8ea17358d678b3a5aabc1bc (patch)
tree2dff94cd90ca026f2f4e0e490da03762cc924680 /src
parent8601ab0fe6c5782cc38de48576eb2f7c4fb2ccef (diff)
downloadingen-8d1e92ab0655d4ede8ea17358d678b3a5aabc1bc.tar.gz
ingen-8d1e92ab0655d4ede8ea17358d678b3a5aabc1bc.tar.bz2
ingen-8d1e92ab0655d4ede8ea17358d678b3a5aabc1bc.zip
Localise buffer reference stuff.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4252 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/server/Buffer.hpp7
-rw-r--r--src/server/BufferFactory.cpp12
-rw-r--r--src/server/BufferFactory.hpp11
-rw-r--r--src/server/BufferRef.hpp39
-rw-r--r--src/server/ConnectionImpl.cpp2
-rw-r--r--src/server/ConnectionImpl.hpp2
-rw-r--r--src/server/ControlBindings.hpp2
-rw-r--r--src/server/DuplexPort.cpp6
-rw-r--r--src/server/DuplexPort.hpp6
-rw-r--r--src/server/InputPort.cpp6
-rw-r--r--src/server/InputPort.hpp6
-rw-r--r--src/server/NodeImpl.cpp8
-rw-r--r--src/server/OutputPort.cpp6
-rw-r--r--src/server/OutputPort.hpp6
-rw-r--r--src/server/PortImpl.cpp10
-rw-r--r--src/server/PortImpl.hpp41
-rw-r--r--src/server/events/Connect.cpp2
-rw-r--r--src/server/events/Connect.hpp2
-rw-r--r--src/server/events/Disconnect.cpp2
-rw-r--r--src/server/events/Disconnect.hpp12
20 files changed, 110 insertions, 78 deletions
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index 11436d9c..fcd6fe65 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -44,8 +44,6 @@ 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);
@@ -94,9 +92,4 @@ private:
} // namespace Server
} // namespace Ingen
-namespace boost {
-inline void intrusive_ptr_add_ref(Ingen::Server::Buffer* b) { b->ref(); }
-inline void intrusive_ptr_release(Ingen::Server::Buffer* b) { b->deref(); }
-}
-
#endif // INGEN_ENGINE_BUFFER_HPP
diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp
index d5b268b7..73b6558d 100644
--- a/src/server/BufferFactory.cpp
+++ b/src/server/BufferFactory.cpp
@@ -92,7 +92,7 @@ BufferFactory::default_buffer_size(LV2_URID type)
}
}
-BufferFactory::Ref
+BufferRef
BufferFactory::get(LV2_URID type, uint32_t capacity, bool force_create)
{
Raul::AtomicPtr<Buffer>& head_ptr = free_list(type);
@@ -114,21 +114,21 @@ BufferFactory::get(LV2_URID type, uint32_t capacity, bool force_create)
} else {
assert(false);
error << "Failed to obtain buffer" << endl;
- return Ref();
+ return BufferRef();
}
}
try_head->_next = NULL;
- return Ref(try_head);
+ return BufferRef(try_head);
}
-BufferFactory::Ref
+BufferRef
BufferFactory::silent_buffer()
{
return _silent_buffer;
}
-BufferFactory::Ref
+BufferRef
BufferFactory::create(LV2_URID type, uint32_t capacity)
{
ThreadManager::assert_not_thread(THREAD_PROCESS);
@@ -152,7 +152,7 @@ BufferFactory::create(LV2_URID type, uint32_t capacity)
buffer->atom()->type = type;
assert(buffer);
- return Ref(buffer);
+ return BufferRef(buffer);
}
void
diff --git a/src/server/BufferFactory.hpp b/src/server/BufferFactory.hpp
index e04cf1e9..08f7680b 100644
--- a/src/server/BufferFactory.hpp
+++ b/src/server/BufferFactory.hpp
@@ -32,6 +32,7 @@
#include "ingen/shared/URIs.hpp"
#include "Buffer.hpp"
+#include "BufferRef.hpp"
#include "PortType.hpp"
#include "types.hpp"
@@ -50,14 +51,12 @@ public:
~BufferFactory();
- typedef boost::intrusive_ptr<Buffer> Ref;
-
static uint32_t audio_buffer_size(SampleCount nframes);
uint32_t default_buffer_size(LV2_URID type);
- Ref get(LV2_URID type, uint32_t capacity, bool force_create=false);
+ BufferRef get(LV2_URID type, uint32_t capacity, bool force_create=false);
- Ref silent_buffer();
+ BufferRef silent_buffer();
void set_block_length(SampleCount block_length);
@@ -69,7 +68,7 @@ private:
friend class Buffer;
void recycle(Buffer* buf);
- Ref create(LV2_URID type, uint32_t capacity=0);
+ BufferRef create(LV2_URID type, uint32_t capacity=0);
inline Raul::AtomicPtr<Buffer>& free_list(LV2_URID type) {
if (type == _uris->atom_Float) {
@@ -91,7 +90,7 @@ private:
Engine& _engine;
SharedPtr<Ingen::Shared::URIs> _uris;
- Ref _silent_buffer;
+ BufferRef _silent_buffer;
};
} // namespace Server
diff --git a/src/server/BufferRef.hpp b/src/server/BufferRef.hpp
new file mode 100644
index 00000000..12a62930
--- /dev/null
+++ b/src/server/BufferRef.hpp
@@ -0,0 +1,39 @@
+/*
+ This file is part of Ingen.
+ Copyright 2007-2012 David Robillard <http://drobilla.net/>
+
+ Ingen is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or any later version.
+
+ Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef INGEN_ENGINE_BUFFERREF_HPP
+#define INGEN_ENGINE_BUFFERREF_HPP
+
+#include <boost/intrusive_ptr.hpp>
+
+namespace Ingen {
+namespace Server {
+
+class Buffer;
+
+typedef boost::intrusive_ptr<Buffer> BufferRef;
+
+} // namespace Server
+} // namespace Ingen
+
+namespace boost {
+
+inline void intrusive_ptr_add_ref(Ingen::Server::Buffer* b) { b->ref(); }
+inline void intrusive_ptr_release(Ingen::Server::Buffer* b) { b->deref(); }
+
+}
+
+#endif // INGEN_ENGINE_BUFFERREF_HPP
diff --git a/src/server/ConnectionImpl.cpp b/src/server/ConnectionImpl.cpp
index 6c17618e..2b6a0255 100644
--- a/src/server/ConnectionImpl.cpp
+++ b/src/server/ConnectionImpl.cpp
@@ -128,7 +128,7 @@ ConnectionImpl::queue(Context& context)
}
}
-BufferFactory::Ref
+BufferRef
ConnectionImpl::buffer(uint32_t voice) const
{
assert(!must_mix());
diff --git a/src/server/ConnectionImpl.hpp b/src/server/ConnectionImpl.hpp
index 20f5586f..4d915606 100644
--- a/src/server/ConnectionImpl.hpp
+++ b/src/server/ConnectionImpl.hpp
@@ -83,7 +83,7 @@ public:
* buffer, and will return accordingly (e.g. the same buffer for every
* voice in a mono->poly connection).
*/
- BufferFactory::Ref buffer(uint32_t voice) const;
+ BufferRef buffer(uint32_t voice) const;
/** Returns true if this connection must mix down voices into a local buffer */
bool must_mix() const;
diff --git a/src/server/ControlBindings.hpp b/src/server/ControlBindings.hpp
index 1a42961c..0a3a92c0 100644
--- a/src/server/ControlBindings.hpp
+++ b/src/server/ControlBindings.hpp
@@ -111,7 +111,7 @@ private:
PortImpl* _learn_port;
SharedPtr<Bindings> _bindings;
- BufferFactory::Ref _feedback;
+ BufferRef _feedback;
};
} // namespace Server
diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp
index 749eaf84..6050e669 100644
--- a/src/server/DuplexPort.cpp
+++ b/src/server/DuplexPort.cpp
@@ -57,9 +57,9 @@ DuplexPort::DuplexPort(
}
bool
-DuplexPort::get_buffers(BufferFactory& bufs,
- Raul::Array<BufferFactory::Ref>* buffers,
- uint32_t poly) const
+DuplexPort::get_buffers(BufferFactory& bufs,
+ Raul::Array<BufferRef>* buffers,
+ uint32_t poly) const
{
if (_is_output)
return InputPort::get_buffers(bufs, buffers, poly);
diff --git a/src/server/DuplexPort.hpp b/src/server/DuplexPort.hpp
index a928f27c..5b8f30e0 100644
--- a/src/server/DuplexPort.hpp
+++ b/src/server/DuplexPort.hpp
@@ -52,9 +52,9 @@ public:
virtual ~DuplexPort() {}
- bool get_buffers(BufferFactory& bufs,
- Raul::Array<BufferFactory::Ref>* buffers,
- uint32_t poly) const;
+ bool get_buffers(BufferFactory& bufs,
+ Raul::Array<BufferRef>* buffers,
+ uint32_t poly) const;
void pre_process(Context& context);
void post_process(Context& context);
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index f50a3d55..3fadd312 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -78,9 +78,9 @@ InputPort::apply_poly(Maid& maid, uint32_t poly)
* @return true iff buffers are locally owned by the port
*/
bool
-InputPort::get_buffers(BufferFactory& bufs,
- Raul::Array<BufferFactory::Ref>* buffers,
- uint32_t poly) const
+InputPort::get_buffers(BufferFactory& bufs,
+ Raul::Array<BufferRef>* buffers,
+ uint32_t poly) const
{
size_t num_connections = (ThreadManager::thread_is(THREAD_PROCESS))
? _connections.size() : _num_connections;
diff --git a/src/server/InputPort.hpp b/src/server/InputPort.hpp
index d4af9a2c..89f3949a 100644
--- a/src/server/InputPort.hpp
+++ b/src/server/InputPort.hpp
@@ -73,9 +73,9 @@ public:
bool apply_poly(Raul::Maid& maid, uint32_t poly);
- bool get_buffers(BufferFactory& bufs,
- Raul::Array<BufferFactory::Ref>* buffers,
- uint32_t poly) const;
+ bool get_buffers(BufferFactory& bufs,
+ Raul::Array<BufferRef>* buffers,
+ uint32_t poly) const;
void pre_process(Context& context);
void post_process(Context& context);
diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp
index 0d930a5f..36074649 100644
--- a/src/server/NodeImpl.cpp
+++ b/src/server/NodeImpl.cpp
@@ -232,10 +232,10 @@ NodeImpl::post_process(Context& context)
}
void
-NodeImpl::set_port_buffer(uint32_t voice,
- uint32_t port_num,
- BufferFactory::Ref buf,
- SampleCount offset)
+NodeImpl::set_port_buffer(uint32_t voice,
+ uint32_t port_num,
+ BufferRef buf,
+ SampleCount offset)
{
/*std::cout << path() << " set port " << port_num << " voice " << voice
<< " buffer " << buf << " offset " << offset << std::endl;*/
diff --git a/src/server/OutputPort.cpp b/src/server/OutputPort.cpp
index f7d6de95..b8ad0169 100644
--- a/src/server/OutputPort.cpp
+++ b/src/server/OutputPort.cpp
@@ -49,9 +49,9 @@ OutputPort::OutputPort(BufferFactory& bufs,
}
bool
-OutputPort::get_buffers(BufferFactory& bufs,
- Raul::Array<BufferFactory::Ref>* buffers,
- uint32_t poly) const
+OutputPort::get_buffers(BufferFactory& bufs,
+ Raul::Array<BufferRef>* buffers,
+ uint32_t poly) const
{
for (uint32_t v = 0; v < poly; ++v)
buffers->at(v) = bufs.get(buffer_type(), _buffer_size);
diff --git a/src/server/OutputPort.hpp b/src/server/OutputPort.hpp
index 9fb3ab58..2338f5cf 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<Buffer::Ref>* buffers,
- uint32_t poly) const;
+ bool get_buffers(BufferFactory& bufs,
+ Raul::Array<BufferRef>* buffers,
+ uint32_t poly) const;
void pre_process(Context& context);
void post_process(Context& context);
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index 4ca87cf8..c4d186d7 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -55,7 +55,7 @@ PortImpl::PortImpl(BufferFactory& bufs,
, _min(bufs.forge().make(0.0f))
, _max(bufs.forge().make(1.0f))
, _last_broadcasted_value(value)
- , _buffers(new Array<BufferFactory::Ref>(static_cast<size_t>(poly)))
+ , _buffers(new Array<BufferRef>(static_cast<size_t>(poly)))
, _prepared_buffers(NULL)
, _broadcast(false)
, _set_by_user(false)
@@ -99,12 +99,12 @@ PortImpl::supports(const Raul::URI& value_type) const
_bufs.forge().alloc_uri(value_type.str()));
}
-Raul::Array<BufferFactory::Ref>*
-PortImpl::set_buffers(Raul::Array<BufferFactory::Ref>* buffers)
+Raul::Array<BufferRef>*
+PortImpl::set_buffers(Raul::Array<BufferRef>* buffers)
{
ThreadManager::assert_thread(THREAD_PROCESS);
- Raul::Array<BufferFactory::Ref>* ret = NULL;
+ Raul::Array<BufferRef>* ret = NULL;
if (buffers != _buffers) {
ret = _buffers;
_buffers = buffers;
@@ -135,7 +135,7 @@ PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly)
}
if (!_prepared_buffers)
- _prepared_buffers = new Array<BufferFactory::Ref>(poly, *_buffers, NULL);
+ _prepared_buffers = new Array<BufferRef>(poly, *_buffers, NULL);
return true;
}
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index 2c106f32..ddbaa087 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -26,6 +26,7 @@
#include "ingen/Port.hpp"
#include "Buffer.hpp"
+#include "BufferRef.hpp"
#include "Context.hpp"
#include "GraphObjectImpl.hpp"
#include "PortType.hpp"
@@ -60,7 +61,7 @@ public:
* Audio thread. Returned value must be freed by caller.
* \a buffers must be poly() long
*/
- Raul::Array<Buffer::Ref>* set_buffers(Raul::Array<Buffer::Ref>* buffers);
+ Raul::Array<BufferRef>* set_buffers(Raul::Array<BufferRef>* buffers);
/** Prepare for a new (external) polyphony value.
*
@@ -90,10 +91,10 @@ public:
void set_minimum(const Raul::Atom& min) { _min = min; }
void set_maximum(const Raul::Atom& max) { _max = max; }
- inline Buffer::Ref buffer(uint32_t voice) const {
+ inline BufferRef buffer(uint32_t voice) const {
return _buffers->at((_poly == 1) ? 0 : voice);
}
- inline Buffer::Ref prepared_buffer(uint32_t voice) const {
+ inline BufferRef prepared_buffer(uint32_t voice) const {
return _prepared_buffers->at(voice);
}
@@ -104,9 +105,9 @@ public:
/** Empty buffer contents completely (ie silence) */
virtual void clear_buffers();
- virtual bool get_buffers(BufferFactory& bufs,
- Raul::Array<Buffer::Ref>* buffers,
- uint32_t poly) const = 0;
+ virtual bool get_buffers(BufferFactory& bufs,
+ Raul::Array<BufferRef>* buffers,
+ uint32_t poly) const = 0;
void setup_buffers(BufferFactory& bufs, uint32_t poly) {
get_buffers(bufs, _buffers, poly);
@@ -158,20 +159,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<Buffer::Ref>* _buffers;
- Raul::Array<Buffer::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<BufferRef>* _buffers;
+ Raul::Array<BufferRef>* _prepared_buffers;
+ bool _broadcast;
+ bool _set_by_user;
};
} // namespace Server
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index bda3fc4c..f61a5cd1 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -145,7 +145,7 @@ Connect::pre_process()
_dst_input_port->increment_num_connections();
}
- _buffers = new Raul::Array<BufferFactory::Ref>(_dst_input_port->poly());
+ _buffers = new Raul::Array<BufferRef>(_dst_input_port->poly());
_dst_input_port->get_buffers(*_engine.buffer_factory(),
_buffers, _dst_input_port->poly());
diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp
index afc4f5fe..f4544272 100644
--- a/src/server/events/Connect.hpp
+++ b/src/server/events/Connect.hpp
@@ -71,7 +71,7 @@ private:
SharedPtr<ConnectionImpl> _connection;
- Raul::Array<BufferFactory::Ref>* _buffers;
+ Raul::Array<BufferRef>* _buffers;
};
} // namespace Events
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index 5fcc12b4..ddf3bb1c 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -93,7 +93,7 @@ Disconnect::Impl::Impl(Engine& e,
_dst_input_port->decrement_num_connections();
if (_dst_input_port->num_connections() == 0) {
- _buffers = new Raul::Array<BufferFactory::Ref>(_dst_input_port->poly());
+ _buffers = new Raul::Array<BufferRef>(_dst_input_port->poly());
_dst_input_port->get_buffers(*_engine.buffer_factory(),
_buffers, _dst_input_port->poly());
diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp
index c855207c..05ac2aa7 100644
--- a/src/server/events/Disconnect.hpp
+++ b/src/server/events/Disconnect.hpp
@@ -68,12 +68,12 @@ public:
InputPort* dst_port() { return _dst_input_port; }
private:
- Engine& _engine;
- OutputPort* _src_output_port;
- InputPort* _dst_input_port;
- PatchImpl* _patch;
- SharedPtr<ConnectionImpl> _connection;
- Raul::Array<BufferFactory::Ref>* _buffers;
+ Engine& _engine;
+ OutputPort* _src_output_port;
+ InputPort* _dst_input_port;
+ PatchImpl* _patch;
+ SharedPtr<ConnectionImpl> _connection;
+ Raul::Array<BufferRef>* _buffers;
};
private: