summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-11-14 19:22:09 -0500
committerDavid Robillard <d@drobilla.net>2016-09-11 14:41:18 +0200
commitd1e58b25654ab25607329afacc9a23d829267637 (patch)
tree8b1f1b0f3019650211cb4815cf0ba5d25ba4127d /src
parent7dd82030ec60df74db7be51a6b8b3bb4a8a9f5a3 (diff)
downloadingen-d1e58b25654ab25607329afacc9a23d829267637.tar.gz
ingen-d1e58b25654ab25607329afacc9a23d829267637.tar.bz2
ingen-d1e58b25654ab25607329afacc9a23d829267637.zip
Fix buffer copying for various types
Diffstat (limited to 'src')
-rw-r--r--src/server/Buffer.cpp8
-rw-r--r--src/server/Buffer.hpp3
-rw-r--r--src/server/InternalBlock.cpp12
3 files changed, 13 insertions, 10 deletions
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index 4fbb44f9..97f1c308 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -158,12 +158,10 @@ Buffer::copy(const Context& context, const Buffer* src)
{
if (!_buf) {
return;
- } else if (is_audio() && src->is_audio()) {
- memcpy(_buf, src->_buf, src->_capacity);
} else if (_type == src->type()) {
- const LV2_Atom* src_atom = src->get<const LV2_Atom>();
- if (lv2_atom_total_size(src_atom) <= _capacity) {
- memcpy(_buf, src_atom, lv2_atom_total_size(src_atom));
+ const uint32_t src_size = src->size();
+ if (src_size <= _capacity) {
+ memcpy(_buf, src->_buf, src_size);
} else {
clear();
}
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index 11037dd1..aa732781 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -60,6 +60,9 @@ public:
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 {
+ return is_audio() ? _capacity : sizeof(LV2_Atom) + get<LV2_Atom>()->size;
+ }
void set_type(LV2_URID type, LV2_URID value_type);
diff --git a/src/server/InternalBlock.cpp b/src/server/InternalBlock.cpp
index 5fa0bdc0..308cb640 100644
--- a/src/server/InternalBlock.cpp
+++ b/src/server/InternalBlock.cpp
@@ -31,15 +31,17 @@ InternalBlock::InternalBlock(PluginImpl* plugin,
void
-InternalBlock::pre_process(ProcessContext& context) {
- /* Output sequences are initialized in LV2 format, an atom:Chunk with size
- set to the capacity of the buffer. Internal nodes don't care, so clear
- to an empty sequences so appending events results in a valid output. */
+InternalBlock::pre_process(ProcessContext& context)
+{
for (uint32_t i = 0; i < num_ports(); ++i) {
PortImpl* const port = _ports->at(i);
if (port->is_input()) {
port->pre_process(context);
- } else {
+ } else if (port->buffer_type() == _plugin->uris().atom_Sequence) {
+ /* Output sequences are initialized in LV2 format, an atom:Chunk
+ with size set to the capacity of the buffer. Internal nodes
+ don't care, so clear to an empty sequences so appending events
+ results in a valid output. */
for (uint32_t v = 0; v < port->poly(); ++v) {
port->buffer(v)->clear();
}