From 574cb313ce5c2c60976fd243e212529ce86b566b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 28 Feb 2012 00:15:20 +0000 Subject: Update LV2_Evbuf (matches that used in current ardour 3.0). git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@4003 a436a847-0d15-0410-975c-d299462d15a1 --- src/lv2_evbuf.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'src/lv2_evbuf.c') diff --git a/src/lv2_evbuf.c b/src/lv2_evbuf.c index 0a2fd31..7877e07 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_Port_Buffer atom; @@ -39,32 +40,41 @@ lv2_evbuf_pad_size(uint32_t size) } LV2_Evbuf* -lv2_evbuf_new(uint32_t capacity, LV2_Evbuf_Type type) +lv2_evbuf_new(uint32_t capacity, LV2_Evbuf_Type type, uint32_t atom_type) { // FIXME: memory must be 64-bit aligned - LV2_Evbuf* evbuf = (LV2_Evbuf*)malloc(sizeof(LV2_Evbuf) + capacity); + LV2_Evbuf* evbuf = (LV2_Evbuf*)malloc( + sizeof(LV2_Evbuf) + sizeof(LV2_Atom_Sequence) + capacity); + evbuf->capacity = capacity; + lv2_evbuf_set_type(evbuf, type, atom_type); + lv2_evbuf_reset(evbuf); + return evbuf; +} + +void +lv2_evbuf_free(LV2_Evbuf* evbuf) +{ + free(evbuf); +} + +void +lv2_evbuf_set_type(LV2_Evbuf* evbuf, LV2_Evbuf_Type type, uint32_t atom_type) +{ evbuf->type = type; switch (type) { case LV2_EVBUF_EVENT: - evbuf->buf.event.data = (uint8_t*)evbuf + sizeof(LV2_Evbuf); - evbuf->buf.event.capacity = capacity; + evbuf->buf.event.data = (uint8_t*)(evbuf + 1); + evbuf->buf.event.capacity = evbuf->capacity; break; case LV2_EVBUF_ATOM: - evbuf->buf.atom.data = (LV2_Atom*)((uint8_t*)evbuf + sizeof(LV2_Evbuf)); - evbuf->buf.atom.size = sizeof(LV2_Atom_Port_Buffer); - evbuf->buf.atom.capacity = capacity - sizeof(LV2_Atom); - evbuf->buf.atom.data->type = 0; // FIXME: set type to atom:Sequence + evbuf->buf.atom.data = (LV2_Atom*)(evbuf + 1); + evbuf->buf.atom.size = sizeof(LV2_Atom_Port_Buffer); + evbuf->buf.atom.capacity = evbuf->capacity; + evbuf->buf.atom.data->type = atom_type; evbuf->buf.atom.data->size = 0; break; } lv2_evbuf_reset(evbuf); - return evbuf; -} - -void -lv2_evbuf_free(LV2_Evbuf* evbuf) -{ - free(evbuf); } void -- cgit v1.2.1