summaryrefslogtreecommitdiffstats
path: root/src/server/Buffer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Buffer.hpp')
-rw-r--r--src/server/Buffer.hpp76
1 files changed, 42 insertions, 34 deletions
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index 21364fd9..2c32076b 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -19,13 +19,12 @@
#include "BufferFactory.hpp"
#include "BufferRef.hpp"
-#include "PortType.hpp"
+#include "server.h"
#include "types.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/ingen.h"
-#include "lv2/atom/atom.h"
-#include "lv2/urid/urid.h"
+#include <ingen/URIs.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/urid/urid.h>
#include <atomic>
#include <cassert>
@@ -34,13 +33,15 @@
namespace ingen {
+enum class PortType;
+
class Atom;
namespace server {
class RunContext;
-class INGEN_API Buffer
+class INGEN_SERVER_API Buffer
{
public:
Buffer(BufferFactory& bufs,
@@ -61,10 +62,10 @@ public:
void* port_data(PortType port_type, SampleCount offset);
const void* port_data(PortType port_type, SampleCount offset) const;
- inline LV2_URID type() const { return _type; }
- inline LV2_URID value_type() const { return _value_type; }
- inline uint32_t capacity() const { return _capacity; }
- inline uint32_t size() const {
+ LV2_URID type() const { return _type; }
+ LV2_URID value_type() const { return _value_type; }
+ uint32_t capacity() const { return _capacity; }
+ uint32_t size() const {
return is_audio() ? _capacity : sizeof(LV2_Atom) + get<LV2_Atom>()->size;
}
@@ -78,52 +79,60 @@ public:
*/
void set_type(GetFn get_func, LV2_URID type, LV2_URID value_type);
- inline bool is_audio() const {
+ bool is_audio() const {
return _type == _factory.uris().atom_Sound;
}
- inline bool is_control() const {
+ bool is_control() const {
return _type == _factory.uris().atom_Float;
}
- inline bool is_sequence() const {
+ bool is_sequence() const {
return _type == _factory.uris().atom_Sequence;
}
/// Audio or float buffers only
- inline const Sample* samples() const {
+ const Sample* samples() const {
if (is_control()) {
return static_cast<const Sample*>(
LV2_ATOM_BODY_CONST(get<LV2_Atom_Float>()));
- } else if (is_audio()) {
+ }
+
+ if (is_audio()) {
return static_cast<const Sample*>(_buf);
}
+
return nullptr;
}
/// Audio buffers only
- inline Sample* samples() {
+ Sample* samples() {
if (is_control()) {
return static_cast<Sample*>(LV2_ATOM_BODY(get<LV2_Atom_Float>()));
- } else if (is_audio()) {
+ }
+
+ if (is_audio()) {
return static_cast<Sample*>(_buf);
}
+
return nullptr;
}
/// Numeric buffers only
- inline Sample value_at(SampleCount offset) const {
+ Sample value_at(SampleCount offset) const {
if (is_audio() || is_control()) {
return samples()[offset];
- } else if (_value_buffer) {
+ }
+
+ if (_value_buffer) {
return reinterpret_cast<const LV2_Atom_Float*>(value())->body;
}
+
return 0.0f;
}
- inline void set_block(const Sample val,
- const SampleCount start,
- const SampleCount end)
+ void
+ set_block(const Sample val, const SampleCount start, const SampleCount end)
{
if (is_sequence()) {
append_event(start, sizeof(val), _factory.uris().atom_Float,
@@ -142,9 +151,8 @@ public:
}
}
- inline void add_block(const Sample val,
- const SampleCount start,
- const SampleCount end)
+ void
+ add_block(const Sample val, const SampleCount start, const SampleCount end)
{
assert(is_audio() || is_control());
assert(end <= _capacity / sizeof(Sample));
@@ -155,10 +163,10 @@ public:
}
}
- inline void write_block(const Sample val,
- const SampleCount start,
- const SampleCount end,
- const bool add)
+ void write_block(const Sample val,
+ const SampleCount start,
+ const SampleCount end,
+ const bool add)
{
if (add) {
add_block(val, start, end);
@@ -212,9 +220,9 @@ public:
template<typename T> const T* get() const { return reinterpret_cast<const T*>(_buf); }
template<typename T> T* get() { return reinterpret_cast<T*>(_buf); }
- inline void ref() { ++_refs; }
+ void ref() { ++_refs; }
- inline void deref() {
+ void deref() {
if ((--_refs) == 0) {
recycle();
}
@@ -229,15 +237,15 @@ private:
BufferFactory& _factory;
// NOLINTNEXTLINE(clang-analyzer-webkit.NoUncountedMemberChecker)
- Buffer* _next; ///< Intrusive linked list for BufferFactory
+ Buffer* _next{nullptr}; ///< Intrusive linked list for BufferFactory
void* _buf; ///< Actual buffer memory
BufferRef _value_buffer; ///< Value buffer for numeric sequences
- int64_t _latest_event;
+ int64_t _latest_event{0};
LV2_URID _type;
LV2_URID _value_type;
uint32_t _capacity;
- std::atomic<unsigned> _refs; ///< Intrusive reference count
+ std::atomic<unsigned> _refs{0}; ///< Intrusive reference count
bool _external; ///< Buffer is externally allocated
};