aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jalv.c2
-rw-r--r--src/lv2_evbuf.c21
-rw-r--r--src/lv2_evbuf.h8
3 files changed, 28 insertions, 3 deletions
diff --git a/src/jalv.c b/src/jalv.c
index 8018c13..b8e550e 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -369,6 +369,8 @@ jack_process_cb(jack_nframes_t nframes, void* data)
host->midi_event_id,
ev.size, ev.buffer);
}
+ } else {
+ lv2_evbuf_prepare_write(host->ports[p].evbuf);
}
}
}
diff --git a/src/lv2_evbuf.c b/src/lv2_evbuf.c
index fed63f4..2e13a58 100644
--- a/src/lv2_evbuf.c
+++ b/src/lv2_evbuf.c
@@ -26,6 +26,7 @@
struct LV2_Evbuf_Impl {
LV2_Evbuf_Type type;
+ uint32_t capacity;
union {
LV2_Event_Buffer event;
LV2_Atom_Sequence atom;
@@ -41,8 +42,10 @@ lv2_evbuf_pad_size(uint32_t size)
LV2_Evbuf*
lv2_evbuf_new(uint32_t capacity, LV2_Evbuf_Type type)
{
+ // FIXME: memory must be 64-bit aligned
LV2_Evbuf* evbuf = (LV2_Evbuf*)malloc(sizeof(LV2_Evbuf) + capacity);
- evbuf->type = type;
+ evbuf->type = type;
+ evbuf->capacity = capacity;
switch (type) {
case LV2_EVBUF_EVENT:
evbuf->buf.event.data = (uint8_t*)evbuf + sizeof(LV2_Evbuf);
@@ -50,7 +53,7 @@ lv2_evbuf_new(uint32_t capacity, LV2_Evbuf_Type type)
break;
case LV2_EVBUF_ATOM:
// FIXME: set type
- evbuf->buf.atom.capacity = capacity;
+ break;
}
lv2_evbuf_reset(evbuf);
return evbuf;
@@ -77,6 +80,18 @@ lv2_evbuf_reset(LV2_Evbuf* evbuf)
}
}
+void
+lv2_evbuf_prepare_write(LV2_Evbuf* evbuf)
+{
+ switch (evbuf->type) {
+ case LV2_EVBUF_EVENT:
+ break;
+ case LV2_EVBUF_ATOM:
+ evbuf->buf.atom.atom.type = 0;
+ evbuf->buf.atom.atom.size = evbuf->capacity;
+ }
+}
+
uint32_t
lv2_evbuf_get_size(LV2_Evbuf* evbuf)
{
@@ -223,7 +238,7 @@ lv2_evbuf_write(LV2_Evbuf_Iterator* iter,
break;
case LV2_EVBUF_ATOM:
abuf = &iter->evbuf->buf.atom;
- if (abuf->capacity - abuf->atom.size < sizeof(LV2_Atom_Event) + size) {
+ if (iter->evbuf->capacity - abuf->atom.size < sizeof(LV2_Atom_Event) + size) {
return false;
}
diff --git a/src/lv2_evbuf.h b/src/lv2_evbuf.h
index e637b9e..b4d8aea 100644
--- a/src/lv2_evbuf.h
+++ b/src/lv2_evbuf.h
@@ -73,6 +73,14 @@ void
lv2_evbuf_reset(LV2_Evbuf* evbuf);
/**
+ Initialize the event buffer before it is written to.
+ This MUST be called for all output event buffers immediately before running
+ the plugin every time run is to be called.
+*/
+void
+lv2_evbuf_prepare_write(LV2_Evbuf* evbuf);
+
+/**
Return the total padded size of the events stored in the buffer.
*/
uint32_t