diff options
Diffstat (limited to 'src/lv2_evbuf.c')
-rw-r--r-- | src/lv2_evbuf.c | 21 |
1 files changed, 18 insertions, 3 deletions
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; } |