aboutsummaryrefslogtreecommitdiffstats
path: root/src/lv2_evbuf.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-02-12 04:19:28 +0000
committerDavid Robillard <d@drobilla.net>2012-02-12 04:19:28 +0000
commit09752457f076c8dd38a116662eba0ac6b1d3e6a2 (patch)
tree9c9d9d4a53b5e20cc7e880f24a74b8966f0d7370 /src/lv2_evbuf.c
parentf78c89077b50934001b63efc4b3a9742dcd0b738 (diff)
downloadjalv-09752457f076c8dd38a116662eba0ac6b1d3e6a2.tar.gz
jalv-09752457f076c8dd38a116662eba0ac6b1d3e6a2.tar.bz2
jalv-09752457f076c8dd38a116662eba0ac6b1d3e6a2.zip
Update for latest atom extension.
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@3982 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/lv2_evbuf.c')
-rw-r--r--src/lv2_evbuf.c21
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;
}