aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-02-08 02:34:23 +0000
committerDavid Robillard <d@drobilla.net>2012-02-08 02:34:23 +0000
commit25fa846f0c9bb91ad3ec635e5b53a631e04de381 (patch)
tree401678b8addabcbd34f0e61bca72f5cca937dc07 /src
parent54ae794994cf19b26f2f43391a24b06d501c1da7 (diff)
downloadjalv-25fa846f0c9bb91ad3ec635e5b53a631e04de381.tar.gz
jalv-25fa846f0c9bb91ad3ec635e5b53a631e04de381.tar.bz2
jalv-25fa846f0c9bb91ad3ec635e5b53a631e04de381.zip
Update for latest Atom extension.
Probably fix #802. git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@3976 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/jalv.c35
-rw-r--r--src/jalv_internal.h2
-rw-r--r--src/lv2_evbuf.c92
-rw-r--r--src/lv2_evbuf.h36
4 files changed, 76 insertions, 89 deletions
diff --git a/src/jalv.c b/src/jalv.c
index 1ebdff3..6ee017e 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -177,7 +177,7 @@ create_port(Jalv* host,
port->type = TYPE_EVENT;
port->old_api = true;
} else if (lilv_port_is_a(host->plugin, port->lilv_port,
- host->aevent_class)) {
+ host->msg_port_class)) {
port->type = TYPE_EVENT;
port->old_api = false;
} else if (!optional) {
@@ -394,7 +394,7 @@ jack_process_cb(jack_nframes_t nframes, void* data)
LV2_Evbuf_Iterator i = lv2_evbuf_end(port->evbuf);
const LV2_Atom* const atom = (const LV2_Atom*)body;
lv2_evbuf_write(&i, nframes, 0,
- atom->type, atom->size, atom->body);
+ atom->type, atom->size, LV2_ATOM_BODY(atom));
} else {
fprintf(stderr, "error: Unknown control change protocol %d\n",
ev.protocol);
@@ -422,15 +422,14 @@ jack_process_cb(jack_nframes_t nframes, void* data)
void* buf = jack_port_get_buffer(port->jack_port, nframes);
jack_midi_clear_buffer(buf);
- LV2_Evbuf_Iterator iter = lv2_evbuf_begin(port->evbuf);
- const uint32_t count = lv2_evbuf_get_event_count(iter.evbuf);
- for (uint32_t i = 0; i < count; ++i) {
+ for (LV2_Evbuf_Iterator i = lv2_evbuf_begin(port->evbuf);
+ lv2_evbuf_is_valid(i);
+ i = lv2_evbuf_next(i)) {
uint32_t frames, subframes, type, size;
uint8_t* data;
- lv2_evbuf_get(iter, &frames, &subframes,
+ lv2_evbuf_get(i, &frames, &subframes,
&type, &size, &data);
jack_midi_event_write(buf, frames, data, size);
- iter = lv2_evbuf_next(iter);
}
} else if (send_ui_updates
&& port->flow != FLOW_INPUT
@@ -603,17 +602,17 @@ main(int argc, char** argv)
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
/* Set up the port classes this app supports */
- host.input_class = lilv_new_uri(world, LILV_URI_INPUT_PORT);
- host.output_class = lilv_new_uri(world, LILV_URI_OUTPUT_PORT);
- 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.aevent_class = lilv_new_uri(world, NS_ATOM "EventPort");
- 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");
- host.optional = lilv_new_uri(world, LILV_NS_LV2
- "connectionOptional");
+ host.input_class = lilv_new_uri(world, LILV_URI_INPUT_PORT);
+ host.output_class = lilv_new_uri(world, LILV_URI_OUTPUT_PORT);
+ 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.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");
+ host.optional = lilv_new_uri(world, LILV_NS_LV2
+ "connectionOptional");
/* Get plugin URI from loaded state or command line */
LilvState* state = NULL;
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 9b6e524..4dc4310 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -118,7 +118,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* aevent_class; ///< Atom event port class (URI)
+ LilvNode* msg_port_class; ///< Atom event port class (URI)
LilvNode* midi_class; ///< MIDI event class (URI)
LilvNode* preset_class; ///< Preset class (URI)
LilvNode* label_pred; ///< rdfs:label
diff --git a/src/lv2_evbuf.c b/src/lv2_evbuf.c
index 6cbffe3..fed63f4 100644
--- a/src/lv2_evbuf.c
+++ b/src/lv2_evbuf.c
@@ -1,5 +1,5 @@
/*
- Copyright 2008-2011 David Robillard <http://drobilla.net>
+ Copyright 2008-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -19,17 +19,17 @@
#include <string.h>
#include <stdlib.h>
-#include "lv2/lv2plug.in/ns/ext/atom/atom-buffer.h"
+#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "lv2/lv2plug.in/ns/ext/event/event.h"
#include "lv2_evbuf.h"
struct LV2_Evbuf_Impl {
+ LV2_Evbuf_Type type;
union {
- LV2_Event_Buffer event;
- LV2_Atom_Buffer atom;
+ LV2_Event_Buffer event;
+ LV2_Atom_Sequence atom;
} buf;
- LV2_Evbuf_Type type;
};
static inline uint32_t
@@ -41,13 +41,15 @@ lv2_evbuf_pad_size(uint32_t size)
LV2_Evbuf*
lv2_evbuf_new(uint32_t capacity, LV2_Evbuf_Type type)
{
- LV2_Evbuf* evbuf = (LV2_Evbuf*)malloc(sizeof(LV2_Evbuf));
+ LV2_Evbuf* evbuf = (LV2_Evbuf*)malloc(sizeof(LV2_Evbuf) + capacity);
evbuf->type = type;
switch (type) {
case LV2_EVBUF_EVENT:
+ evbuf->buf.event.data = (uint8_t*)evbuf + sizeof(LV2_Evbuf);
evbuf->buf.event.capacity = capacity;
break;
case LV2_EVBUF_ATOM:
+ // FIXME: set type
evbuf->buf.atom.capacity = capacity;
}
lv2_evbuf_reset(evbuf);
@@ -71,8 +73,7 @@ lv2_evbuf_reset(LV2_Evbuf* evbuf)
evbuf->buf.event.size = 0;
break;
case LV2_EVBUF_ATOM:
- evbuf->buf.atom.event_count = 0;
- evbuf->buf.atom.size = 0;
+ evbuf->buf.atom.atom.size = 0;
}
}
@@ -83,19 +84,7 @@ lv2_evbuf_get_size(LV2_Evbuf* evbuf)
case LV2_EVBUF_EVENT:
return evbuf->buf.event.size;
case LV2_EVBUF_ATOM:
- return evbuf->buf.atom.size;
- }
- return 0;
-}
-
-uint32_t
-lv2_evbuf_get_event_count(LV2_Evbuf* evbuf)
-{
- switch (evbuf->type) {
- case LV2_EVBUF_EVENT:
- return evbuf->buf.event.event_count;
- case LV2_EVBUF_ATOM:
- return evbuf->buf.atom.event_count;
+ return evbuf->buf.atom.atom.size;
}
return 0;
}
@@ -123,7 +112,7 @@ LV2_Evbuf_Iterator
lv2_evbuf_end(LV2_Evbuf* evbuf)
{
const size_t size = lv2_evbuf_get_size(evbuf);
- const LV2_Evbuf_Iterator iter = { evbuf, lv2_atom_pad_size(size) };
+ const LV2_Evbuf_Iterator iter = { evbuf, lv2_evbuf_pad_size(size) };
return iter;
}
@@ -140,19 +129,22 @@ lv2_evbuf_next(LV2_Evbuf_Iterator iter)
return iter;
}
- LV2_Evbuf* evbuf = iter.evbuf;
- uint32_t size;
- uint32_t offset = iter.offset;
+ LV2_Evbuf* evbuf = iter.evbuf;
+ uint32_t offset = iter.offset;
+ uint32_t size;
switch (evbuf->type) {
case LV2_EVBUF_EVENT:
- size = ((LV2_Event*)(evbuf->buf.event.data + offset))->size;
+ size = ((LV2_Event*)(evbuf->buf.event.data + offset))->size;
+ offset += lv2_evbuf_pad_size(sizeof(LV2_Event) + size);
break;
case LV2_EVBUF_ATOM:
- size = ((LV2_Atom_Event*)(evbuf->buf.atom.data + offset))->body.size;
+ size = ((LV2_Atom_Event*)
+ ((char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, &evbuf->buf.atom)
+ + offset))->body.size;
+ offset += lv2_evbuf_pad_size(sizeof(LV2_Atom_Event) + size);
break;
}
- offset += lv2_evbuf_pad_size(sizeof(LV2_Atom_Event) + size);
LV2_Evbuf_Iterator next = { evbuf, offset };
return next;
}
@@ -184,12 +176,14 @@ lv2_evbuf_get(LV2_Evbuf_Iterator iter,
*data = (uint8_t*)ev + sizeof(LV2_Event);
break;
case LV2_EVBUF_ATOM:
- aev = (LV2_Atom_Event*)(iter.evbuf->buf.atom.data + iter.offset);
- *frames = aev->frames;
- *subframes = aev->subframes;
+ aev = (LV2_Atom_Event*)(
+ (char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, &iter.evbuf->buf.atom)
+ + iter.offset);
+ *frames = aev->time.audio.frames;
+ *subframes = aev->time.audio.subframes;
*type = aev->body.type;
*size = aev->body.size;
- *data = aev->body.body;
+ *data = LV2_ATOM_BODY(&aev->body);
break;
}
@@ -204,10 +198,10 @@ lv2_evbuf_write(LV2_Evbuf_Iterator* iter,
uint32_t size,
const uint8_t* data)
{
- LV2_Event_Buffer* ebuf;
- LV2_Event* ev;
- LV2_Atom_Buffer* abuf;
- LV2_Atom_Event* aev;
+ LV2_Event_Buffer* ebuf;
+ LV2_Event* ev;
+ LV2_Atom_Sequence* abuf;
+ LV2_Atom_Event* aev;
switch (iter->evbuf->type) {
case LV2_EVBUF_EVENT:
ebuf = &iter->evbuf->buf.event;
@@ -229,22 +223,22 @@ lv2_evbuf_write(LV2_Evbuf_Iterator* iter,
break;
case LV2_EVBUF_ATOM:
abuf = &iter->evbuf->buf.atom;
- if (abuf->capacity - abuf->size < sizeof(LV2_Atom_Event) + size) {
+ if (abuf->capacity - abuf->atom.size < sizeof(LV2_Atom_Event) + size) {
return false;
}
- aev = (LV2_Atom_Event*)(abuf->data + iter->offset);
- aev->frames = frames;
- aev->subframes = subframes;
- aev->body.type = type;
- aev->body.size = size;
- memcpy(aev->body.body, data, size);
- ++abuf->event_count;
-
- size = lv2_atom_pad_size(sizeof(LV2_Atom_Event) + size);
- abuf->size += size;
- abuf->event_count += 1;
- iter->offset += size;
+ aev = (LV2_Atom_Event*)(
+ (char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, abuf)
+ + iter->offset);
+ aev->time.audio.frames = frames;
+ aev->time.audio.subframes = subframes;
+ aev->body.type = type;
+ aev->body.size = size;
+ memcpy(LV2_ATOM_BODY(&aev->body), data, size);
+
+ size = lv2_evbuf_pad_size(sizeof(LV2_Atom_Event) + size);
+ abuf->atom.size += size;
+ iter->offset += size;
break;
}
diff --git a/src/lv2_evbuf.h b/src/lv2_evbuf.h
index da0713e..e637b9e 100644
--- a/src/lv2_evbuf.h
+++ b/src/lv2_evbuf.h
@@ -1,5 +1,5 @@
/*
- Copyright 2008-2011 David Robillard <http://drobilla.net>
+ Copyright 2008-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -29,12 +29,12 @@ extern "C" {
*/
typedef enum {
/**
- An old ev:EventBuffer (LV2_Event_Buffer).
+ An (old) ev:EventBuffer (LV2_Event_Buffer).
*/
LV2_EVBUF_EVENT,
/**
- A new atom:EventBuffer (LV2_Atom_Event_Buffer).
+ A (new) atom:Sequence (LV2_Atom_Sequence).
*/
LV2_EVBUF_ATOM
} LV2_Evbuf_Type;
@@ -79,12 +79,6 @@ uint32_t
lv2_evbuf_get_size(LV2_Evbuf* evbuf);
/**
- Return the number of events stored in the buffer.
-*/
-uint32_t
-lv2_evbuf_get_event_count(LV2_Evbuf* evbuf);
-
-/**
Return the actual buffer implementation.
The format of the buffer returned depends on the buffer type.
*/
@@ -92,7 +86,7 @@ void*
lv2_evbuf_get_buffer(LV2_Evbuf* evbuf);
/**
- Return an iterator to the start of @a buf.
+ Return an iterator to the start of @p buf.
*/
LV2_Evbuf_Iterator
lv2_evbuf_begin(LV2_Evbuf* evbuf);
@@ -104,26 +98,26 @@ LV2_Evbuf_Iterator
lv2_evbuf_end(LV2_Evbuf* evbuf);
/**
- Check if @a iter is valid.
- @return True if @a iter is valid, otherwise false (past end of buffer)
+ Check if @p iter is valid.
+ @return True if @p iter is valid, otherwise false (past end of buffer)
*/
bool
lv2_evbuf_is_valid(LV2_Evbuf_Iterator iter);
/**
- Advance @a iter forward one event.
- @a iter must be valid.
- @return True if @a iter is valid, otherwise false (reached end of buffer)
+ Advance @p iter forward one event.
+ @p iter must be valid.
+ @return True if @p iter is valid, otherwise false (reached end of buffer)
*/
LV2_Evbuf_Iterator
lv2_evbuf_next(LV2_Evbuf_Iterator iter);
/**
Dereference an event iterator (i.e. get the event currently pointed to).
- @a iter must be valid.
- @a type Set to the type of the event.
- @a size Set to the size of the event.
- @a data Set to the contents of the event.
+ @p iter must be valid.
+ @p type Set to the type of the event.
+ @p size Set to the size of the event.
+ @p data Set to the contents of the event.
@return True on success.
*/
bool
@@ -135,8 +129,8 @@ lv2_evbuf_get(LV2_Evbuf_Iterator iter,
uint8_t** data);
/**
- Write an event at @a iter.
- The event (if any) pointed to by @a iter will be overwritten, and @a iter
+ Write an event at @p iter.
+ The event (if any) pointed to by @p iter will be overwritten, and @p iter
incremented to point to the following event (i.e. several calls to this
function can be done in sequence without twiddling iter in-between).
@return True if event was written, otherwise false (buffer is full).