summaryrefslogtreecommitdiffstats
path: root/src/server/Buffer.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-12-14 14:44:32 -0500
committerDavid Robillard <d@drobilla.net>2016-12-14 14:47:13 -0500
commitbf71b4be9f36f9d7c619053d97ab6f98bb98dc21 (patch)
treeea1d8b78defdeec76026d24fbf507c75a97629d1 /src/server/Buffer.cpp
parenta2f86537a9fdaabe12b553a1cf066649a96b4891 (diff)
downloadingen-bf71b4be9f36f9d7c619053d97ab6f98bb98dc21.tar.gz
ingen-bf71b4be9f36f9d7c619053d97ab6f98bb98dc21.tar.bz2
ingen-bf71b4be9f36f9d7c619053d97ab6f98bb98dc21.zip
Fix real-time safety of control bindings
Diffstat (limited to 'src/server/Buffer.cpp')
-rw-r--r--src/server/Buffer.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index 71dd320a..cf313b67 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -341,6 +341,30 @@ Buffer::append_event(int64_t frames, const LV2_Atom* body)
return append_event(frames, body->size, body->type, (const uint8_t*)(body + 1));
}
+bool
+Buffer::append_event_buffer(const Buffer* buf)
+{
+ LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)get<LV2_Atom>();
+ LV2_Atom_Sequence* bseq = (LV2_Atom_Sequence*)buf->get<LV2_Atom>();
+ if (seq->atom.type == _factory.uris().atom_Chunk) {
+ clear(); // Chunk initialized with prepare_output_write(), clear
+ }
+
+ const uint32_t total_size = lv2_atom_total_size(&seq->atom);
+ uint8_t* const end = (uint8_t*)seq + total_size;
+ const uint32_t n_bytes = bseq->atom.size - sizeof(bseq->body);
+ if (sizeof(LV2_Atom) + total_size + n_bytes >= _capacity) {
+ return false; // Not enough space
+ }
+
+ memcpy(end, bseq + 1, n_bytes);
+ seq->atom.size += n_bytes;
+
+ _latest_event = std::max(_latest_event, buf->_latest_event);
+
+ return true;
+}
+
SampleCount
Buffer::next_value_offset(SampleCount offset, SampleCount end) const
{