summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/EventBuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine/EventBuffer.cpp')
-rw-r--r--src/libs/engine/EventBuffer.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/libs/engine/EventBuffer.cpp b/src/libs/engine/EventBuffer.cpp
index 9985e2b7..dfeff610 100644
--- a/src/libs/engine/EventBuffer.cpp
+++ b/src/libs/engine/EventBuffer.cpp
@@ -178,6 +178,9 @@ EventBuffer::append(uint32_t frames,
}
#endif
+ /*cout << "Appending event type " << type << ", size " << size
+ << " @ " << frames << "." << subframes << endl;*/
+
bool ret = lv2_event_write(&_iter, frames, subframes, type, size, data);
if (!ret)
@@ -190,6 +193,43 @@ EventBuffer::append(uint32_t frames,
}
+/** Append a buffer of events to the buffer.
+ *
+ * \a timestamp must be >= the latest event in the buffer,
+ * and < this_nframes()
+ *
+ * \return true on success
+ */
+bool
+EventBuffer::append(const LV2_Event_Buffer* buf)
+{
+ uint8_t** data;
+ bool ret = true;
+
+ LV2_Event_Iterator iter;
+ for (lv2_event_begin(&iter, _buf); lv2_event_is_valid(&iter); lv2_event_increment(&iter)) {
+ LV2_Event* ev = lv2_event_get(&iter, data);
+
+#ifndef NDEBUG
+ assert((ev->frames > _latest_frames)
+ || (ev->frames == _latest_frames
+ && ev->subframes >= _latest_subframes));
+#endif
+
+ if (!(ret = append(ev->frames, ev->subframes, ev->type, ev->size, *data))) {
+ cerr << "ERROR: Failed to write event." << endl;
+ break;
+ } else {
+ }
+
+ _latest_frames = ev->frames;
+ _latest_subframes = ev->subframes;
+ }
+
+ return ret;
+}
+
+
/** Read an event from the current position in the buffer
*
* \return true if read was successful, or false if end of buffer reached