aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jalv.c8
-rw-r--r--src/jalv_internal.h1
-rw-r--r--src/lv2_evbuf.c40
-rw-r--r--src/lv2_evbuf.h13
4 files changed, 44 insertions, 18 deletions
diff --git a/src/jalv.c b/src/jalv.c
index 5a76deb..5f89962 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -225,7 +225,9 @@ jalv_allocate_port_buffers(Jalv* jalv)
lv2_evbuf_free(port->evbuf);
port->evbuf = lv2_evbuf_new(
jalv->midi_buf_size,
- port->old_api ? LV2_EVBUF_EVENT : LV2_EVBUF_ATOM);
+ port->old_api ? LV2_EVBUF_EVENT : LV2_EVBUF_ATOM,
+ jalv->map.map(jalv->map.handle,
+ lilv_node_as_string(jalv->seq_class)));
lilv_instance_connect_port(
jalv->instance, i, lv2_evbuf_get_buffer(port->evbuf));
default: break;
@@ -427,6 +429,7 @@ jack_process_cb(jack_nframes_t nframes, void* data)
uint8_t* data;
lv2_evbuf_get(i, &frames, &subframes,
&type, &size, &data);
+ // FIXME: check type
jack_midi_event_write(buf, frames, data, size);
/* TODO: Be more disciminate about what to send */
@@ -622,7 +625,8 @@ main(int argc, char** argv)
host.control_class = lilv_new_uri(world, LILV_URI_CONTROL_PORT);
host.audio_class = lilv_new_uri(world, LILV_URI_AUDIO_PORT);
host.event_class = lilv_new_uri(world, LILV_URI_EVENT_PORT);
- host.msg_port_class = lilv_new_uri(world, NS_ATOM "MessagePort");
+ host.seq_class = lilv_new_uri(world, LV2_ATOM__Sequence);
+ host.msg_port_class = lilv_new_uri(world, LV2_ATOM__MessagePort);
host.midi_class = lilv_new_uri(world, LILV_URI_MIDI_EVENT);
host.preset_class = lilv_new_uri(world, NS_PSET "Preset");
host.label_pred = lilv_new_uri(world, LILV_NS_RDFS "label");
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 1dc225f..474da83 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -121,6 +121,7 @@ typedef struct {
LilvNode* control_class; ///< Control port class (URI)
LilvNode* audio_class; ///< Audio port class (URI)
LilvNode* event_class; ///< Event port class (URI)
+ LilvNode* seq_class; ///< Atom sequence class (URI)
LilvNode* msg_port_class; ///< Atom event port class (URI)
LilvNode* midi_class; ///< MIDI event class (URI)
LilvNode* preset_class; ///< Preset class (URI)
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
diff --git a/src/lv2_evbuf.h b/src/lv2_evbuf.h
index e637b9e..b2caa12 100644
--- a/src/lv2_evbuf.h
+++ b/src/lv2_evbuf.h
@@ -54,9 +54,11 @@ typedef struct {
/**
Allocate a new, empty event buffer.
+ The URID for atom:Sequence must be passed for atom_Sequence if type is
+ LV2_EVBUF_ATOM.
*/
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);
/**
Free an event buffer allocated with lv2_evbuf_new.
@@ -65,6 +67,15 @@ void
lv2_evbuf_free(LV2_Evbuf* evbuf);
/**
+ Change the type of an existing event buffer. This will clear and reset the
+ buffer, it is not possible to change the type and preserve the buffer
+ contents since the formats differ. The URID for atom:Sequence must be
+ passed for atom_Sequence if type is LV2_EVBUF_ATOM.
+*/
+void
+lv2_evbuf_set_type(LV2_Evbuf* evbuf, LV2_Evbuf_Type type, uint32_t atom_type);
+
+/**
Clear and initialize an existing event buffer.
The contents of buf are ignored entirely and overwritten, except capacity
which is unmodified.