aboutsummaryrefslogtreecommitdiffstats
path: root/lv2
diff options
context:
space:
mode:
Diffstat (limited to 'lv2')
-rw-r--r--lv2/atom/atom-test-utils.c44
-rw-r--r--lv2/atom/atom-test.c668
-rw-r--r--lv2/atom/atom.h113
-rw-r--r--lv2/atom/forge-overflow-test.c292
-rw-r--r--lv2/atom/forge.h422
-rw-r--r--lv2/atom/util.h347
-rw-r--r--lv2/buf-size/buf-size.h2
-rw-r--r--lv2/core/attributes.h24
-rw-r--r--lv2/core/lv2.h452
-rw-r--r--lv2/core/lv2_util.h55
-rw-r--r--lv2/data-access/data-access.h30
-rw-r--r--lv2/dynmanifest/dynmanifest.h21
-rw-r--r--lv2/event/event-helpers.h189
-rw-r--r--lv2/event/event.h349
-rw-r--r--lv2/instance-access/instance-access.h2
-rw-r--r--lv2/log/log.h74
-rw-r--r--lv2/log/logger.h84
-rw-r--r--lv2/midi/midi.h227
-rw-r--r--lv2/morph/morph.h2
-rw-r--r--lv2/options/options.h108
-rw-r--r--lv2/parameters/parameters.h2
-rw-r--r--lv2/patch/patch.h2
-rw-r--r--lv2/port-groups/port-groups.h2
-rw-r--r--lv2/port-props/port-props.h2
-rw-r--r--lv2/presets/presets.h2
-rw-r--r--lv2/resize-port/resize-port.h40
-rw-r--r--lv2/state/state.h441
-rw-r--r--lv2/time/time.h2
-rw-r--r--lv2/ui/ui.h579
-rw-r--r--lv2/units/units.h2
-rw-r--r--lv2/uri-map/uri-map.h78
-rw-r--r--lv2/urid/urid.h98
-rw-r--r--lv2/worker/worker.h176
33 files changed, 2443 insertions, 2488 deletions
diff --git a/lv2/atom/atom-test-utils.c b/lv2/atom/atom-test-utils.c
index 50e8887..b015cec 100644
--- a/lv2/atom/atom-test-utils.c
+++ b/lv2/atom/atom-test-utils.c
@@ -30,44 +30,44 @@ static uint32_t n_uris = 0;
static char*
copy_string(const char* str)
{
- const size_t len = strlen(str);
- char* dup = (char*)malloc(len + 1);
- memcpy(dup, str, len + 1);
- return dup;
+ const size_t len = strlen(str);
+ char* dup = (char*)malloc(len + 1);
+ memcpy(dup, str, len + 1);
+ return dup;
}
static LV2_URID
urid_map(LV2_URID_Map_Handle handle, const char* uri)
{
- for (uint32_t i = 0; i < n_uris; ++i) {
- if (!strcmp(uris[i], uri)) {
- return i + 1;
- }
- }
+ for (uint32_t i = 0; i < n_uris; ++i) {
+ if (!strcmp(uris[i], uri)) {
+ return i + 1;
+ }
+ }
- uris = (char**)realloc(uris, ++n_uris * sizeof(char*));
- uris[n_uris - 1] = copy_string(uri);
- return n_uris;
+ uris = (char**)realloc(uris, ++n_uris * sizeof(char*));
+ uris[n_uris - 1] = copy_string(uri);
+ return n_uris;
}
static void
free_urid_map(void)
{
- for (uint32_t i = 0; i < n_uris; ++i) {
- free(uris[i]);
- }
+ for (uint32_t i = 0; i < n_uris; ++i) {
+ free(uris[i]);
+ }
- free(uris);
+ free(uris);
}
LV2_LOG_FUNC(1, 2)
static int
test_fail(const char* fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- fprintf(stderr, "error: ");
- vfprintf(stderr, fmt, args);
- va_end(args);
- return 1;
+ va_list args;
+ va_start(args, fmt);
+ fprintf(stderr, "error: ");
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ return 1;
}
diff --git a/lv2/atom/atom-test.c b/lv2/atom/atom-test.c
index 24f176e..39095a3 100644
--- a/lv2/atom/atom-test.c
+++ b/lv2/atom/atom-test.c
@@ -29,341 +29,339 @@
int
main(void)
{
- LV2_URID_Map map = { NULL, urid_map };
- LV2_Atom_Forge forge;
- lv2_atom_forge_init(&forge, &map);
-
- LV2_URID eg_Object = urid_map(NULL, "http://example.org/Object");
- LV2_URID eg_one = urid_map(NULL, "http://example.org/one");
- LV2_URID eg_two = urid_map(NULL, "http://example.org/two");
- LV2_URID eg_three = urid_map(NULL, "http://example.org/three");
- LV2_URID eg_four = urid_map(NULL, "http://example.org/four");
- LV2_URID eg_true = urid_map(NULL, "http://example.org/true");
- LV2_URID eg_false = urid_map(NULL, "http://example.org/false");
- LV2_URID eg_path = urid_map(NULL, "http://example.org/path");
- LV2_URID eg_uri = urid_map(NULL, "http://example.org/uri");
- LV2_URID eg_urid = urid_map(NULL, "http://example.org/urid");
- LV2_URID eg_string = urid_map(NULL, "http://example.org/string");
- LV2_URID eg_literal = urid_map(NULL, "http://example.org/literal");
- LV2_URID eg_tuple = urid_map(NULL, "http://example.org/tuple");
- LV2_URID eg_vector = urid_map(NULL, "http://example.org/vector");
- LV2_URID eg_vector2 = urid_map(NULL, "http://example.org/vector2");
- LV2_URID eg_seq = urid_map(NULL, "http://example.org/seq");
-
-#define BUF_SIZE 1024
+ LV2_URID_Map map = {NULL, urid_map};
+ LV2_Atom_Forge forge;
+ lv2_atom_forge_init(&forge, &map);
+
+ LV2_URID eg_Object = urid_map(NULL, "http://example.org/Object");
+ LV2_URID eg_one = urid_map(NULL, "http://example.org/one");
+ LV2_URID eg_two = urid_map(NULL, "http://example.org/two");
+ LV2_URID eg_three = urid_map(NULL, "http://example.org/three");
+ LV2_URID eg_four = urid_map(NULL, "http://example.org/four");
+ LV2_URID eg_true = urid_map(NULL, "http://example.org/true");
+ LV2_URID eg_false = urid_map(NULL, "http://example.org/false");
+ LV2_URID eg_path = urid_map(NULL, "http://example.org/path");
+ LV2_URID eg_uri = urid_map(NULL, "http://example.org/uri");
+ LV2_URID eg_urid = urid_map(NULL, "http://example.org/urid");
+ LV2_URID eg_string = urid_map(NULL, "http://example.org/string");
+ LV2_URID eg_literal = urid_map(NULL, "http://example.org/literal");
+ LV2_URID eg_tuple = urid_map(NULL, "http://example.org/tuple");
+ LV2_URID eg_vector = urid_map(NULL, "http://example.org/vector");
+ LV2_URID eg_vector2 = urid_map(NULL, "http://example.org/vector2");
+ LV2_URID eg_seq = urid_map(NULL, "http://example.org/seq");
+
+#define BUF_SIZE 1024
#define NUM_PROPS 15
- uint8_t buf[BUF_SIZE];
- lv2_atom_forge_set_buffer(&forge, buf, BUF_SIZE);
-
- LV2_Atom_Forge_Frame obj_frame;
- LV2_Atom* obj = lv2_atom_forge_deref(
- &forge, lv2_atom_forge_object(&forge, &obj_frame, 0, eg_Object));
-
- // eg_one = (Int)1
- lv2_atom_forge_key(&forge, eg_one);
- LV2_Atom_Int* one = (LV2_Atom_Int*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_int(&forge, 1));
- if (one->body != 1) {
- return test_fail("%d != 1\n", one->body);
- }
-
- // eg_two = (Long)2
- lv2_atom_forge_key(&forge, eg_two);
- LV2_Atom_Long* two = (LV2_Atom_Long*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_long(&forge, 2));
- if (two->body != 2) {
- return test_fail("%" PRId64 " != 2\n", two->body);
- }
-
- // eg_three = (Float)3.0
- lv2_atom_forge_key(&forge, eg_three);
- LV2_Atom_Float* three = (LV2_Atom_Float*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_float(&forge, 3.0f));
- if (three->body != 3) {
- return test_fail("%f != 3\n", three->body);
- }
-
- // eg_four = (Double)4.0
- lv2_atom_forge_key(&forge, eg_four);
- LV2_Atom_Double* four = (LV2_Atom_Double*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_double(&forge, 4.0));
- if (four->body != 4) {
- return test_fail("%f != 4\n", four->body);
- }
-
- // eg_true = (Bool)1
- lv2_atom_forge_key(&forge, eg_true);
- LV2_Atom_Bool* t = (LV2_Atom_Bool*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_bool(&forge, true));
- if (t->body != 1) {
- return test_fail("%d != 1 (true)\n", t->body);
- }
-
- // eg_false = (Bool)0
- lv2_atom_forge_key(&forge, eg_false);
- LV2_Atom_Bool* f = (LV2_Atom_Bool*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_bool(&forge, false));
- if (f->body != 0) {
- return test_fail("%d != 0 (false)\n", f->body);
- }
-
- // eg_path = (Path)"/foo/bar"
- const char* pstr = "/foo/bar";
- const uint32_t pstr_len = (uint32_t)strlen(pstr);
- lv2_atom_forge_key(&forge, eg_path);
- LV2_Atom_String* path = (LV2_Atom_String*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_uri(&forge, pstr, pstr_len));
- char* pbody = (char*)LV2_ATOM_BODY(path);
- if (strcmp(pbody, pstr)) {
- return test_fail("%s != \"%s\"\n", pbody, pstr);
- }
-
- // eg_uri = (URI)"http://example.org/value"
- const char* ustr = "http://example.org/value";
- const uint32_t ustr_len = (uint32_t)strlen(ustr);
- lv2_atom_forge_key(&forge, eg_uri);
- LV2_Atom_String* uri = (LV2_Atom_String*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_uri(&forge, ustr, ustr_len));
- char* ubody = (char*)LV2_ATOM_BODY(uri);
- if (strcmp(ubody, ustr)) {
- return test_fail("%s != \"%s\"\n", ubody, ustr);
- }
-
- // eg_urid = (URID)"http://example.org/value"
- LV2_URID eg_value = urid_map(NULL, "http://example.org/value");
- lv2_atom_forge_key(&forge, eg_urid);
- LV2_Atom_URID* urid = (LV2_Atom_URID*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_urid(&forge, eg_value));
- if (urid->body != eg_value) {
- return test_fail("%u != %u\n", urid->body, eg_value);
- }
-
- // eg_string = (String)"hello"
- lv2_atom_forge_key(&forge, eg_string);
- LV2_Atom_String* string = (LV2_Atom_String*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_string(
- &forge, "hello", strlen("hello")));
- char* sbody = (char*)LV2_ATOM_BODY(string);
- if (strcmp(sbody, "hello")) {
- return test_fail("%s != \"hello\"\n", sbody);
- }
-
- // eg_literal = (Literal)"hello"@fr
- lv2_atom_forge_key(&forge, eg_literal);
- LV2_Atom_Literal* literal = (LV2_Atom_Literal*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_literal(
- &forge, "bonjour", strlen("bonjour"),
- 0, urid_map(NULL, "http://lexvo.org/id/term/fr")));
- char* lbody = (char*)LV2_ATOM_CONTENTS(LV2_Atom_Literal, literal);
- if (strcmp(lbody, "bonjour")) {
- return test_fail("%s != \"bonjour\"\n", lbody);
- }
-
- // eg_tuple = "foo",true
- lv2_atom_forge_key(&forge, eg_tuple);
- LV2_Atom_Forge_Frame tuple_frame;
- LV2_Atom_Tuple* tuple = (LV2_Atom_Tuple*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_tuple(&forge, &tuple_frame));
- LV2_Atom_String* tup0 = (LV2_Atom_String*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_string(
- &forge, "foo", strlen("foo")));
- LV2_Atom_Bool* tup1 = (LV2_Atom_Bool*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_bool(&forge, true));
- lv2_atom_forge_pop(&forge, &tuple_frame);
- LV2_Atom* i = lv2_atom_tuple_begin(tuple);
- if (lv2_atom_tuple_is_end(LV2_ATOM_BODY(tuple), tuple->atom.size, i)) {
- return test_fail("Tuple iterator is empty\n");
- }
- LV2_Atom* tup0i = i;
- if (!lv2_atom_equals((LV2_Atom*)tup0, tup0i)) {
- return test_fail("Corrupt tuple element 0\n");
- }
- i = lv2_atom_tuple_next(i);
- if (lv2_atom_tuple_is_end(LV2_ATOM_BODY(tuple), tuple->atom.size, i)) {
- return test_fail("Premature end of tuple iterator\n");
- }
- LV2_Atom* tup1i = i;
- if (!lv2_atom_equals((LV2_Atom*)tup1, tup1i)) {
- return test_fail("Corrupt tuple element 1\n");
- }
- i = lv2_atom_tuple_next(i);
- if (!lv2_atom_tuple_is_end(LV2_ATOM_BODY(tuple), tuple->atom.size, i)) {
- return test_fail("Tuple iter is not at end\n");
- }
-
- // eg_vector = (Vector<Int>)1,2,3,4
- lv2_atom_forge_key(&forge, eg_vector);
- int32_t elems[] = { 1, 2, 3, 4 };
- LV2_Atom_Vector* vector = (LV2_Atom_Vector*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_vector(
- &forge, sizeof(int32_t), forge.Int, 4, elems));
- void* vec_body = LV2_ATOM_CONTENTS(LV2_Atom_Vector, vector);
- if (memcmp(elems, vec_body, sizeof(elems))) {
- return test_fail("Corrupt vector\n");
- }
-
- // eg_vector2 = (Vector<Int>)1,2,3,4
- lv2_atom_forge_key(&forge, eg_vector2);
- LV2_Atom_Forge_Frame vec_frame;
- LV2_Atom_Vector* vector2 = (LV2_Atom_Vector*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_vector_head(
- &forge, &vec_frame, sizeof(int32_t), forge.Int));
- for (unsigned e = 0; e < sizeof(elems) / sizeof(int32_t); ++e) {
- lv2_atom_forge_int(&forge, elems[e]);
- }
- lv2_atom_forge_pop(&forge, &vec_frame);
- if (!lv2_atom_equals(&vector->atom, &vector2->atom)) {
- return test_fail("Vector != Vector2\n");
- }
-
- // eg_seq = (Sequence)1, 2
- lv2_atom_forge_key(&forge, eg_seq);
- LV2_Atom_Forge_Frame seq_frame;
- LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)lv2_atom_forge_deref(
- &forge, lv2_atom_forge_sequence_head(&forge, &seq_frame, 0));
- lv2_atom_forge_frame_time(&forge, 0);
- lv2_atom_forge_int(&forge, 1);
- lv2_atom_forge_frame_time(&forge, 1);
- lv2_atom_forge_int(&forge, 2);
- lv2_atom_forge_pop(&forge, &seq_frame);
-
- lv2_atom_forge_pop(&forge, &obj_frame);
-
- // Test equality
- LV2_Atom_Int itwo = { { forge.Int, sizeof(int32_t) }, 2 };
- if (lv2_atom_equals((LV2_Atom*)one, (LV2_Atom*)two)) {
- return test_fail("1 == 2.0\n");
- } else if (lv2_atom_equals((LV2_Atom*)one, (LV2_Atom*)&itwo)) {
- return test_fail("1 == 2\n");
- } else if (!lv2_atom_equals((LV2_Atom*)one, (LV2_Atom*)one)) {
- return test_fail("1 != 1\n");
- }
-
- unsigned n_events = 0;
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
- if (ev->time.frames != n_events) {
- return test_fail("Corrupt event %u has bad time\n", n_events);
- } else if (ev->body.type != forge.Int) {
- return test_fail("Corrupt event %u has bad type\n", n_events);
- } else if (((LV2_Atom_Int*)&ev->body)->body != (int)n_events + 1) {
- return test_fail("Event %u != %u\n", n_events, n_events + 1);
- }
- ++n_events;
- }
-
- int n_props = 0;
- LV2_ATOM_OBJECT_FOREACH((LV2_Atom_Object*)obj, prop) {
- if (!prop->key) {
- return test_fail("Corrupt property %d has no key\n", n_props);
- } else if (prop->context) {
- return test_fail("Corrupt property %d has context\n", n_props);
- }
- ++n_props;
- }
-
- if (n_props != NUM_PROPS) {
- return test_fail("Corrupt object has %d properties != %d\n",
- n_props, NUM_PROPS);
- }
-
- struct {
- const LV2_Atom* one;
- const LV2_Atom* two;
- const LV2_Atom* three;
- const LV2_Atom* four;
- const LV2_Atom* affirmative;
- const LV2_Atom* negative;
- const LV2_Atom* path;
- const LV2_Atom* uri;
- const LV2_Atom* urid;
- const LV2_Atom* string;
- const LV2_Atom* literal;
- const LV2_Atom* tuple;
- const LV2_Atom* vector;
- const LV2_Atom* vector2;
- const LV2_Atom* seq;
- } matches;
-
- memset(&matches, 0, sizeof(matches));
-
- LV2_Atom_Object_Query q[] = {
- { eg_one, &matches.one },
- { eg_two, &matches.two },
- { eg_three, &matches.three },
- { eg_four, &matches.four },
- { eg_true, &matches.affirmative },
- { eg_false, &matches.negative },
- { eg_path, &matches.path },
- { eg_uri, &matches.uri },
- { eg_urid, &matches.urid },
- { eg_string, &matches.string },
- { eg_literal, &matches.literal },
- { eg_tuple, &matches.tuple },
- { eg_vector, &matches.vector },
- { eg_vector2, &matches.vector2 },
- { eg_seq, &matches.seq },
- LV2_ATOM_OBJECT_QUERY_END
- };
-
- int n_matches = lv2_atom_object_query((LV2_Atom_Object*)obj, q);
- for (int n = 0; n < 2; ++n) {
- if (n_matches != n_props) {
- return test_fail("Query failed, %d matches != %d\n",
- n_matches, n_props);
- } else if (!lv2_atom_equals((LV2_Atom*)one, matches.one)) {
- return test_fail("Bad match one\n");
- } else if (!lv2_atom_equals((LV2_Atom*)two, matches.two)) {
- return test_fail("Bad match two\n");
- } else if (!lv2_atom_equals((LV2_Atom*)three, matches.three)) {
- return test_fail("Bad match three\n");
- } else if (!lv2_atom_equals((LV2_Atom*)four, matches.four)) {
- return test_fail("Bad match four\n");
- } else if (!lv2_atom_equals((LV2_Atom*)t, matches.affirmative)) {
- return test_fail("Bad match true\n");
- } else if (!lv2_atom_equals((LV2_Atom*)f, matches.negative)) {
- return test_fail("Bad match false\n");
- } else if (!lv2_atom_equals((LV2_Atom*)path, matches.path)) {
- return test_fail("Bad match path\n");
- } else if (!lv2_atom_equals((LV2_Atom*)uri, matches.uri)) {
- return test_fail("Bad match URI\n");
- } else if (!lv2_atom_equals((LV2_Atom*)string, matches.string)) {
- return test_fail("Bad match string\n");
- } else if (!lv2_atom_equals((LV2_Atom*)literal, matches.literal)) {
- return test_fail("Bad match literal\n");
- } else if (!lv2_atom_equals((LV2_Atom*)tuple, matches.tuple)) {
- return test_fail("Bad match tuple\n");
- } else if (!lv2_atom_equals((LV2_Atom*)vector, matches.vector)) {
- return test_fail("Bad match vector\n");
- } else if (!lv2_atom_equals((LV2_Atom*)vector, matches.vector2)) {
- return test_fail("Bad match vector2\n");
- } else if (!lv2_atom_equals((LV2_Atom*)seq, matches.seq)) {
- return test_fail("Bad match sequence\n");
- }
- memset(&matches, 0, sizeof(matches));
-
- // clang-format off
- n_matches = lv2_atom_object_get((LV2_Atom_Object*)obj,
- eg_one, &matches.one,
- eg_two, &matches.two,
- eg_three, &matches.three,
- eg_four, &matches.four,
- eg_true, &matches.affirmative,
- eg_false, &matches.negative,
- eg_path, &matches.path,
- eg_uri, &matches.uri,
- eg_urid, &matches.urid,
- eg_string, &matches.string,
- eg_literal, &matches.literal,
- eg_tuple, &matches.tuple,
- eg_vector, &matches.vector,
- eg_vector2, &matches.vector2,
- eg_seq, &matches.seq,
- 0);
- // clang-format on
- }
-
- free_urid_map();
-
- return 0;
+ uint8_t buf[BUF_SIZE];
+ lv2_atom_forge_set_buffer(&forge, buf, BUF_SIZE);
+
+ LV2_Atom_Forge_Frame obj_frame;
+ LV2_Atom* obj = lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_object(&forge, &obj_frame, 0, eg_Object));
+
+ // eg_one = (Int)1
+ lv2_atom_forge_key(&forge, eg_one);
+ LV2_Atom_Int* one =
+ (LV2_Atom_Int*)lv2_atom_forge_deref(&forge, lv2_atom_forge_int(&forge, 1));
+ if (one->body != 1) {
+ return test_fail("%d != 1\n", one->body);
+ }
+
+ // eg_two = (Long)2
+ lv2_atom_forge_key(&forge, eg_two);
+ LV2_Atom_Long* two = (LV2_Atom_Long*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_long(&forge, 2));
+ if (two->body != 2) {
+ return test_fail("%" PRId64 " != 2\n", two->body);
+ }
+
+ // eg_three = (Float)3.0
+ lv2_atom_forge_key(&forge, eg_three);
+ LV2_Atom_Float* three = (LV2_Atom_Float*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_float(&forge, 3.0f));
+ if (three->body != 3) {
+ return test_fail("%f != 3\n", three->body);
+ }
+
+ // eg_four = (Double)4.0
+ lv2_atom_forge_key(&forge, eg_four);
+ LV2_Atom_Double* four = (LV2_Atom_Double*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_double(&forge, 4.0));
+ if (four->body != 4) {
+ return test_fail("%f != 4\n", four->body);
+ }
+
+ // eg_true = (Bool)1
+ lv2_atom_forge_key(&forge, eg_true);
+ LV2_Atom_Bool* t = (LV2_Atom_Bool*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_bool(&forge, true));
+ if (t->body != 1) {
+ return test_fail("%d != 1 (true)\n", t->body);
+ }
+
+ // eg_false = (Bool)0
+ lv2_atom_forge_key(&forge, eg_false);
+ LV2_Atom_Bool* f = (LV2_Atom_Bool*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_bool(&forge, false));
+ if (f->body != 0) {
+ return test_fail("%d != 0 (false)\n", f->body);
+ }
+
+ // eg_path = (Path)"/foo/bar"
+ const char* pstr = "/foo/bar";
+ const uint32_t pstr_len = (uint32_t)strlen(pstr);
+ lv2_atom_forge_key(&forge, eg_path);
+ LV2_Atom_String* path = (LV2_Atom_String*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_uri(&forge, pstr, pstr_len));
+ char* pbody = (char*)LV2_ATOM_BODY(path);
+ if (strcmp(pbody, pstr)) {
+ return test_fail("%s != \"%s\"\n", pbody, pstr);
+ }
+
+ // eg_uri = (URI)"http://example.org/value"
+ const char* ustr = "http://example.org/value";
+ const uint32_t ustr_len = (uint32_t)strlen(ustr);
+ lv2_atom_forge_key(&forge, eg_uri);
+ LV2_Atom_String* uri = (LV2_Atom_String*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_uri(&forge, ustr, ustr_len));
+ char* ubody = (char*)LV2_ATOM_BODY(uri);
+ if (strcmp(ubody, ustr)) {
+ return test_fail("%s != \"%s\"\n", ubody, ustr);
+ }
+
+ // eg_urid = (URID)"http://example.org/value"
+ LV2_URID eg_value = urid_map(NULL, "http://example.org/value");
+ lv2_atom_forge_key(&forge, eg_urid);
+ LV2_Atom_URID* urid = (LV2_Atom_URID*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_urid(&forge, eg_value));
+ if (urid->body != eg_value) {
+ return test_fail("%u != %u\n", urid->body, eg_value);
+ }
+
+ // eg_string = (String)"hello"
+ lv2_atom_forge_key(&forge, eg_string);
+ LV2_Atom_String* string = (LV2_Atom_String*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_string(&forge, "hello", strlen("hello")));
+ char* sbody = (char*)LV2_ATOM_BODY(string);
+ if (strcmp(sbody, "hello")) {
+ return test_fail("%s != \"hello\"\n", sbody);
+ }
+
+ // eg_literal = (Literal)"hello"@fr
+ lv2_atom_forge_key(&forge, eg_literal);
+ LV2_Atom_Literal* literal = (LV2_Atom_Literal*)lv2_atom_forge_deref(
+ &forge,
+ lv2_atom_forge_literal(&forge,
+ "bonjour",
+ strlen("bonjour"),
+ 0,
+ urid_map(NULL, "http://lexvo.org/id/term/fr")));
+ char* lbody = (char*)LV2_ATOM_CONTENTS(LV2_Atom_Literal, literal);
+ if (strcmp(lbody, "bonjour")) {
+ return test_fail("%s != \"bonjour\"\n", lbody);
+ }
+
+ // eg_tuple = "foo",true
+ lv2_atom_forge_key(&forge, eg_tuple);
+ LV2_Atom_Forge_Frame tuple_frame;
+ LV2_Atom_Tuple* tuple = (LV2_Atom_Tuple*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_tuple(&forge, &tuple_frame));
+ LV2_Atom_String* tup0 = (LV2_Atom_String*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_string(&forge, "foo", strlen("foo")));
+ LV2_Atom_Bool* tup1 = (LV2_Atom_Bool*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_bool(&forge, true));
+ lv2_atom_forge_pop(&forge, &tuple_frame);
+ LV2_Atom* i = lv2_atom_tuple_begin(tuple);
+ if (lv2_atom_tuple_is_end(LV2_ATOM_BODY(tuple), tuple->atom.size, i)) {
+ return test_fail("Tuple iterator is empty\n");
+ }
+ LV2_Atom* tup0i = i;
+ if (!lv2_atom_equals((LV2_Atom*)tup0, tup0i)) {
+ return test_fail("Corrupt tuple element 0\n");
+ }
+ i = lv2_atom_tuple_next(i);
+ if (lv2_atom_tuple_is_end(LV2_ATOM_BODY(tuple), tuple->atom.size, i)) {
+ return test_fail("Premature end of tuple iterator\n");
+ }
+ LV2_Atom* tup1i = i;
+ if (!lv2_atom_equals((LV2_Atom*)tup1, tup1i)) {
+ return test_fail("Corrupt tuple element 1\n");
+ }
+ i = lv2_atom_tuple_next(i);
+ if (!lv2_atom_tuple_is_end(LV2_ATOM_BODY(tuple), tuple->atom.size, i)) {
+ return test_fail("Tuple iter is not at end\n");
+ }
+
+ // eg_vector = (Vector<Int>)1,2,3,4
+ lv2_atom_forge_key(&forge, eg_vector);
+ int32_t elems[] = {1, 2, 3, 4};
+ LV2_Atom_Vector* vector = (LV2_Atom_Vector*)lv2_atom_forge_deref(
+ &forge,
+ lv2_atom_forge_vector(&forge, sizeof(int32_t), forge.Int, 4, elems));
+ void* vec_body = LV2_ATOM_CONTENTS(LV2_Atom_Vector, vector);
+ if (memcmp(elems, vec_body, sizeof(elems))) {
+ return test_fail("Corrupt vector\n");
+ }
+
+ // eg_vector2 = (Vector<Int>)1,2,3,4
+ lv2_atom_forge_key(&forge, eg_vector2);
+ LV2_Atom_Forge_Frame vec_frame;
+ LV2_Atom_Vector* vector2 = (LV2_Atom_Vector*)lv2_atom_forge_deref(
+ &forge,
+ lv2_atom_forge_vector_head(&forge, &vec_frame, sizeof(int32_t), forge.Int));
+ for (unsigned e = 0; e < sizeof(elems) / sizeof(int32_t); ++e) {
+ lv2_atom_forge_int(&forge, elems[e]);
+ }
+ lv2_atom_forge_pop(&forge, &vec_frame);
+ if (!lv2_atom_equals(&vector->atom, &vector2->atom)) {
+ return test_fail("Vector != Vector2\n");
+ }
+
+ // eg_seq = (Sequence)1, 2
+ lv2_atom_forge_key(&forge, eg_seq);
+ LV2_Atom_Forge_Frame seq_frame;
+ LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)lv2_atom_forge_deref(
+ &forge, lv2_atom_forge_sequence_head(&forge, &seq_frame, 0));
+ lv2_atom_forge_frame_time(&forge, 0);
+ lv2_atom_forge_int(&forge, 1);
+ lv2_atom_forge_frame_time(&forge, 1);
+ lv2_atom_forge_int(&forge, 2);
+ lv2_atom_forge_pop(&forge, &seq_frame);
+
+ lv2_atom_forge_pop(&forge, &obj_frame);
+
+ // Test equality
+ LV2_Atom_Int itwo = {{forge.Int, sizeof(int32_t)}, 2};
+ if (lv2_atom_equals((LV2_Atom*)one, (LV2_Atom*)two)) {
+ return test_fail("1 == 2.0\n");
+ } else if (lv2_atom_equals((LV2_Atom*)one, (LV2_Atom*)&itwo)) {
+ return test_fail("1 == 2\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)one, (LV2_Atom*)one)) {
+ return test_fail("1 != 1\n");
+ }
+
+ unsigned n_events = 0;
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
+ if (ev->time.frames != n_events) {
+ return test_fail("Corrupt event %u has bad time\n", n_events);
+ } else if (ev->body.type != forge.Int) {
+ return test_fail("Corrupt event %u has bad type\n", n_events);
+ } else if (((LV2_Atom_Int*)&ev->body)->body != (int)n_events + 1) {
+ return test_fail("Event %u != %u\n", n_events, n_events + 1);
+ }
+ ++n_events;
+ }
+
+ int n_props = 0;
+ LV2_ATOM_OBJECT_FOREACH ((LV2_Atom_Object*)obj, prop) {
+ if (!prop->key) {
+ return test_fail("Corrupt property %d has no key\n", n_props);
+ } else if (prop->context) {
+ return test_fail("Corrupt property %d has context\n", n_props);
+ }
+ ++n_props;
+ }
+
+ if (n_props != NUM_PROPS) {
+ return test_fail(
+ "Corrupt object has %d properties != %d\n", n_props, NUM_PROPS);
+ }
+
+ struct {
+ const LV2_Atom* one;
+ const LV2_Atom* two;
+ const LV2_Atom* three;
+ const LV2_Atom* four;
+ const LV2_Atom* affirmative;
+ const LV2_Atom* negative;
+ const LV2_Atom* path;
+ const LV2_Atom* uri;
+ const LV2_Atom* urid;
+ const LV2_Atom* string;
+ const LV2_Atom* literal;
+ const LV2_Atom* tuple;
+ const LV2_Atom* vector;
+ const LV2_Atom* vector2;
+ const LV2_Atom* seq;
+ } matches;
+
+ memset(&matches, 0, sizeof(matches));
+
+ LV2_Atom_Object_Query q[] = {{eg_one, &matches.one},
+ {eg_two, &matches.two},
+ {eg_three, &matches.three},
+ {eg_four, &matches.four},
+ {eg_true, &matches.affirmative},
+ {eg_false, &matches.negative},
+ {eg_path, &matches.path},
+ {eg_uri, &matches.uri},
+ {eg_urid, &matches.urid},
+ {eg_string, &matches.string},
+ {eg_literal, &matches.literal},
+ {eg_tuple, &matches.tuple},
+ {eg_vector, &matches.vector},
+ {eg_vector2, &matches.vector2},
+ {eg_seq, &matches.seq},
+ LV2_ATOM_OBJECT_QUERY_END};
+
+ int n_matches = lv2_atom_object_query((LV2_Atom_Object*)obj, q);
+ for (int n = 0; n < 2; ++n) {
+ if (n_matches != n_props) {
+ return test_fail("Query failed, %d matches != %d\n", n_matches, n_props);
+ } else if (!lv2_atom_equals((LV2_Atom*)one, matches.one)) {
+ return test_fail("Bad match one\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)two, matches.two)) {
+ return test_fail("Bad match two\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)three, matches.three)) {
+ return test_fail("Bad match three\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)four, matches.four)) {
+ return test_fail("Bad match four\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)t, matches.affirmative)) {
+ return test_fail("Bad match true\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)f, matches.negative)) {
+ return test_fail("Bad match false\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)path, matches.path)) {
+ return test_fail("Bad match path\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)uri, matches.uri)) {
+ return test_fail("Bad match URI\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)string, matches.string)) {
+ return test_fail("Bad match string\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)literal, matches.literal)) {
+ return test_fail("Bad match literal\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)tuple, matches.tuple)) {
+ return test_fail("Bad match tuple\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)vector, matches.vector)) {
+ return test_fail("Bad match vector\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)vector, matches.vector2)) {
+ return test_fail("Bad match vector2\n");
+ } else if (!lv2_atom_equals((LV2_Atom*)seq, matches.seq)) {
+ return test_fail("Bad match sequence\n");
+ }
+ memset(&matches, 0, sizeof(matches));
+
+ // clang-format off
+ n_matches = lv2_atom_object_get((LV2_Atom_Object*)obj,
+ eg_one, &matches.one,
+ eg_two, &matches.two,
+ eg_three, &matches.three,
+ eg_four, &matches.four,
+ eg_true, &matches.affirmative,
+ eg_false, &matches.negative,
+ eg_path, &matches.path,
+ eg_uri, &matches.uri,
+ eg_urid, &matches.urid,
+ eg_string, &matches.string,
+ eg_literal, &matches.literal,
+ eg_tuple, &matches.tuple,
+ eg_vector, &matches.vector,
+ eg_vector2, &matches.vector2,
+ eg_seq, &matches.seq,
+ 0);
+ // clang-format on
+ }
+
+ free_urid_map();
+
+ return 0;
}
diff --git a/lv2/atom/atom.h b/lv2/atom/atom.h
index a82c977..1ef94cc 100644
--- a/lv2/atom/atom.h
+++ b/lv2/atom/atom.h
@@ -69,7 +69,7 @@
// clang-format on
-#define LV2_ATOM_REFERENCE_TYPE 0 ///< The special type for a reference atom
+#define LV2_ATOM_REFERENCE_TYPE 0 ///< The special type for a reference atom
#ifdef __cplusplus
extern "C" {
@@ -77,8 +77,8 @@ extern "C" {
/** @cond */
/** This expression will fail to compile if double does not fit in 64 bits. */
-typedef char lv2_atom_assert_double_fits_in_64_bits[
- ((sizeof(double) <= sizeof(uint64_t)) * 2) - 1];
+typedef char lv2_atom_assert_double_fits_in_64_bits
+ [((sizeof(double) <= sizeof(uint64_t)) * 2) - 1];
/** @endcond */
/**
@@ -87,14 +87,13 @@ typedef char lv2_atom_assert_double_fits_in_64_bits[
@param type The type of the atom, for example LV2_Atom_String.
@param atom A variable-sized atom.
*/
-#define LV2_ATOM_CONTENTS(type, atom) \
- ((void*)((uint8_t*)(atom) + sizeof(type)))
+#define LV2_ATOM_CONTENTS(type, atom) ((void*)((uint8_t*)(atom) + sizeof(type)))
/**
Const version of LV2_ATOM_CONTENTS.
*/
#define LV2_ATOM_CONTENTS_CONST(type, atom) \
- ((const void*)((const uint8_t*)(atom) + sizeof(type)))
+ ((const void*)((const uint8_t*)(atom) + sizeof(type)))
/**
Return a pointer to the body of an Atom. The "body" of an atom is the
@@ -109,32 +108,32 @@ typedef char lv2_atom_assert_double_fits_in_64_bits[
/** The header of an atom:Atom. */
typedef struct {
- uint32_t size; /**< Size in bytes, not including type and size. */
- uint32_t type; /**< Type of this atom (mapped URI). */
+ uint32_t size; /**< Size in bytes, not including type and size. */
+ uint32_t type; /**< Type of this atom (mapped URI). */
} LV2_Atom;
/** An atom:Int or atom:Bool. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- int32_t body; /**< Integer value. */
+ LV2_Atom atom; /**< Atom header. */
+ int32_t body; /**< Integer value. */
} LV2_Atom_Int;
/** An atom:Long. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- int64_t body; /**< Integer value. */
+ LV2_Atom atom; /**< Atom header. */
+ int64_t body; /**< Integer value. */
} LV2_Atom_Long;
/** An atom:Float. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- float body; /**< Floating point value. */
+ LV2_Atom atom; /**< Atom header. */
+ float body; /**< Floating point value. */
} LV2_Atom_Float;
/** An atom:Double. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- double body; /**< Floating point value. */
+ LV2_Atom atom; /**< Atom header. */
+ double body; /**< Floating point value. */
} LV2_Atom_Double;
/** An atom:Bool. May be cast to LV2_Atom. */
@@ -142,84 +141,84 @@ typedef LV2_Atom_Int LV2_Atom_Bool;
/** An atom:URID. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- uint32_t body; /**< URID. */
+ LV2_Atom atom; /**< Atom header. */
+ uint32_t body; /**< URID. */
} LV2_Atom_URID;
/** An atom:String. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- /* Contents (a null-terminated UTF-8 string) follow here. */
+ LV2_Atom atom; /**< Atom header. */
+ /* Contents (a null-terminated UTF-8 string) follow here. */
} LV2_Atom_String;
/** The body of an atom:Literal. */
typedef struct {
- uint32_t datatype; /**< Datatype URID. */
- uint32_t lang; /**< Language URID. */
- /* Contents (a null-terminated UTF-8 string) follow here. */
+ uint32_t datatype; /**< Datatype URID. */
+ uint32_t lang; /**< Language URID. */
+ /* Contents (a null-terminated UTF-8 string) follow here. */
} LV2_Atom_Literal_Body;
/** An atom:Literal. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- LV2_Atom_Literal_Body body; /**< Body. */
+ LV2_Atom atom; /**< Atom header. */
+ LV2_Atom_Literal_Body body; /**< Body. */
} LV2_Atom_Literal;
/** An atom:Tuple. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- /* Contents (a series of complete atoms) follow here. */
+ LV2_Atom atom; /**< Atom header. */
+ /* Contents (a series of complete atoms) follow here. */
} LV2_Atom_Tuple;
/** The body of an atom:Vector. */
typedef struct {
- uint32_t child_size; /**< The size of each element in the vector. */
- uint32_t child_type; /**< The type of each element in the vector. */
- /* Contents (a series of packed atom bodies) follow here. */
+ uint32_t child_size; /**< The size of each element in the vector. */
+ uint32_t child_type; /**< The type of each element in the vector. */
+ /* Contents (a series of packed atom bodies) follow here. */
} LV2_Atom_Vector_Body;
/** An atom:Vector. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- LV2_Atom_Vector_Body body; /**< Body. */
+ LV2_Atom atom; /**< Atom header. */
+ LV2_Atom_Vector_Body body; /**< Body. */
} LV2_Atom_Vector;
/** The body of an atom:Property (typically in an atom:Object). */
typedef struct {
- uint32_t key; /**< Key (predicate) (mapped URI). */
- uint32_t context; /**< Context URID (may be, and generally is, 0). */
- LV2_Atom value; /**< Value atom header. */
- /* Value atom body follows here. */
+ uint32_t key; /**< Key (predicate) (mapped URI). */
+ uint32_t context; /**< Context URID (may be, and generally is, 0). */
+ LV2_Atom value; /**< Value atom header. */
+ /* Value atom body follows here. */
} LV2_Atom_Property_Body;
/** An atom:Property. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- LV2_Atom_Property_Body body; /**< Body. */
+ LV2_Atom atom; /**< Atom header. */
+ LV2_Atom_Property_Body body; /**< Body. */
} LV2_Atom_Property;
/** The body of an atom:Object. May be cast to LV2_Atom. */
typedef struct {
- uint32_t id; /**< URID, or 0 for blank. */
- uint32_t otype; /**< Type URID (same as rdf:type, for fast dispatch). */
- /* Contents (a series of property bodies) follow here. */
+ uint32_t id; /**< URID, or 0 for blank. */
+ uint32_t otype; /**< Type URID (same as rdf:type, for fast dispatch). */
+ /* Contents (a series of property bodies) follow here. */
} LV2_Atom_Object_Body;
/** An atom:Object. May be cast to LV2_Atom. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- LV2_Atom_Object_Body body; /**< Body. */
+ LV2_Atom atom; /**< Atom header. */
+ LV2_Atom_Object_Body body; /**< Body. */
} LV2_Atom_Object;
/** The header of an atom:Event. Note this type is NOT an LV2_Atom. */
typedef struct {
- /** Time stamp. Which type is valid is determined by context. */
- union {
- int64_t frames; /**< Time in audio frames. */
- double beats; /**< Time in beats. */
- } time;
- LV2_Atom body; /**< Event body atom header. */
- /* Body atom contents follow here. */
+ /** Time stamp. Which type is valid is determined by context. */
+ union {
+ int64_t frames; /**< Time in audio frames. */
+ double beats; /**< Time in beats. */
+ } time;
+ LV2_Atom body; /**< Event body atom header. */
+ /* Body atom contents follow here. */
} LV2_Atom_Event;
/**
@@ -239,23 +238,23 @@ typedef struct {
</pre>
*/
typedef struct {
- uint32_t unit; /**< URID of unit of event time stamps. */
- uint32_t pad; /**< Currently unused. */
- /* Contents (a series of events) follow here. */
+ uint32_t unit; /**< URID of unit of event time stamps. */
+ uint32_t pad; /**< Currently unused. */
+ /* Contents (a series of events) follow here. */
} LV2_Atom_Sequence_Body;
/** An atom:Sequence. */
typedef struct {
- LV2_Atom atom; /**< Atom header. */
- LV2_Atom_Sequence_Body body; /**< Body. */
+ LV2_Atom atom; /**< Atom header. */
+ LV2_Atom_Sequence_Body body; /**< Body. */
} LV2_Atom_Sequence;
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
@}
*/
-#endif /* LV2_ATOM_H */
+#endif /* LV2_ATOM_H */
diff --git a/lv2/atom/forge-overflow-test.c b/lv2/atom/forge-overflow-test.c
index ed5845a..8e5ede6 100644
--- a/lv2/atom/forge-overflow-test.c
+++ b/lv2/atom/forge-overflow-test.c
@@ -28,210 +28,208 @@ test_string_overflow(void)
{
#define MAX_CHARS 15
- static const size_t capacity = sizeof(LV2_Atom_String) + MAX_CHARS + 1;
- static const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
- uint8_t* buf = (uint8_t*)malloc(capacity);
- LV2_URID_Map map = { NULL, urid_map };
- LV2_Atom_Forge forge;
- lv2_atom_forge_init(&forge, &map);
-
- // Check that writing increasingly long strings fails at the right point
- for (size_t count = 0; count < MAX_CHARS; ++count) {
- lv2_atom_forge_set_buffer(&forge, buf, capacity);
-
- const LV2_Atom_Forge_Ref ref =
- lv2_atom_forge_string(&forge, str, count);
- if (!ref) {
- return test_fail("Failed to write %zu byte string\n", count);
- }
- }
-
- // Failure writing to an exactly full forge
- if (lv2_atom_forge_string(&forge, str, MAX_CHARS + 1)) {
- return test_fail("Successfully wrote past end of buffer\n");
- }
-
- // Failure writing body after successfully writing header
- lv2_atom_forge_set_buffer(&forge, buf, sizeof(LV2_Atom) + 1);
- if (lv2_atom_forge_string(&forge, "AB", 2)) {
- return test_fail("Successfully wrote atom header past end\n");
- }
-
- free(buf);
- return 0;
+ static const size_t capacity = sizeof(LV2_Atom_String) + MAX_CHARS + 1;
+ static const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ uint8_t* buf = (uint8_t*)malloc(capacity);
+ LV2_URID_Map map = {NULL, urid_map};
+ LV2_Atom_Forge forge;
+ lv2_atom_forge_init(&forge, &map);
+
+ // Check that writing increasingly long strings fails at the right point
+ for (size_t count = 0; count < MAX_CHARS; ++count) {
+ lv2_atom_forge_set_buffer(&forge, buf, capacity);
+
+ const LV2_Atom_Forge_Ref ref = lv2_atom_forge_string(&forge, str, count);
+ if (!ref) {
+ return test_fail("Failed to write %zu byte string\n", count);
+ }
+ }
+
+ // Failure writing to an exactly full forge
+ if (lv2_atom_forge_string(&forge, str, MAX_CHARS + 1)) {
+ return test_fail("Successfully wrote past end of buffer\n");
+ }
+
+ // Failure writing body after successfully writing header
+ lv2_atom_forge_set_buffer(&forge, buf, sizeof(LV2_Atom) + 1);
+ if (lv2_atom_forge_string(&forge, "AB", 2)) {
+ return test_fail("Successfully wrote atom header past end\n");
+ }
+
+ free(buf);
+ return 0;
}
static int
test_literal_overflow(void)
{
- static const size_t capacity = sizeof(LV2_Atom_Literal) + 2;
-
- uint8_t* buf = (uint8_t*)malloc(capacity);
- LV2_URID_Map map = { NULL, urid_map };
- LV2_Atom_Forge forge;
- lv2_atom_forge_init(&forge, &map);
-
- // Failure in atom header
- lv2_atom_forge_set_buffer(&forge, buf, 1);
- if (lv2_atom_forge_literal(&forge, "A", 1, 0, 0)) {
- return test_fail("Successfully wrote atom header past end\n");
- }
-
- // Failure in literal header
- lv2_atom_forge_set_buffer(&forge, buf, sizeof(LV2_Atom) + 1);
- if (lv2_atom_forge_literal(&forge, "A", 1, 0, 0)) {
- return test_fail("Successfully wrote literal header past end\n");
- }
-
- // Success (only room for one character + null terminator)
- lv2_atom_forge_set_buffer(&forge, buf, capacity);
- if (!lv2_atom_forge_literal(&forge, "A", 1, 0, 0)) {
- return test_fail("Failed to write small enough literal\n");
- }
-
- // Failure in body
- lv2_atom_forge_set_buffer(&forge, buf, capacity);
- if (lv2_atom_forge_literal(&forge, "AB", 2, 0, 0)) {
- return test_fail("Successfully wrote literal body past end\n");
- }
-
- free(buf);
- return 0;
+ static const size_t capacity = sizeof(LV2_Atom_Literal) + 2;
+
+ uint8_t* buf = (uint8_t*)malloc(capacity);
+ LV2_URID_Map map = {NULL, urid_map};
+ LV2_Atom_Forge forge;
+ lv2_atom_forge_init(&forge, &map);
+
+ // Failure in atom header
+ lv2_atom_forge_set_buffer(&forge, buf, 1);
+ if (lv2_atom_forge_literal(&forge, "A", 1, 0, 0)) {
+ return test_fail("Successfully wrote atom header past end\n");
+ }
+
+ // Failure in literal header
+ lv2_atom_forge_set_buffer(&forge, buf, sizeof(LV2_Atom) + 1);
+ if (lv2_atom_forge_literal(&forge, "A", 1, 0, 0)) {
+ return test_fail("Successfully wrote literal header past end\n");
+ }
+
+ // Success (only room for one character + null terminator)
+ lv2_atom_forge_set_buffer(&forge, buf, capacity);
+ if (!lv2_atom_forge_literal(&forge, "A", 1, 0, 0)) {
+ return test_fail("Failed to write small enough literal\n");
+ }
+
+ // Failure in body
+ lv2_atom_forge_set_buffer(&forge, buf, capacity);
+ if (lv2_atom_forge_literal(&forge, "AB", 2, 0, 0)) {
+ return test_fail("Successfully wrote literal body past end\n");
+ }
+
+ free(buf);
+ return 0;
}
static int
test_sequence_overflow(void)
{
- static const size_t size = sizeof(LV2_Atom_Sequence) + 6 * sizeof(LV2_Atom);
- LV2_URID_Map map = { NULL, urid_map };
+ static const size_t size = sizeof(LV2_Atom_Sequence) + 6 * sizeof(LV2_Atom);
+ LV2_URID_Map map = {NULL, urid_map};
- // Test over a range that fails in the sequence header and event components
- for (size_t capacity = 1; capacity < size; ++capacity) {
- uint8_t* buf = (uint8_t*)malloc(capacity);
+ // Test over a range that fails in the sequence header and event components
+ for (size_t capacity = 1; capacity < size; ++capacity) {
+ uint8_t* buf = (uint8_t*)malloc(capacity);
- LV2_Atom_Forge forge;
- lv2_atom_forge_init(&forge, &map);
- lv2_atom_forge_set_buffer(&forge, buf, capacity);
+ LV2_Atom_Forge forge;
+ lv2_atom_forge_init(&forge, &map);
+ lv2_atom_forge_set_buffer(&forge, buf, capacity);
- LV2_Atom_Forge_Frame frame;
- LV2_Atom_Forge_Ref ref =
- lv2_atom_forge_sequence_head(&forge, &frame, 0);
+ LV2_Atom_Forge_Frame frame;
+ LV2_Atom_Forge_Ref ref = lv2_atom_forge_sequence_head(&forge, &frame, 0);
- assert(capacity >= sizeof(LV2_Atom_Sequence) || !frame.ref);
- assert(capacity >= sizeof(LV2_Atom_Sequence) || !ref);
- (void)ref;
+ assert(capacity >= sizeof(LV2_Atom_Sequence) || !frame.ref);
+ assert(capacity >= sizeof(LV2_Atom_Sequence) || !ref);
+ (void)ref;
- lv2_atom_forge_frame_time(&forge, 0);
- lv2_atom_forge_int(&forge, 42);
- lv2_atom_forge_pop(&forge, &frame);
+ lv2_atom_forge_frame_time(&forge, 0);
+ lv2_atom_forge_int(&forge, 42);
+ lv2_atom_forge_pop(&forge, &frame);
- free(buf);
- }
+ free(buf);
+ }
- return 0;
+ return 0;
}
static int
test_vector_head_overflow(void)
{
- static const size_t size = sizeof(LV2_Atom_Vector) + 3 * sizeof(LV2_Atom);
- LV2_URID_Map map = { NULL, urid_map };
+ static const size_t size = sizeof(LV2_Atom_Vector) + 3 * sizeof(LV2_Atom);
+ LV2_URID_Map map = {NULL, urid_map};
- // Test over a range that fails in the vector header and elements
- for (size_t capacity = 1; capacity < size; ++capacity) {
- uint8_t* buf = (uint8_t*)malloc(capacity);
+ // Test over a range that fails in the vector header and elements
+ for (size_t capacity = 1; capacity < size; ++capacity) {
+ uint8_t* buf = (uint8_t*)malloc(capacity);
- LV2_Atom_Forge forge;
- lv2_atom_forge_init(&forge, &map);
- lv2_atom_forge_set_buffer(&forge, buf, capacity);
+ LV2_Atom_Forge forge;
+ lv2_atom_forge_init(&forge, &map);
+ lv2_atom_forge_set_buffer(&forge, buf, capacity);
- LV2_Atom_Forge_Frame frame;
- LV2_Atom_Forge_Ref ref = lv2_atom_forge_vector_head(
- &forge, &frame, sizeof(int32_t), forge.Int);
+ LV2_Atom_Forge_Frame frame;
+ LV2_Atom_Forge_Ref ref =
+ lv2_atom_forge_vector_head(&forge, &frame, sizeof(int32_t), forge.Int);
- assert(capacity >= sizeof(LV2_Atom_Vector) || !frame.ref);
- assert(capacity >= sizeof(LV2_Atom_Vector) || !ref);
- (void)ref;
+ assert(capacity >= sizeof(LV2_Atom_Vector) || !frame.ref);
+ assert(capacity >= sizeof(LV2_Atom_Vector) || !ref);
+ (void)ref;
- lv2_atom_forge_int(&forge, 1);
- lv2_atom_forge_int(&forge, 2);
- lv2_atom_forge_int(&forge, 3);
- lv2_atom_forge_pop(&forge, &frame);
+ lv2_atom_forge_int(&forge, 1);
+ lv2_atom_forge_int(&forge, 2);
+ lv2_atom_forge_int(&forge, 3);
+ lv2_atom_forge_pop(&forge, &frame);
- free(buf);
- }
+ free(buf);
+ }
- return 0;
+ return 0;
}
static int
test_vector_overflow(void)
{
- static const size_t size = sizeof(LV2_Atom_Vector) + 3 * sizeof(LV2_Atom);
- static const int32_t vec[] = { 1, 2, 3 };
- LV2_URID_Map map = { NULL, urid_map };
+ static const size_t size = sizeof(LV2_Atom_Vector) + 3 * sizeof(LV2_Atom);
+ static const int32_t vec[] = {1, 2, 3};
+ LV2_URID_Map map = {NULL, urid_map};
- // Test over a range that fails in the vector header and elements
- for (size_t capacity = 1; capacity < size; ++capacity) {
- uint8_t* buf = (uint8_t*)malloc(capacity);
+ // Test over a range that fails in the vector header and elements
+ for (size_t capacity = 1; capacity < size; ++capacity) {
+ uint8_t* buf = (uint8_t*)malloc(capacity);
- LV2_Atom_Forge forge;
- lv2_atom_forge_init(&forge, &map);
- lv2_atom_forge_set_buffer(&forge, buf, capacity);
+ LV2_Atom_Forge forge;
+ lv2_atom_forge_init(&forge, &map);
+ lv2_atom_forge_set_buffer(&forge, buf, capacity);
- LV2_Atom_Forge_Ref ref = lv2_atom_forge_vector(
- &forge, sizeof(int32_t), forge.Int, 3, vec);
+ LV2_Atom_Forge_Ref ref =
+ lv2_atom_forge_vector(&forge, sizeof(int32_t), forge.Int, 3, vec);
- assert(capacity >= sizeof(LV2_Atom_Vector) || !ref);
- (void)ref;
+ assert(capacity >= sizeof(LV2_Atom_Vector) || !ref);
+ (void)ref;
- free(buf);
- }
+ free(buf);
+ }
- return 0;
+ return 0;
}
static int
test_tuple_overflow(void)
{
- static const size_t size = sizeof(LV2_Atom_Tuple) + 3 * sizeof(LV2_Atom);
- LV2_URID_Map map = { NULL, urid_map };
+ static const size_t size = sizeof(LV2_Atom_Tuple) + 3 * sizeof(LV2_Atom);
+ LV2_URID_Map map = {NULL, urid_map};
- // Test over a range that fails in the tuple header and elements
- for (size_t capacity = 1; capacity < size; ++capacity) {
- uint8_t* buf = (uint8_t*)malloc(capacity);
+ // Test over a range that fails in the tuple header and elements
+ for (size_t capacity = 1; capacity < size; ++capacity) {
+ uint8_t* buf = (uint8_t*)malloc(capacity);
- LV2_Atom_Forge forge;
- lv2_atom_forge_init(&forge, &map);
- lv2_atom_forge_set_buffer(&forge, buf, capacity);
+ LV2_Atom_Forge forge;
+ lv2_atom_forge_init(&forge, &map);
+ lv2_atom_forge_set_buffer(&forge, buf, capacity);
- LV2_Atom_Forge_Frame frame;
- LV2_Atom_Forge_Ref ref = lv2_atom_forge_tuple(&forge, &frame);
+ LV2_Atom_Forge_Frame frame;
+ LV2_Atom_Forge_Ref ref = lv2_atom_forge_tuple(&forge, &frame);
- assert(capacity >= sizeof(LV2_Atom_Tuple) || !frame.ref);
- assert(capacity >= sizeof(LV2_Atom_Tuple) || !ref);
- (void)ref;
+ assert(capacity >= sizeof(LV2_Atom_Tuple) || !frame.ref);
+ assert(capacity >= sizeof(LV2_Atom_Tuple) || !ref);
+ (void)ref;
- lv2_atom_forge_int(&forge, 1);
- lv2_atom_forge_float(&forge, 2.0f);
- lv2_atom_forge_string(&forge, "three", 5);
- lv2_atom_forge_pop(&forge, &frame);
+ lv2_atom_forge_int(&forge, 1);
+ lv2_atom_forge_float(&forge, 2.0f);
+ lv2_atom_forge_string(&forge, "three", 5);
+ lv2_atom_forge_pop(&forge, &frame);
- free(buf);
- }
+ free(buf);
+ }
- return 0;
+ return 0;
}
int
main(void)
{
- const int ret = test_string_overflow() || test_literal_overflow() ||
- test_sequence_overflow() || test_vector_head_overflow() ||
- test_vector_overflow() || test_tuple_overflow();
+ const int ret = test_string_overflow() || test_literal_overflow() ||
+ test_sequence_overflow() || test_vector_head_overflow() ||
+ test_vector_overflow() || test_tuple_overflow();
- free_urid_map();
+ free_urid_map();
- return ret;
+ return ret;
}
diff --git a/lv2/atom/forge.h b/lv2/atom/forge.h
index 0920e0a..42471f5 100644
--- a/lv2/atom/forge.h
+++ b/lv2/atom/forge.h
@@ -75,52 +75,52 @@ typedef void* LV2_Atom_Forge_Sink_Handle;
typedef intptr_t LV2_Atom_Forge_Ref;
/** Sink function for writing output. See lv2_atom_forge_set_sink(). */
-typedef LV2_Atom_Forge_Ref
-(*LV2_Atom_Forge_Sink)(LV2_Atom_Forge_Sink_Handle handle,
- const void* buf,
- uint32_t size);
+typedef LV2_Atom_Forge_Ref (*LV2_Atom_Forge_Sink)(
+ LV2_Atom_Forge_Sink_Handle handle,
+ const void* buf,
+ uint32_t size);
/** Function for resolving a reference. See lv2_atom_forge_set_sink(). */
-typedef LV2_Atom*
-(*LV2_Atom_Forge_Deref_Func)(LV2_Atom_Forge_Sink_Handle handle,
- LV2_Atom_Forge_Ref ref);
+typedef LV2_Atom* (*LV2_Atom_Forge_Deref_Func)(
+ LV2_Atom_Forge_Sink_Handle handle,
+ LV2_Atom_Forge_Ref ref);
/** A stack frame used for keeping track of nested Atom containers. */
typedef struct LV2_Atom_Forge_Frame {
- struct LV2_Atom_Forge_Frame* parent;
- LV2_Atom_Forge_Ref ref;
+ struct LV2_Atom_Forge_Frame* parent;
+ LV2_Atom_Forge_Ref ref;
} LV2_Atom_Forge_Frame;
/** A "forge" for creating atoms by appending to a buffer. */
typedef struct {
- uint8_t* buf;
- uint32_t offset;
- uint32_t size;
-
- LV2_Atom_Forge_Sink sink;
- LV2_Atom_Forge_Deref_Func deref;
- LV2_Atom_Forge_Sink_Handle handle;
-
- LV2_Atom_Forge_Frame* stack;
-
- LV2_URID Blank LV2_DEPRECATED;
- LV2_URID Bool;
- LV2_URID Chunk;
- LV2_URID Double;
- LV2_URID Float;
- LV2_URID Int;
- LV2_URID Long;
- LV2_URID Literal;
- LV2_URID Object;
- LV2_URID Path;
- LV2_URID Property;
- LV2_URID Resource LV2_DEPRECATED;
- LV2_URID Sequence;
- LV2_URID String;
- LV2_URID Tuple;
- LV2_URID URI;
- LV2_URID URID;
- LV2_URID Vector;
+ uint8_t* buf;
+ uint32_t offset;
+ uint32_t size;
+
+ LV2_Atom_Forge_Sink sink;
+ LV2_Atom_Forge_Deref_Func deref;
+ LV2_Atom_Forge_Sink_Handle handle;
+
+ LV2_Atom_Forge_Frame* stack;
+
+ LV2_URID Blank LV2_DEPRECATED;
+ LV2_URID Bool;
+ LV2_URID Chunk;
+ LV2_URID Double;
+ LV2_URID Float;
+ LV2_URID Int;
+ LV2_URID Long;
+ LV2_URID Literal;
+ LV2_URID Object;
+ LV2_URID Path;
+ LV2_URID Property;
+ LV2_URID Resource LV2_DEPRECATED;
+ LV2_URID Sequence;
+ LV2_URID String;
+ LV2_URID Tuple;
+ LV2_URID URI;
+ LV2_URID URID;
+ LV2_URID Vector;
} LV2_Atom_Forge;
static inline void
@@ -135,32 +135,32 @@ lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size);
static inline void
lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map)
{
- lv2_atom_forge_set_buffer(forge, NULL, 0);
- forge->Blank = map->map(map->handle, LV2_ATOM__Blank);
- forge->Bool = map->map(map->handle, LV2_ATOM__Bool);
- forge->Chunk = map->map(map->handle, LV2_ATOM__Chunk);
- forge->Double = map->map(map->handle, LV2_ATOM__Double);
- forge->Float = map->map(map->handle, LV2_ATOM__Float);
- forge->Int = map->map(map->handle, LV2_ATOM__Int);
- forge->Long = map->map(map->handle, LV2_ATOM__Long);
- forge->Literal = map->map(map->handle, LV2_ATOM__Literal);
- forge->Object = map->map(map->handle, LV2_ATOM__Object);
- forge->Path = map->map(map->handle, LV2_ATOM__Path);
- forge->Property = map->map(map->handle, LV2_ATOM__Property);
- forge->Resource = map->map(map->handle, LV2_ATOM__Resource);
- forge->Sequence = map->map(map->handle, LV2_ATOM__Sequence);
- forge->String = map->map(map->handle, LV2_ATOM__String);
- forge->Tuple = map->map(map->handle, LV2_ATOM__Tuple);
- forge->URI = map->map(map->handle, LV2_ATOM__URI);
- forge->URID = map->map(map->handle, LV2_ATOM__URID);
- forge->Vector = map->map(map->handle, LV2_ATOM__Vector);
+ lv2_atom_forge_set_buffer(forge, NULL, 0);
+ forge->Blank = map->map(map->handle, LV2_ATOM__Blank);
+ forge->Bool = map->map(map->handle, LV2_ATOM__Bool);
+ forge->Chunk = map->map(map->handle, LV2_ATOM__Chunk);
+ forge->Double = map->map(map->handle, LV2_ATOM__Double);
+ forge->Float = map->map(map->handle, LV2_ATOM__Float);
+ forge->Int = map->map(map->handle, LV2_ATOM__Int);
+ forge->Long = map->map(map->handle, LV2_ATOM__Long);
+ forge->Literal = map->map(map->handle, LV2_ATOM__Literal);
+ forge->Object = map->map(map->handle, LV2_ATOM__Object);
+ forge->Path = map->map(map->handle, LV2_ATOM__Path);
+ forge->Property = map->map(map->handle, LV2_ATOM__Property);
+ forge->Resource = map->map(map->handle, LV2_ATOM__Resource);
+ forge->Sequence = map->map(map->handle, LV2_ATOM__Sequence);
+ forge->String = map->map(map->handle, LV2_ATOM__String);
+ forge->Tuple = map->map(map->handle, LV2_ATOM__Tuple);
+ forge->URI = map->map(map->handle, LV2_ATOM__URI);
+ forge->URID = map->map(map->handle, LV2_ATOM__URID);
+ forge->Vector = map->map(map->handle, LV2_ATOM__Vector);
}
/** Access the Atom pointed to by a reference. */
static inline LV2_Atom*
lv2_atom_forge_deref(LV2_Atom_Forge* forge, LV2_Atom_Forge_Ref ref)
{
- return forge->buf ? (LV2_Atom*)ref : forge->deref(forge->handle, ref);
+ return forge->buf ? (LV2_Atom*)ref : forge->deref(forge->handle, ref);
}
/**
@@ -179,43 +179,42 @@ lv2_atom_forge_push(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Frame* frame,
LV2_Atom_Forge_Ref ref)
{
- frame->parent = forge->stack;
- frame->ref = ref;
+ frame->parent = forge->stack;
+ frame->ref = ref;
- if (ref) {
- forge->stack = frame; // Don't push, so walking the stack is always safe
- }
+ if (ref) {
+ forge->stack = frame; // Don't push, so walking the stack is always safe
+ }
- return ref;
+ return ref;
}
/** Pop a stack frame. This must be called when a container is finished. */
static inline void
lv2_atom_forge_pop(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame)
{
- if (frame->ref) {
- // If frame has a valid ref, it must be the top of the stack
- assert(frame == forge->stack);
- forge->stack = frame->parent;
- }
- // Otherwise, frame was not pushed because of overflow, do nothing
+ if (frame->ref) {
+ // If frame has a valid ref, it must be the top of the stack
+ assert(frame == forge->stack);
+ forge->stack = frame->parent;
+ }
+ // Otherwise, frame was not pushed because of overflow, do nothing
}
/** Return true iff the top of the stack has the given type. */
static inline bool
lv2_atom_forge_top_is(LV2_Atom_Forge* forge, uint32_t type)
{
- return forge->stack && forge->stack->ref &&
- (lv2_atom_forge_deref(forge, forge->stack->ref)->type == type);
+ return forge->stack && forge->stack->ref &&
+ (lv2_atom_forge_deref(forge, forge->stack->ref)->type == type);
}
/** Return true iff `type` is an atom:Object. */
static inline bool
lv2_atom_forge_is_object_type(const LV2_Atom_Forge* forge, uint32_t type)
{
- return (type == forge->Object ||
- type == forge->Blank ||
- type == forge->Resource);
+ return (type == forge->Object || type == forge->Blank ||
+ type == forge->Resource);
}
/** Return true iff `type` is an atom:Object with a blank ID. */
@@ -224,8 +223,7 @@ lv2_atom_forge_is_blank(const LV2_Atom_Forge* forge,
uint32_t type,
const LV2_Atom_Object_Body* body)
{
- return (type == forge->Blank ||
- (type == forge->Object && body->id == 0));
+ return (type == forge->Blank || (type == forge->Object && body->id == 0));
}
/**
@@ -238,13 +236,13 @@ lv2_atom_forge_is_blank(const LV2_Atom_Forge* forge,
static inline void
lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size)
{
- forge->buf = buf;
- forge->size = (uint32_t)size;
- forge->offset = 0;
- forge->deref = NULL;
- forge->sink = NULL;
- forge->handle = NULL;
- forge->stack = NULL;
+ forge->buf = buf;
+ forge->size = (uint32_t)size;
+ forge->offset = 0;
+ forge->deref = NULL;
+ forge->sink = NULL;
+ forge->handle = NULL;
+ forge->stack = NULL;
}
/**
@@ -267,12 +265,12 @@ lv2_atom_forge_set_sink(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Deref_Func deref,
LV2_Atom_Forge_Sink_Handle handle)
{
- forge->buf = NULL;
- forge->size = forge->offset = 0;
- forge->deref = deref;
- forge->sink = sink;
- forge->handle = handle;
- forge->stack = NULL;
+ forge->buf = NULL;
+ forge->size = forge->offset = 0;
+ forge->deref = deref;
+ forge->sink = sink;
+ forge->handle = handle;
+ forge->stack = NULL;
}
/**
@@ -289,55 +287,53 @@ lv2_atom_forge_set_sink(LV2_Atom_Forge* forge,
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_raw(LV2_Atom_Forge* forge, const void* data, uint32_t size)
{
- LV2_Atom_Forge_Ref out = 0;
- if (forge->sink) {
- out = forge->sink(forge->handle, data, size);
- } else {
- out = (LV2_Atom_Forge_Ref)forge->buf + forge->offset;
- uint8_t* mem = forge->buf + forge->offset;
- if (forge->offset + size > forge->size) {
- return 0;
- }
- forge->offset += size;
- memcpy(mem, data, size);
- }
- for (LV2_Atom_Forge_Frame* f = forge->stack; f; f = f->parent) {
- lv2_atom_forge_deref(forge, f->ref)->size += size;
- }
- return out;
+ LV2_Atom_Forge_Ref out = 0;
+ if (forge->sink) {
+ out = forge->sink(forge->handle, data, size);
+ } else {
+ out = (LV2_Atom_Forge_Ref)forge->buf + forge->offset;
+ uint8_t* mem = forge->buf + forge->offset;
+ if (forge->offset + size > forge->size) {
+ return 0;
+ }
+ forge->offset += size;
+ memcpy(mem, data, size);
+ }
+ for (LV2_Atom_Forge_Frame* f = forge->stack; f; f = f->parent) {
+ lv2_atom_forge_deref(forge, f->ref)->size += size;
+ }
+ return out;
}
/** Pad output accordingly so next write is 64-bit aligned. */
static inline void
lv2_atom_forge_pad(LV2_Atom_Forge* forge, uint32_t written)
{
- const uint64_t pad = 0;
- const uint32_t pad_size = lv2_atom_pad_size(written) - written;
- lv2_atom_forge_raw(forge, &pad, pad_size);
+ const uint64_t pad = 0;
+ const uint32_t pad_size = lv2_atom_pad_size(written) - written;
+ lv2_atom_forge_raw(forge, &pad, pad_size);
}
/** Write raw output, padding to 64-bits as necessary. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_write(LV2_Atom_Forge* forge, const void* data, uint32_t size)
{
- LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, data, size);
- if (out) {
- lv2_atom_forge_pad(forge, size);
- }
- return out;
+ LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, data, size);
+ if (out) {
+ lv2_atom_forge_pad(forge, size);
+ }
+ return out;
}
/** Write a null-terminated string body. */
static inline LV2_Atom_Forge_Ref
-lv2_atom_forge_string_body(LV2_Atom_Forge* forge,
- const char* str,
- uint32_t len)
+lv2_atom_forge_string_body(LV2_Atom_Forge* forge, const char* str, uint32_t len)
{
- LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, str, len);
- if (out && (out = lv2_atom_forge_raw(forge, "", 1))) {
- lv2_atom_forge_pad(forge, len + 1);
- }
- return out;
+ LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, str, len);
+ if (out && (out = lv2_atom_forge_raw(forge, "", 1))) {
+ lv2_atom_forge_pad(forge, len + 1);
+ }
+ return out;
}
/**
@@ -350,66 +346,66 @@ lv2_atom_forge_string_body(LV2_Atom_Forge* forge,
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_atom(LV2_Atom_Forge* forge, uint32_t size, uint32_t type)
{
- const LV2_Atom a = { size, type };
- return lv2_atom_forge_raw(forge, &a, sizeof(a));
+ const LV2_Atom a = {size, type};
+ return lv2_atom_forge_raw(forge, &a, sizeof(a));
}
/** Write a primitive (fixed-size) atom. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_primitive(LV2_Atom_Forge* forge, const LV2_Atom* a)
{
- return (lv2_atom_forge_top_is(forge, forge->Vector)
- ? lv2_atom_forge_raw(forge, LV2_ATOM_BODY_CONST(a), a->size)
- : lv2_atom_forge_write(
- forge, a, (uint32_t)sizeof(LV2_Atom) + a->size));
+ return (
+ lv2_atom_forge_top_is(forge, forge->Vector)
+ ? lv2_atom_forge_raw(forge, LV2_ATOM_BODY_CONST(a), a->size)
+ : lv2_atom_forge_write(forge, a, (uint32_t)sizeof(LV2_Atom) + a->size));
}
/** Write an atom:Int. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_int(LV2_Atom_Forge* forge, int32_t val)
{
- const LV2_Atom_Int a = { { sizeof(val), forge->Int }, val };
- return lv2_atom_forge_primitive(forge, &a.atom);
+ const LV2_Atom_Int a = {{sizeof(val), forge->Int}, val};
+ return lv2_atom_forge_primitive(forge, &a.atom);
}
/** Write an atom:Long. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_long(LV2_Atom_Forge* forge, int64_t val)
{
- const LV2_Atom_Long a = { { sizeof(val), forge->Long }, val };
- return lv2_atom_forge_primitive(forge, &a.atom);
+ const LV2_Atom_Long a = {{sizeof(val), forge->Long}, val};
+ return lv2_atom_forge_primitive(forge, &a.atom);
}
/** Write an atom:Float. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_float(LV2_Atom_Forge* forge, float val)
{
- const LV2_Atom_Float a = { { sizeof(val), forge->Float }, val };
- return lv2_atom_forge_primitive(forge, &a.atom);
+ const LV2_Atom_Float a = {{sizeof(val), forge->Float}, val};
+ return lv2_atom_forge_primitive(forge, &a.atom);
}
/** Write an atom:Double. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_double(LV2_Atom_Forge* forge, double val)
{
- const LV2_Atom_Double a = { { sizeof(val), forge->Double }, val };
- return lv2_atom_forge_primitive(forge, &a.atom);
+ const LV2_Atom_Double a = {{sizeof(val), forge->Double}, val};
+ return lv2_atom_forge_primitive(forge, &a.atom);
}
/** Write an atom:Bool. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_bool(LV2_Atom_Forge* forge, bool val)
{
- const LV2_Atom_Bool a = { { sizeof(int32_t), forge->Bool }, val ? 1 : 0 };
- return lv2_atom_forge_primitive(forge, &a.atom);
+ const LV2_Atom_Bool a = {{sizeof(int32_t), forge->Bool}, val ? 1 : 0};
+ return lv2_atom_forge_primitive(forge, &a.atom);
}
/** Write an atom:URID. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_urid(LV2_Atom_Forge* forge, LV2_URID id)
{
- const LV2_Atom_URID a = { { sizeof(id), forge->URID }, id };
- return lv2_atom_forge_primitive(forge, &a.atom);
+ const LV2_Atom_URID a = {{sizeof(id), forge->URID}, id};
+ return lv2_atom_forge_primitive(forge, &a.atom);
}
/** Write an atom compatible with atom:String. Used internally. */
@@ -419,23 +415,23 @@ lv2_atom_forge_typed_string(LV2_Atom_Forge* forge,
const char* str,
uint32_t len)
{
- const LV2_Atom_String a = { { len + 1, type } };
- LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a));
- if (out) {
- if (!lv2_atom_forge_string_body(forge, str, len)) {
- LV2_Atom* atom = lv2_atom_forge_deref(forge, out);
- atom->size = atom->type = 0;
- out = 0;
- }
- }
- return out;
+ const LV2_Atom_String a = {{len + 1, type}};
+ LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a));
+ if (out) {
+ if (!lv2_atom_forge_string_body(forge, str, len)) {
+ LV2_Atom* atom = lv2_atom_forge_deref(forge, out);
+ atom->size = atom->type = 0;
+ out = 0;
+ }
+ }
+ return out;
}
/** Write an atom:String. Note that `str` need not be NULL terminated. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_string(LV2_Atom_Forge* forge, const char* str, uint32_t len)
{
- return lv2_atom_forge_typed_string(forge, forge->String, str, len);
+ return lv2_atom_forge_typed_string(forge, forge->String, str, len);
}
/**
@@ -446,14 +442,14 @@ lv2_atom_forge_string(LV2_Atom_Forge* forge, const char* str, uint32_t len)
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_uri(LV2_Atom_Forge* forge, const char* uri, uint32_t len)
{
- return lv2_atom_forge_typed_string(forge, forge->URI, uri, len);
+ return lv2_atom_forge_typed_string(forge, forge->URI, uri, len);
}
/** Write an atom:Path. Note that `path` need not be NULL terminated. */
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_path(LV2_Atom_Forge* forge, const char* path, uint32_t len)
{
- return lv2_atom_forge_typed_string(forge, forge->Path, path, len);
+ return lv2_atom_forge_typed_string(forge, forge->Path, path, len);
}
/** Write an atom:Literal. */
@@ -464,21 +460,19 @@ lv2_atom_forge_literal(LV2_Atom_Forge* forge,
uint32_t datatype,
uint32_t lang)
{
- const LV2_Atom_Literal a = {
- { (uint32_t)(sizeof(LV2_Atom_Literal) - sizeof(LV2_Atom) + len + 1),
- forge->Literal },
- { datatype,
- lang }
- };
- LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a));
- if (out) {
- if (!lv2_atom_forge_string_body(forge, str, len)) {
- LV2_Atom* atom = lv2_atom_forge_deref(forge, out);
- atom->size = atom->type = 0;
- out = 0;
- }
- }
- return out;
+ const LV2_Atom_Literal a = {
+ {(uint32_t)(sizeof(LV2_Atom_Literal) - sizeof(LV2_Atom) + len + 1),
+ forge->Literal},
+ {datatype, lang}};
+ LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a));
+ if (out) {
+ if (!lv2_atom_forge_string_body(forge, str, len)) {
+ LV2_Atom* atom = lv2_atom_forge_deref(forge, out);
+ atom->size = atom->type = 0;
+ out = 0;
+ }
+ }
+ return out;
}
/** Start an atom:Vector. */
@@ -488,12 +482,10 @@ lv2_atom_forge_vector_head(LV2_Atom_Forge* forge,
uint32_t child_size,
uint32_t child_type)
{
- const LV2_Atom_Vector a = {
- { sizeof(LV2_Atom_Vector_Body), forge->Vector },
- { child_size, child_type }
- };
- return lv2_atom_forge_push(
- forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
+ const LV2_Atom_Vector a = {{sizeof(LV2_Atom_Vector_Body), forge->Vector},
+ {child_size, child_type}};
+ return lv2_atom_forge_push(
+ forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
}
/** Write a complete atom:Vector. */
@@ -504,16 +496,15 @@ lv2_atom_forge_vector(LV2_Atom_Forge* forge,
uint32_t n_elems,
const void* elems)
{
- const LV2_Atom_Vector a = {
- { (uint32_t)(sizeof(LV2_Atom_Vector_Body) + n_elems * child_size),
- forge->Vector },
- { child_size, child_type }
- };
- LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
- if (out) {
- lv2_atom_forge_write(forge, elems, child_size * n_elems);
- }
- return out;
+ const LV2_Atom_Vector a = {
+ {(uint32_t)(sizeof(LV2_Atom_Vector_Body) + n_elems * child_size),
+ forge->Vector},
+ {child_size, child_type}};
+ LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a));
+ if (out) {
+ lv2_atom_forge_write(forge, elems, child_size * n_elems);
+ }
+ return out;
}
/**
@@ -536,9 +527,9 @@ lv2_atom_forge_vector(LV2_Atom_Forge* forge,
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_tuple(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame)
{
- const LV2_Atom_Tuple a = { { 0, forge->Tuple } };
- return lv2_atom_forge_push(
- forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
+ const LV2_Atom_Tuple a = {{0, forge->Tuple}};
+ return lv2_atom_forge_push(
+ forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
}
/**
@@ -571,12 +562,10 @@ lv2_atom_forge_object(LV2_Atom_Forge* forge,
LV2_URID id,
LV2_URID otype)
{
- const LV2_Atom_Object a = {
- { (uint32_t)sizeof(LV2_Atom_Object_Body), forge->Object },
- { id, otype }
- };
- return lv2_atom_forge_push(
- forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
+ const LV2_Atom_Object a = {
+ {(uint32_t)sizeof(LV2_Atom_Object_Body), forge->Object}, {id, otype}};
+ return lv2_atom_forge_push(
+ forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
}
/**
@@ -592,12 +581,10 @@ lv2_atom_forge_resource(LV2_Atom_Forge* forge,
LV2_URID id,
LV2_URID otype)
{
- const LV2_Atom_Object a = {
- { (uint32_t)sizeof(LV2_Atom_Object_Body), forge->Resource },
- { id, otype }
- };
- return lv2_atom_forge_push(
- forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
+ const LV2_Atom_Object a = {
+ {(uint32_t)sizeof(LV2_Atom_Object_Body), forge->Resource}, {id, otype}};
+ return lv2_atom_forge_push(
+ forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
}
/**
@@ -613,12 +600,10 @@ lv2_atom_forge_blank(LV2_Atom_Forge* forge,
uint32_t id,
LV2_URID otype)
{
- const LV2_Atom_Object a = {
- { (uint32_t)sizeof(LV2_Atom_Object_Body), forge->Blank },
- { id, otype }
- };
- return lv2_atom_forge_push(
- forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
+ const LV2_Atom_Object a = {
+ {(uint32_t)sizeof(LV2_Atom_Object_Body), forge->Blank}, {id, otype}};
+ return lv2_atom_forge_push(
+ forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
}
/**
@@ -627,11 +612,10 @@ lv2_atom_forge_blank(LV2_Atom_Forge* forge,
See lv2_atom_forge_object() documentation for an example.
*/
static inline LV2_Atom_Forge_Ref
-lv2_atom_forge_key(LV2_Atom_Forge* forge,
- LV2_URID key)
+lv2_atom_forge_key(LV2_Atom_Forge* forge, LV2_URID key)
{
- const LV2_Atom_Property_Body a = { key, 0, { 0, 0 } };
- return lv2_atom_forge_write(forge, &a, 2 * (uint32_t)sizeof(uint32_t));
+ const LV2_Atom_Property_Body a = {key, 0, {0, 0}};
+ return lv2_atom_forge_write(forge, &a, 2 * (uint32_t)sizeof(uint32_t));
}
/**
@@ -645,8 +629,8 @@ lv2_atom_forge_property_head(LV2_Atom_Forge* forge,
LV2_URID key,
LV2_URID context)
{
- const LV2_Atom_Property_Body a = { key, context, { 0, 0 } };
- return lv2_atom_forge_write(forge, &a, 2 * (uint32_t)sizeof(uint32_t));
+ const LV2_Atom_Property_Body a = {key, context, {0, 0}};
+ return lv2_atom_forge_write(forge, &a, 2 * (uint32_t)sizeof(uint32_t));
}
/**
@@ -657,12 +641,10 @@ lv2_atom_forge_sequence_head(LV2_Atom_Forge* forge,
LV2_Atom_Forge_Frame* frame,
uint32_t unit)
{
- const LV2_Atom_Sequence a = {
- { (uint32_t)sizeof(LV2_Atom_Sequence_Body), forge->Sequence },
- { unit, 0 }
- };
- return lv2_atom_forge_push(
- forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
+ const LV2_Atom_Sequence a = {
+ {(uint32_t)sizeof(LV2_Atom_Sequence_Body), forge->Sequence}, {unit, 0}};
+ return lv2_atom_forge_push(
+ forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a)));
}
/**
@@ -673,7 +655,7 @@ lv2_atom_forge_sequence_head(LV2_Atom_Forge* forge,
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_frame_time(LV2_Atom_Forge* forge, int64_t frames)
{
- return lv2_atom_forge_write(forge, &frames, sizeof(frames));
+ return lv2_atom_forge_write(forge, &frames, sizeof(frames));
}
/**
@@ -684,13 +666,13 @@ lv2_atom_forge_frame_time(LV2_Atom_Forge* forge, int64_t frames)
static inline LV2_Atom_Forge_Ref
lv2_atom_forge_beat_time(LV2_Atom_Forge* forge, double beats)
{
- return lv2_atom_forge_write(forge, &beats, sizeof(beats));
+ return lv2_atom_forge_write(forge, &beats, sizeof(beats));
}
LV2_RESTORE_WARNINGS
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
@@ -698,4 +680,4 @@ LV2_RESTORE_WARNINGS
@}
*/
-#endif /* LV2_ATOM_FORGE_H */
+#endif /* LV2_ATOM_FORGE_H */
diff --git a/lv2/atom/util.h b/lv2/atom/util.h
index 98c9edb..4818d96 100644
--- a/lv2/atom/util.h
+++ b/lv2/atom/util.h
@@ -49,30 +49,29 @@ extern "C" {
static inline uint32_t
lv2_atom_pad_size(uint32_t size)
{
- return (size + 7U) & (~7U);
+ return (size + 7U) & (~7U);
}
/** Return the total size of `atom`, including the header. */
static inline uint32_t
lv2_atom_total_size(const LV2_Atom* atom)
{
- return (uint32_t)sizeof(LV2_Atom) + atom->size;
+ return (uint32_t)sizeof(LV2_Atom) + atom->size;
}
/** Return true iff `atom` is null. */
static inline bool
lv2_atom_is_null(const LV2_Atom* atom)
{
- return !atom || (atom->type == 0 && atom->size == 0);
+ return !atom || (atom->type == 0 && atom->size == 0);
}
/** Return true iff `a` is equal to `b`. */
static inline bool
lv2_atom_equals(const LV2_Atom* a, const LV2_Atom* b)
{
- return (a == b) || ((a->type == b->type) &&
- (a->size == b->size) &&
- !memcmp(a + 1, b + 1, a->size));
+ return (a == b) || ((a->type == b->type) && (a->size == b->size) &&
+ !memcmp(a + 1, b + 1, a->size));
}
/**
@@ -84,14 +83,14 @@ lv2_atom_equals(const LV2_Atom* a, const LV2_Atom* b)
static inline LV2_Atom_Event*
lv2_atom_sequence_begin(const LV2_Atom_Sequence_Body* body)
{
- return (LV2_Atom_Event*)(body + 1);
+ return (LV2_Atom_Event*)(body + 1);
}
/** Get an iterator pointing to the end of a Sequence body. */
static inline LV2_Atom_Event*
lv2_atom_sequence_end(const LV2_Atom_Sequence_Body* body, uint32_t size)
{
- return (LV2_Atom_Event*)((const uint8_t*)body + lv2_atom_pad_size(size));
+ return (LV2_Atom_Event*)((const uint8_t*)body + lv2_atom_pad_size(size));
}
/** Return true iff `i` has reached the end of `body`. */
@@ -100,16 +99,15 @@ lv2_atom_sequence_is_end(const LV2_Atom_Sequence_Body* body,
uint32_t size,
const LV2_Atom_Event* i)
{
- return (const uint8_t*)i >= ((const uint8_t*)body + size);
+ return (const uint8_t*)i >= ((const uint8_t*)body + size);
}
/** Return an iterator to the element following `i`. */
static inline LV2_Atom_Event*
lv2_atom_sequence_next(const LV2_Atom_Event* i)
{
- return (LV2_Atom_Event*)((const uint8_t*)i
- + sizeof(LV2_Atom_Event)
- + lv2_atom_pad_size(i->body.size));
+ return (LV2_Atom_Event*)((const uint8_t*)i + sizeof(LV2_Atom_Event) +
+ lv2_atom_pad_size(i->body.size));
}
/**
@@ -126,16 +124,16 @@ lv2_atom_sequence_next(const LV2_Atom_Event* i)
}
@endcode
*/
-#define LV2_ATOM_SEQUENCE_FOREACH(seq, iter) \
- for (LV2_Atom_Event* (iter) = lv2_atom_sequence_begin(&(seq)->body); \
- !lv2_atom_sequence_is_end(&(seq)->body, (seq)->atom.size, (iter)); \
- (iter) = lv2_atom_sequence_next(iter))
+#define LV2_ATOM_SEQUENCE_FOREACH(seq, iter) \
+ for (LV2_Atom_Event * (iter) = lv2_atom_sequence_begin(&(seq)->body); \
+ !lv2_atom_sequence_is_end(&(seq)->body, (seq)->atom.size, (iter)); \
+ (iter) = lv2_atom_sequence_next(iter))
/** Like LV2_ATOM_SEQUENCE_FOREACH but for a headerless sequence body. */
-#define LV2_ATOM_SEQUENCE_BODY_FOREACH(body, size, iter) \
- for (LV2_Atom_Event* (iter) = lv2_atom_sequence_begin(body); \
- !lv2_atom_sequence_is_end(body, size, (iter)); \
- (iter) = lv2_atom_sequence_next(iter))
+#define LV2_ATOM_SEQUENCE_BODY_FOREACH(body, size, iter) \
+ for (LV2_Atom_Event * (iter) = lv2_atom_sequence_begin(body); \
+ !lv2_atom_sequence_is_end(body, size, (iter)); \
+ (iter) = lv2_atom_sequence_next(iter))
/**
@}
@@ -151,7 +149,7 @@ lv2_atom_sequence_next(const LV2_Atom_Event* i)
static inline void
lv2_atom_sequence_clear(LV2_Atom_Sequence* seq)
{
- seq->atom.size = sizeof(LV2_Atom_Sequence_Body);
+ seq->atom.size = sizeof(LV2_Atom_Sequence_Body);
}
/**
@@ -170,17 +168,17 @@ lv2_atom_sequence_append_event(LV2_Atom_Sequence* seq,
uint32_t capacity,
const LV2_Atom_Event* event)
{
- const uint32_t total_size = (uint32_t)sizeof(*event) + event->body.size;
- if (capacity - seq->atom.size < total_size) {
- return NULL;
- }
+ const uint32_t total_size = (uint32_t)sizeof(*event) + event->body.size;
+ if (capacity - seq->atom.size < total_size) {
+ return NULL;
+ }
- LV2_Atom_Event* e = lv2_atom_sequence_end(&seq->body, seq->atom.size);
- memcpy(e, event, total_size);
+ LV2_Atom_Event* e = lv2_atom_sequence_end(&seq->body, seq->atom.size);
+ memcpy(e, event, total_size);
- seq->atom.size += lv2_atom_pad_size(total_size);
+ seq->atom.size += lv2_atom_pad_size(total_size);
- return e;
+ return e;
}
/**
@@ -193,22 +191,22 @@ lv2_atom_sequence_append_event(LV2_Atom_Sequence* seq,
static inline LV2_Atom*
lv2_atom_tuple_begin(const LV2_Atom_Tuple* tup)
{
- return (LV2_Atom*)(LV2_ATOM_BODY(tup));
+ return (LV2_Atom*)(LV2_ATOM_BODY(tup));
}
/** Return true iff `i` has reached the end of `body`. */
static inline bool
lv2_atom_tuple_is_end(const void* body, uint32_t size, const LV2_Atom* i)
{
- return (const uint8_t*)i >= ((const uint8_t*)body + size);
+ return (const uint8_t*)i >= ((const uint8_t*)body + size);
}
/** Return an iterator to the element following `i`. */
static inline LV2_Atom*
lv2_atom_tuple_next(const LV2_Atom* i)
{
- return (LV2_Atom*)(
- (const uint8_t*)i + sizeof(LV2_Atom) + lv2_atom_pad_size(i->size));
+ return (LV2_Atom*)((const uint8_t*)i + sizeof(LV2_Atom) +
+ lv2_atom_pad_size(i->size));
}
/**
@@ -225,16 +223,17 @@ lv2_atom_tuple_next(const LV2_Atom* i)
}
@endcode
*/
-#define LV2_ATOM_TUPLE_FOREACH(tuple, iter) \
- for (LV2_Atom* (iter) = lv2_atom_tuple_begin(tuple); \
- !lv2_atom_tuple_is_end(LV2_ATOM_BODY(tuple), (tuple)->atom.size, (iter)); \
- (iter) = lv2_atom_tuple_next(iter))
+#define LV2_ATOM_TUPLE_FOREACH(tuple, iter) \
+ for (LV2_Atom * (iter) = lv2_atom_tuple_begin(tuple); \
+ !lv2_atom_tuple_is_end( \
+ LV2_ATOM_BODY(tuple), (tuple)->atom.size, (iter)); \
+ (iter) = lv2_atom_tuple_next(iter))
/** Like LV2_ATOM_TUPLE_FOREACH but for a headerless tuple body. */
#define LV2_ATOM_TUPLE_BODY_FOREACH(body, size, iter) \
- for (LV2_Atom* (iter) = (LV2_Atom*)(body); \
- !lv2_atom_tuple_is_end(body, size, (iter)); \
- (iter) = lv2_atom_tuple_next(iter))
+ for (LV2_Atom * (iter) = (LV2_Atom*)(body); \
+ !lv2_atom_tuple_is_end(body, size, (iter)); \
+ (iter) = lv2_atom_tuple_next(iter))
/**
@}
@@ -246,7 +245,7 @@ lv2_atom_tuple_next(const LV2_Atom* i)
static inline LV2_Atom_Property_Body*
lv2_atom_object_begin(const LV2_Atom_Object_Body* body)
{
- return (LV2_Atom_Property_Body*)(body + 1);
+ return (LV2_Atom_Property_Body*)(body + 1);
}
/** Return true iff `i` has reached the end of `obj`. */
@@ -255,18 +254,19 @@ lv2_atom_object_is_end(const LV2_Atom_Object_Body* body,
uint32_t size,
const LV2_Atom_Property_Body* i)
{
- return (const uint8_t*)i >= ((const uint8_t*)body + size);
+ return (const uint8_t*)i >= ((const uint8_t*)body + size);
}
/** Return an iterator to the property following `i`. */
static inline LV2_Atom_Property_Body*
lv2_atom_object_next(const LV2_Atom_Property_Body* i)
{
- const LV2_Atom* const value = (const LV2_Atom*)(
- (const uint8_t*)i + 2 * sizeof(uint32_t));
- return (LV2_Atom_Property_Body*)(
- (const uint8_t*)i + lv2_atom_pad_size(
- (uint32_t)sizeof(LV2_Atom_Property_Body) + value->size));
+ const LV2_Atom* const value =
+ (const LV2_Atom*)((const uint8_t*)i + 2 * sizeof(uint32_t));
+ return (LV2_Atom_Property_Body*)((const uint8_t*)i +
+ lv2_atom_pad_size(
+ (uint32_t)sizeof(LV2_Atom_Property_Body) +
+ value->size));
}
/**
@@ -283,16 +283,16 @@ lv2_atom_object_next(const LV2_Atom_Property_Body* i)
}
@endcode
*/
-#define LV2_ATOM_OBJECT_FOREACH(obj, iter) \
- for (LV2_Atom_Property_Body* (iter) = lv2_atom_object_begin(&(obj)->body); \
- !lv2_atom_object_is_end(&(obj)->body, (obj)->atom.size, (iter)); \
- (iter) = lv2_atom_object_next(iter))
+#define LV2_ATOM_OBJECT_FOREACH(obj, iter) \
+ for (LV2_Atom_Property_Body * (iter) = lv2_atom_object_begin(&(obj)->body); \
+ !lv2_atom_object_is_end(&(obj)->body, (obj)->atom.size, (iter)); \
+ (iter) = lv2_atom_object_next(iter))
/** Like LV2_ATOM_OBJECT_FOREACH but for a headerless object body. */
-#define LV2_ATOM_OBJECT_BODY_FOREACH(body, size, iter) \
- for (LV2_Atom_Property_Body* (iter) = lv2_atom_object_begin(body); \
- !lv2_atom_object_is_end(body, size, (iter)); \
- (iter) = lv2_atom_object_next(iter))
+#define LV2_ATOM_OBJECT_BODY_FOREACH(body, size, iter) \
+ for (LV2_Atom_Property_Body * (iter) = lv2_atom_object_begin(body); \
+ !lv2_atom_object_is_end(body, size, (iter)); \
+ (iter) = lv2_atom_object_next(iter))
/**
@}
@@ -302,12 +302,12 @@ lv2_atom_object_next(const LV2_Atom_Property_Body* i)
/** A single entry in an Object query. */
typedef struct {
- uint32_t key; /**< Key to query (input set by user) */
- const LV2_Atom** value; /**< Found value (output set by query function) */
+ uint32_t key; /**< Key to query (input set by user) */
+ const LV2_Atom** value; /**< Found value (output set by query function) */
} LV2_Atom_Object_Query;
/** Sentinel for lv2_atom_object_query(). */
-static const LV2_Atom_Object_Query LV2_ATOM_OBJECT_QUERY_END = { 0, NULL };
+static const LV2_Atom_Object_Query LV2_ATOM_OBJECT_QUERY_END = {0, NULL};
/**
Get an object's values for various keys.
@@ -338,26 +338,26 @@ static inline int
lv2_atom_object_query(const LV2_Atom_Object* object,
LV2_Atom_Object_Query* query)
{
- int matches = 0;
- int n_queries = 0;
-
- /* Count number of query keys so we can short-circuit when done */
- for (LV2_Atom_Object_Query* q = query; q->key; ++q) {
- ++n_queries;
- }
-
- LV2_ATOM_OBJECT_FOREACH(object, prop) {
- for (LV2_Atom_Object_Query* q = query; q->key; ++q) {
- if (q->key == prop->key && !*q->value) {
- *q->value = &prop->value;
- if (++matches == n_queries) {
- return matches;
- }
- break;
- }
- }
- }
- return matches;
+ int matches = 0;
+ int n_queries = 0;
+
+ /* Count number of query keys so we can short-circuit when done */
+ for (LV2_Atom_Object_Query* q = query; q->key; ++q) {
+ ++n_queries;
+ }
+
+ LV2_ATOM_OBJECT_FOREACH (object, prop) {
+ for (LV2_Atom_Object_Query* q = query; q->key; ++q) {
+ if (q->key == prop->key && !*q->value) {
+ *q->value = &prop->value;
+ if (++matches == n_queries) {
+ return matches;
+ }
+ break;
+ }
+ }
+ }
+ return matches;
}
/**
@@ -366,37 +366,37 @@ lv2_atom_object_query(const LV2_Atom_Object* object,
static inline int
lv2_atom_object_body_get(uint32_t size, const LV2_Atom_Object_Body* body, ...)
{
- int matches = 0;
- int n_queries = 0;
-
- /* Count number of keys so we can short-circuit when done */
- va_list args;
- va_start(args, body);
- for (n_queries = 0; va_arg(args, uint32_t); ++n_queries) {
- if (!va_arg(args, const LV2_Atom**)) {
- va_end(args);
- return -1;
- }
- }
- va_end(args);
-
- LV2_ATOM_OBJECT_BODY_FOREACH(body, size, prop) {
- va_start(args, body);
- for (int i = 0; i < n_queries; ++i) {
- uint32_t qkey = va_arg(args, uint32_t);
- const LV2_Atom** qval = va_arg(args, const LV2_Atom**);
- if (qkey == prop->key && !*qval) {
- *qval = &prop->value;
- if (++matches == n_queries) {
- va_end(args);
- return matches;
- }
- break;
- }
- }
- va_end(args);
- }
- return matches;
+ int matches = 0;
+ int n_queries = 0;
+
+ /* Count number of keys so we can short-circuit when done */
+ va_list args;
+ va_start(args, body);
+ for (n_queries = 0; va_arg(args, uint32_t); ++n_queries) {
+ if (!va_arg(args, const LV2_Atom**)) {
+ va_end(args);
+ return -1;
+ }
+ }
+ va_end(args);
+
+ LV2_ATOM_OBJECT_BODY_FOREACH (body, size, prop) {
+ va_start(args, body);
+ for (int i = 0; i < n_queries; ++i) {
+ uint32_t qkey = va_arg(args, uint32_t);
+ const LV2_Atom** qval = va_arg(args, const LV2_Atom**);
+ if (qkey == prop->key && !*qval) {
+ *qval = &prop->value;
+ if (++matches == n_queries) {
+ va_end(args);
+ return matches;
+ }
+ break;
+ }
+ }
+ va_end(args);
+ }
+ return matches;
}
/**
@@ -421,37 +421,37 @@ lv2_atom_object_body_get(uint32_t size, const LV2_Atom_Object_Body* body, ...)
static inline int
lv2_atom_object_get(const LV2_Atom_Object* object, ...)
{
- int matches = 0;
- int n_queries = 0;
-
- /* Count number of keys so we can short-circuit when done */
- va_list args;
- va_start(args, object);
- for (n_queries = 0; va_arg(args, uint32_t); ++n_queries) {
- if (!va_arg(args, const LV2_Atom**)) {
- va_end(args);
- return -1;
- }
- }
- va_end(args);
-
- LV2_ATOM_OBJECT_FOREACH(object, prop) {
- va_start(args, object);
- for (int i = 0; i < n_queries; ++i) {
- uint32_t qkey = va_arg(args, uint32_t);
- const LV2_Atom** qval = va_arg(args, const LV2_Atom**);
- if (qkey == prop->key && !*qval) {
- *qval = &prop->value;
- if (++matches == n_queries) {
- va_end(args);
- return matches;
- }
- break;
- }
- }
- va_end(args);
- }
- return matches;
+ int matches = 0;
+ int n_queries = 0;
+
+ /* Count number of keys so we can short-circuit when done */
+ va_list args;
+ va_start(args, object);
+ for (n_queries = 0; va_arg(args, uint32_t); ++n_queries) {
+ if (!va_arg(args, const LV2_Atom**)) {
+ va_end(args);
+ return -1;
+ }
+ }
+ va_end(args);
+
+ LV2_ATOM_OBJECT_FOREACH (object, prop) {
+ va_start(args, object);
+ for (int i = 0; i < n_queries; ++i) {
+ uint32_t qkey = va_arg(args, uint32_t);
+ const LV2_Atom** qval = va_arg(args, const LV2_Atom**);
+ if (qkey == prop->key && !*qval) {
+ *qval = &prop->value;
+ if (++matches == n_queries) {
+ va_end(args);
+ return matches;
+ }
+ break;
+ }
+ }
+ va_end(args);
+ }
+ return matches;
}
/**
@@ -477,43 +477,42 @@ lv2_atom_object_get(const LV2_Atom_Object* object, ...)
static inline int
lv2_atom_object_get_typed(const LV2_Atom_Object* object, ...)
{
- int matches = 0;
- int n_queries = 0;
-
- /* Count number of keys so we can short-circuit when done */
- va_list args;
- va_start(args, object);
- for (n_queries = 0; va_arg(args, uint32_t); ++n_queries) {
- if (!va_arg(args, const LV2_Atom**) ||
- !va_arg(args, uint32_t)) {
- va_end(args);
- return -1;
- }
- }
- va_end(args);
-
- LV2_ATOM_OBJECT_FOREACH(object, prop) {
- va_start(args, object);
- for (int i = 0; i < n_queries; ++i) {
- const uint32_t qkey = va_arg(args, uint32_t);
- const LV2_Atom** qval = va_arg(args, const LV2_Atom**);
- const uint32_t qtype = va_arg(args, uint32_t);
- if (!*qval && qkey == prop->key && qtype == prop->value.type) {
- *qval = &prop->value;
- if (++matches == n_queries) {
- va_end(args);
- return matches;
- }
- break;
- }
- }
- va_end(args);
- }
- return matches;
+ int matches = 0;
+ int n_queries = 0;
+
+ /* Count number of keys so we can short-circuit when done */
+ va_list args;
+ va_start(args, object);
+ for (n_queries = 0; va_arg(args, uint32_t); ++n_queries) {
+ if (!va_arg(args, const LV2_Atom**) || !va_arg(args, uint32_t)) {
+ va_end(args);
+ return -1;
+ }
+ }
+ va_end(args);
+
+ LV2_ATOM_OBJECT_FOREACH (object, prop) {
+ va_start(args, object);
+ for (int i = 0; i < n_queries; ++i) {
+ const uint32_t qkey = va_arg(args, uint32_t);
+ const LV2_Atom** qval = va_arg(args, const LV2_Atom**);
+ const uint32_t qtype = va_arg(args, uint32_t);
+ if (!*qval && qkey == prop->key && qtype == prop->value.type) {
+ *qval = &prop->value;
+ if (++matches == n_queries) {
+ va_end(args);
+ return matches;
+ }
+ break;
+ }
+ }
+ va_end(args);
+ }
+ return matches;
}
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
diff --git a/lv2/buf-size/buf-size.h b/lv2/buf-size/buf-size.h
index 98f23ab..98a812c 100644
--- a/lv2/buf-size/buf-size.h
+++ b/lv2/buf-size/buf-size.h
@@ -48,4 +48,4 @@
@}
*/
-#endif /* LV2_BUF_SIZE_H */
+#endif /* LV2_BUF_SIZE_H */
diff --git a/lv2/core/attributes.h b/lv2/core/attributes.h
index 672d716..0281d97 100644
--- a/lv2/core/attributes.h
+++ b/lv2/core/attributes.h
@@ -27,29 +27,29 @@
*/
#if defined(__GNUC__) && __GNUC__ > 3
-#define LV2_DEPRECATED __attribute__((__deprecated__))
+# define LV2_DEPRECATED __attribute__((__deprecated__))
#else
-#define LV2_DEPRECATED
+# define LV2_DEPRECATED
#endif
#if defined(__clang__)
-#define LV2_DISABLE_DEPRECATION_WARNINGS \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
+# define LV2_DISABLE_DEPRECATION_WARNINGS \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
#elif defined(__GNUC__) && __GNUC__ > 4
-#define LV2_DISABLE_DEPRECATION_WARNINGS \
- _Pragma("GCC diagnostic push") \
- _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+# define LV2_DISABLE_DEPRECATION_WARNINGS \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#else
-#define LV2_DISABLE_DEPRECATION_WARNINGS
+# define LV2_DISABLE_DEPRECATION_WARNINGS
#endif
#if defined(__clang__)
-#define LV2_RESTORE_WARNINGS _Pragma("clang diagnostic pop")
+# define LV2_RESTORE_WARNINGS _Pragma("clang diagnostic pop")
#elif defined(__GNUC__) && __GNUC__ > 4
-#define LV2_RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
+# define LV2_RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
#else
-#define LV2_RESTORE_WARNINGS
+# define LV2_RESTORE_WARNINGS
#endif
/**
diff --git a/lv2/core/lv2.h b/lv2/core/lv2.h
index c0376e9..82bc7ab 100644
--- a/lv2/core/lv2.h
+++ b/lv2/core/lv2.h
@@ -144,7 +144,7 @@ extern "C" {
compare to NULL (or 0 for C++) but otherwise the host MUST NOT attempt to
interpret it.
*/
-typedef void * LV2_Handle;
+typedef void* LV2_Handle;
/**
Feature.
@@ -155,20 +155,20 @@ typedef void * LV2_Handle;
Some features, such as lv2:isLive, do not require the host to pass data.
*/
typedef struct {
- /**
- A globally unique, case-sensitive identifier (URI) for this feature.
+ /**
+ A globally unique, case-sensitive identifier (URI) for this feature.
- This MUST be a valid URI string as defined by RFC 3986.
- */
- const char * URI;
+ This MUST be a valid URI string as defined by RFC 3986.
+ */
+ const char* URI;
- /**
- Pointer to arbitrary data.
+ /**
+ Pointer to arbitrary data.
- The format of this data is defined by the extension which describes the
- feature with the given `URI`.
- */
- void * data;
+ The format of this data is defined by the extension which describes the
+ feature with the given `URI`.
+ */
+ void* data;
} LV2_Feature;
/**
@@ -178,190 +178,187 @@ typedef struct {
a plugin.
*/
typedef struct LV2_Descriptor {
- /**
- A globally unique, case-sensitive identifier for this plugin.
-
- This MUST be a valid URI string as defined by RFC 3986. All plugins with
- the same URI MUST be compatible to some degree, see
- http://lv2plug.in/ns/lv2core for details.
- */
- const char * URI;
-
- /**
- Instantiate the plugin.
-
- Note that instance initialisation should generally occur in activate()
- rather than here. If a host calls instantiate(), it MUST call cleanup()
- at some point in the future.
-
- @param descriptor Descriptor of the plugin to instantiate.
-
- @param sample_rate Sample rate, in Hz, for the new plugin instance.
-
- @param bundle_path Path to the LV2 bundle which contains this plugin
- binary. It MUST include the trailing directory separator so that simply
- appending a filename will yield the path to that file in the bundle.
-
- @param features A NULL terminated array of LV2_Feature structs which
- represent the features the host supports. Plugins may refuse to
- instantiate if required features are not found here. However, hosts MUST
- NOT use this as a discovery mechanism: instead, use the RDF data to
- determine which features are required and do not attempt to instantiate
- unsupported plugins at all. This parameter MUST NOT be NULL, i.e. a host
- that supports no features MUST pass a single element array containing
- NULL.
-
- @return A handle for the new plugin instance, or NULL if instantiation
- has failed.
- */
- LV2_Handle (*instantiate)(const struct LV2_Descriptor * descriptor,
- double sample_rate,
- const char * bundle_path,
- const LV2_Feature *const * features);
-
- /**
- Connect a port on a plugin instance to a memory location.
-
- Plugin writers should be aware that the host may elect to use the same
- buffer for more than one port and even use the same buffer for both
- input and output (see lv2:inPlaceBroken in lv2.ttl).
-
- If the plugin has the feature lv2:hardRTCapable then there are various
- things that the plugin MUST NOT do within the connect_port() function;
- see lv2core.ttl for details.
-
- connect_port() MUST be called at least once for each port before run()
- is called, unless that port is lv2:connectionOptional. The plugin must
- pay careful attention to the block size passed to run() since the block
- allocated may only just be large enough to contain the data, and is not
- guaranteed to remain constant between run() calls.
-
- connect_port() may be called more than once for a plugin instance to
- allow the host to change the buffers that the plugin is reading or
- writing. These calls may be made before or after activate() or
- deactivate() calls.
-
- @param instance Plugin instance containing the port.
-
- @param port Index of the port to connect. The host MUST NOT try to
- connect a port index that is not defined in the plugin's RDF data. If
- it does, the plugin's behaviour is undefined (a crash is likely).
-
- @param data_location Pointer to data of the type defined by the port
- type in the plugin's RDF data (for example, an array of float for an
- lv2:AudioPort). This pointer must be stored by the plugin instance and
- used to read/write data when run() is called. Data present at the time
- of the connect_port() call MUST NOT be considered meaningful.
- */
- void (*connect_port)(LV2_Handle instance,
- uint32_t port,
- void * data_location);
-
- /**
- Initialise a plugin instance and activate it for use.
-
- This is separated from instantiate() to aid real-time support and so
- that hosts can reinitialise a plugin instance by calling deactivate()
- and then activate(). In this case the plugin instance MUST reset all
- state information dependent on the history of the plugin instance except
- for any data locations provided by connect_port(). If there is nothing
- for activate() to do then this field may be NULL.
-
- When present, hosts MUST call this function once before run() is called
- for the first time. This call SHOULD be made as close to the run() call
- as possible and indicates to real-time plugins that they are now live,
- however plugins MUST NOT rely on a prompt call to run() after
- activate().
-
- The host MUST NOT call activate() again until deactivate() has been
- called first. If a host calls activate(), it MUST call deactivate() at
- some point in the future. Note that connect_port() may be called before
- or after activate().
- */
- void (*activate)(LV2_Handle instance);
-
- /**
- Run a plugin instance for a block.
-
- Note that if an activate() function exists then it must be called before
- run(). If deactivate() is called for a plugin instance then run() may
- not be called until activate() has been called again.
-
- If the plugin has the feature lv2:hardRTCapable then there are various
- things that the plugin MUST NOT do within the run() function (see
- lv2core.ttl for details).
-
- As a special case, when `sample_count` is 0, the plugin should update
- any output ports that represent a single instant in time (for example,
- control ports, but not audio ports). This is particularly useful for
- latent plugins, which should update their latency output port so hosts
- can pre-roll plugins to compute latency. Plugins MUST NOT crash when
- `sample_count` is 0.
-
- @param instance Instance to be run.
-
- @param sample_count The block size (in samples) for which the plugin
- instance must run.
- */
- void (*run)(LV2_Handle instance,
- uint32_t sample_count);
-
- /**
- Deactivate a plugin instance (counterpart to activate()).
-
- Hosts MUST deactivate all activated instances after they have been run()
- for the last time. This call SHOULD be made as close to the last run()
- call as possible and indicates to real-time plugins that they are no
- longer live, however plugins MUST NOT rely on prompt deactivation. If
- there is nothing for deactivate() to do then this field may be NULL
-
- Deactivation is not similar to pausing since the plugin instance will be
- reinitialised by activate(). However, deactivate() itself MUST NOT fully
- reset plugin state. For example, the host may deactivate a plugin, then
- store its state (using some extension to do so).
-
- Hosts MUST NOT call deactivate() unless activate() was previously
- called. Note that connect_port() may be called before or after
- deactivate().
- */
- void (*deactivate)(LV2_Handle instance);
-
- /**
- Clean up a plugin instance (counterpart to instantiate()).
-
- Once an instance of a plugin has been finished with it must be deleted
- using this function. The instance handle passed ceases to be valid after
- this call.
-
- If activate() was called for a plugin instance then a corresponding call
- to deactivate() MUST be made before cleanup() is called. Hosts MUST NOT
- call cleanup() unless instantiate() was previously called.
- */
- void (*cleanup)(LV2_Handle instance);
-
- /**
- Return additional plugin data defined by some extenion.
-
- A typical use of this facility is to return a struct containing function
- pointers to extend the LV2_Descriptor API.
-
- The actual type and meaning of the returned object MUST be specified
- precisely by the extension. This function MUST return NULL for any
- unsupported URI. If a plugin does not support any extension data, this
- field may be NULL.
-
- The host is never responsible for freeing the returned value.
- */
- const void * (*extension_data)(const char * uri);
+ /**
+ A globally unique, case-sensitive identifier for this plugin.
+
+ This MUST be a valid URI string as defined by RFC 3986. All plugins with
+ the same URI MUST be compatible to some degree, see
+ http://lv2plug.in/ns/lv2core for details.
+ */
+ const char* URI;
+
+ /**
+ Instantiate the plugin.
+
+ Note that instance initialisation should generally occur in activate()
+ rather than here. If a host calls instantiate(), it MUST call cleanup()
+ at some point in the future.
+
+ @param descriptor Descriptor of the plugin to instantiate.
+
+ @param sample_rate Sample rate, in Hz, for the new plugin instance.
+
+ @param bundle_path Path to the LV2 bundle which contains this plugin
+ binary. It MUST include the trailing directory separator so that simply
+ appending a filename will yield the path to that file in the bundle.
+
+ @param features A NULL terminated array of LV2_Feature structs which
+ represent the features the host supports. Plugins may refuse to
+ instantiate if required features are not found here. However, hosts MUST
+ NOT use this as a discovery mechanism: instead, use the RDF data to
+ determine which features are required and do not attempt to instantiate
+ unsupported plugins at all. This parameter MUST NOT be NULL, i.e. a host
+ that supports no features MUST pass a single element array containing
+ NULL.
+
+ @return A handle for the new plugin instance, or NULL if instantiation
+ has failed.
+ */
+ LV2_Handle (*instantiate)(const struct LV2_Descriptor* descriptor,
+ double sample_rate,
+ const char* bundle_path,
+ const LV2_Feature* const* features);
+
+ /**
+ Connect a port on a plugin instance to a memory location.
+
+ Plugin writers should be aware that the host may elect to use the same
+ buffer for more than one port and even use the same buffer for both
+ input and output (see lv2:inPlaceBroken in lv2.ttl).
+
+ If the plugin has the feature lv2:hardRTCapable then there are various
+ things that the plugin MUST NOT do within the connect_port() function;
+ see lv2core.ttl for details.
+
+ connect_port() MUST be called at least once for each port before run()
+ is called, unless that port is lv2:connectionOptional. The plugin must
+ pay careful attention to the block size passed to run() since the block
+ allocated may only just be large enough to contain the data, and is not
+ guaranteed to remain constant between run() calls.
+
+ connect_port() may be called more than once for a plugin instance to
+ allow the host to change the buffers that the plugin is reading or
+ writing. These calls may be made before or after activate() or
+ deactivate() calls.
+
+ @param instance Plugin instance containing the port.
+
+ @param port Index of the port to connect. The host MUST NOT try to
+ connect a port index that is not defined in the plugin's RDF data. If
+ it does, the plugin's behaviour is undefined (a crash is likely).
+
+ @param data_location Pointer to data of the type defined by the port
+ type in the plugin's RDF data (for example, an array of float for an
+ lv2:AudioPort). This pointer must be stored by the plugin instance and
+ used to read/write data when run() is called. Data present at the time
+ of the connect_port() call MUST NOT be considered meaningful.
+ */
+ void (*connect_port)(LV2_Handle instance, uint32_t port, void* data_location);
+
+ /**
+ Initialise a plugin instance and activate it for use.
+
+ This is separated from instantiate() to aid real-time support and so
+ that hosts can reinitialise a plugin instance by calling deactivate()
+ and then activate(). In this case the plugin instance MUST reset all
+ state information dependent on the history of the plugin instance except
+ for any data locations provided by connect_port(). If there is nothing
+ for activate() to do then this field may be NULL.
+
+ When present, hosts MUST call this function once before run() is called
+ for the first time. This call SHOULD be made as close to the run() call
+ as possible and indicates to real-time plugins that they are now live,
+ however plugins MUST NOT rely on a prompt call to run() after
+ activate().
+
+ The host MUST NOT call activate() again until deactivate() has been
+ called first. If a host calls activate(), it MUST call deactivate() at
+ some point in the future. Note that connect_port() may be called before
+ or after activate().
+ */
+ void (*activate)(LV2_Handle instance);
+
+ /**
+ Run a plugin instance for a block.
+
+ Note that if an activate() function exists then it must be called before
+ run(). If deactivate() is called for a plugin instance then run() may
+ not be called until activate() has been called again.
+
+ If the plugin has the feature lv2:hardRTCapable then there are various
+ things that the plugin MUST NOT do within the run() function (see
+ lv2core.ttl for details).
+
+ As a special case, when `sample_count` is 0, the plugin should update
+ any output ports that represent a single instant in time (for example,
+ control ports, but not audio ports). This is particularly useful for
+ latent plugins, which should update their latency output port so hosts
+ can pre-roll plugins to compute latency. Plugins MUST NOT crash when
+ `sample_count` is 0.
+
+ @param instance Instance to be run.
+
+ @param sample_count The block size (in samples) for which the plugin
+ instance must run.
+ */
+ void (*run)(LV2_Handle instance, uint32_t sample_count);
+
+ /**
+ Deactivate a plugin instance (counterpart to activate()).
+
+ Hosts MUST deactivate all activated instances after they have been run()
+ for the last time. This call SHOULD be made as close to the last run()
+ call as possible and indicates to real-time plugins that they are no
+ longer live, however plugins MUST NOT rely on prompt deactivation. If
+ there is nothing for deactivate() to do then this field may be NULL
+
+ Deactivation is not similar to pausing since the plugin instance will be
+ reinitialised by activate(). However, deactivate() itself MUST NOT fully
+ reset plugin state. For example, the host may deactivate a plugin, then
+ store its state (using some extension to do so).
+
+ Hosts MUST NOT call deactivate() unless activate() was previously
+ called. Note that connect_port() may be called before or after
+ deactivate().
+ */
+ void (*deactivate)(LV2_Handle instance);
+
+ /**
+ Clean up a plugin instance (counterpart to instantiate()).
+
+ Once an instance of a plugin has been finished with it must be deleted
+ using this function. The instance handle passed ceases to be valid after
+ this call.
+
+ If activate() was called for a plugin instance then a corresponding call
+ to deactivate() MUST be made before cleanup() is called. Hosts MUST NOT
+ call cleanup() unless instantiate() was previously called.
+ */
+ void (*cleanup)(LV2_Handle instance);
+
+ /**
+ Return additional plugin data defined by some extenion.
+
+ A typical use of this facility is to return a struct containing function
+ pointers to extend the LV2_Descriptor API.
+
+ The actual type and meaning of the returned object MUST be specified
+ precisely by the extension. This function MUST return NULL for any
+ unsupported URI. If a plugin does not support any extension data, this
+ field may be NULL.
+
+ The host is never responsible for freeing the returned value.
+ */
+ const void* (*extension_data)(const char* uri);
} LV2_Descriptor;
/**
Helper macro needed for LV2_SYMBOL_EXPORT when using C++.
*/
#ifdef __cplusplus
-# define LV2_SYMBOL_EXTERN extern "C"
+# define LV2_SYMBOL_EXTERN extern "C"
#else
-# define LV2_SYMBOL_EXTERN
+# define LV2_SYMBOL_EXTERN
#endif
/**
@@ -369,9 +366,10 @@ typedef struct LV2_Descriptor {
by the host as a symbol from the dynamic library.
*/
#ifdef _WIN32
-# define LV2_SYMBOL_EXPORT LV2_SYMBOL_EXTERN __declspec(dllexport)
+# define LV2_SYMBOL_EXPORT LV2_SYMBOL_EXTERN __declspec(dllexport)
#else
-# define LV2_SYMBOL_EXPORT LV2_SYMBOL_EXTERN __attribute__((visibility("default")))
+# define LV2_SYMBOL_EXPORT \
+ LV2_SYMBOL_EXTERN __attribute__((visibility("default")))
#endif
/**
@@ -398,13 +396,13 @@ typedef struct LV2_Descriptor {
consistent between loads of the plugin library.
*/
LV2_SYMBOL_EXPORT
-const LV2_Descriptor * lv2_descriptor(uint32_t index);
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index);
/**
Type of the lv2_descriptor() function in a library (old discovery API).
*/
-typedef const LV2_Descriptor *
-(*LV2_Descriptor_Function)(uint32_t index);
+typedef const LV2_Descriptor* (*LV2_Descriptor_Function)(uint32_t index);
/**
Handle for a library descriptor.
@@ -418,34 +416,33 @@ typedef void* LV2_Lib_Handle;
lv2_lib_descriptor() function in the shared object.
*/
typedef struct {
- /**
- Opaque library data which must be passed as the first parameter to all
- the methods of this struct.
- */
- LV2_Lib_Handle handle;
-
- /**
- The total size of this struct. This allows for this struct to be
- expanded in the future if necessary. This MUST be set by the library to
- sizeof(LV2_Lib_Descriptor). The host MUST NOT access any fields of this
- struct beyond get_plugin() unless this field indicates they are present.
- */
- uint32_t size;
-
- /**
- Destroy this library descriptor and free all related resources.
- */
- void (*cleanup)(LV2_Lib_Handle handle);
-
- /**
- Plugin accessor.
-
- Plugins are accessed by index using values from 0 upwards. Out of range
- indices MUST result in this function returning NULL, so the host can
- enumerate plugins by increasing `index` until NULL is returned.
- */
- const LV2_Descriptor * (*get_plugin)(LV2_Lib_Handle handle,
- uint32_t index);
+ /**
+ Opaque library data which must be passed as the first parameter to all
+ the methods of this struct.
+ */
+ LV2_Lib_Handle handle;
+
+ /**
+ The total size of this struct. This allows for this struct to be
+ expanded in the future if necessary. This MUST be set by the library to
+ sizeof(LV2_Lib_Descriptor). The host MUST NOT access any fields of this
+ struct beyond get_plugin() unless this field indicates they are present.
+ */
+ uint32_t size;
+
+ /**
+ Destroy this library descriptor and free all related resources.
+ */
+ void (*cleanup)(LV2_Lib_Handle handle);
+
+ /**
+ Plugin accessor.
+
+ Plugins are accessed by index using values from 0 upwards. Out of range
+ indices MUST result in this function returning NULL, so the host can
+ enumerate plugins by increasing `index` until NULL is returned.
+ */
+ const LV2_Descriptor* (*get_plugin)(LV2_Lib_Handle handle, uint32_t index);
} LV2_Lib_Descriptor;
/**
@@ -465,16 +462,15 @@ typedef struct {
from that library have been destroyed.
*/
LV2_SYMBOL_EXPORT
-const LV2_Lib_Descriptor *
-lv2_lib_descriptor(const char * bundle_path,
- const LV2_Feature *const * features);
+const LV2_Lib_Descriptor*
+lv2_lib_descriptor(const char* bundle_path, const LV2_Feature* const* features);
/**
Type of the lv2_lib_descriptor() function in an LV2 library.
*/
-typedef const LV2_Lib_Descriptor *
-(*LV2_Lib_Descriptor_Function)(const char * bundle_path,
- const LV2_Feature *const * features);
+typedef const LV2_Lib_Descriptor* (*LV2_Lib_Descriptor_Function)(
+ const char* bundle_path,
+ const LV2_Feature* const* features);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/lv2/core/lv2_util.h b/lv2/core/lv2_util.h
index 0269c70..0301c77 100644
--- a/lv2/core/lv2_util.h
+++ b/lv2/core/lv2_util.h
@@ -38,17 +38,16 @@ extern "C" {
present but have NULL data.
*/
static inline void*
-lv2_features_data(const LV2_Feature*const* features,
- const char* const uri)
+lv2_features_data(const LV2_Feature* const* features, const char* const uri)
{
- if (features) {
- for (const LV2_Feature*const* f = features; *f; ++f) {
- if (!strcmp(uri, (*f)->URI)) {
- return (*f)->data;
- }
- }
- }
- return NULL;
+ if (features) {
+ for (const LV2_Feature* const* f = features; *f; ++f) {
+ if (!strcmp(uri, (*f)->URI)) {
+ return (*f)->data;
+ }
+ }
+ }
+ return NULL;
}
/**
@@ -76,27 +75,27 @@ lv2_features_data(const LV2_Feature*const* features,
static inline const char*
lv2_features_query(const LV2_Feature* const* features, ...)
{
- va_list args;
- va_start(args, features);
-
- const char* uri = NULL;
- while ((uri = va_arg(args, const char*))) {
- void** data = va_arg(args, void**);
- bool required = va_arg(args, int);
-
- *data = lv2_features_data(features, uri);
- if (required && !*data) {
- va_end(args);
- return uri;
- }
- }
-
- va_end(args);
- return NULL;
+ va_list args;
+ va_start(args, features);
+
+ const char* uri = NULL;
+ while ((uri = va_arg(args, const char*))) {
+ void** data = va_arg(args, void**);
+ bool required = va_arg(args, int);
+
+ *data = lv2_features_data(features, uri);
+ if (required && !*data) {
+ va_end(args);
+ return uri;
+ }
+ }
+
+ va_end(args);
+ return NULL;
}
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
diff --git a/lv2/data-access/data-access.h b/lv2/data-access/data-access.h
index fb930ec..e5252cb 100644
--- a/lv2/data-access/data-access.h
+++ b/lv2/data-access/data-access.h
@@ -48,27 +48,27 @@ extern "C" {
and data pointed to an instance of this struct.
*/
typedef struct {
- /**
- A pointer to a method the UI can call to get data (of a type specified
- by some other extension) from the plugin.
-
- This call never is never guaranteed to return anything, UIs should
- degrade gracefully if direct access to the plugin data is not possible
- (in which case this function will return NULL).
-
- This is for access to large data that can only possibly work if the UI
- and plugin are running in the same process. For all other things, use
- the normal LV2 UI communication system.
- */
- const void* (*data_access)(const char* uri);
+ /**
+ A pointer to a method the UI can call to get data (of a type specified
+ by some other extension) from the plugin.
+
+ This call never is never guaranteed to return anything, UIs should
+ degrade gracefully if direct access to the plugin data is not possible
+ (in which case this function will return NULL).
+
+ This is for access to large data that can only possibly work if the UI
+ and plugin are running in the same process. For all other things, use
+ the normal LV2 UI communication system.
+ */
+ const void* (*data_access)(const char* uri);
} LV2_Extension_Data_Feature;
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
@}
*/
-#endif /* LV2_DATA_ACCESS_H */
+#endif /* LV2_DATA_ACCESS_H */
diff --git a/lv2/dynmanifest/dynmanifest.h b/lv2/dynmanifest/dynmanifest.h
index 36d7ebb..6181f71 100644
--- a/lv2/dynmanifest/dynmanifest.h
+++ b/lv2/dynmanifest/dynmanifest.h
@@ -52,7 +52,7 @@ extern "C" {
NOT even valid to compare this to NULL. The dynamic manifest generator MAY
use it to reference internal data.
*/
-typedef void * LV2_Dyn_Manifest_Handle;
+typedef void* LV2_Dyn_Manifest_Handle;
/**
Generate the dynamic manifest.
@@ -70,8 +70,9 @@ typedef void * LV2_Dyn_Manifest_Handle;
evaluate the result of the operation by examining the returned value and
MUST NOT try to interpret the value of handle.
*/
-int lv2_dyn_manifest_open(LV2_Dyn_Manifest_Handle * handle,
- const LV2_Feature *const * features);
+int
+lv2_dyn_manifest_open(LV2_Dyn_Manifest_Handle* handle,
+ const LV2_Feature* const* features);
/**
Fetch a "list" of subject URIs described in the dynamic manifest.
@@ -96,8 +97,8 @@ int lv2_dyn_manifest_open(LV2_Dyn_Manifest_Handle * handle,
@return 0 on success, otherwise a non-zero error code.
*/
-int lv2_dyn_manifest_get_subjects(LV2_Dyn_Manifest_Handle handle,
- FILE * fp);
+int
+lv2_dyn_manifest_get_subjects(LV2_Dyn_Manifest_Handle handle, FILE* fp);
/**
Function that fetches data related to a specific URI.
@@ -129,9 +130,10 @@ int lv2_dyn_manifest_get_subjects(LV2_Dyn_Manifest_Handle handle,
@return 0 on success, otherwise a non-zero error code.
*/
-int lv2_dyn_manifest_get_data(LV2_Dyn_Manifest_Handle handle,
- FILE * fp,
- const char * uri);
+int
+lv2_dyn_manifest_get_data(LV2_Dyn_Manifest_Handle handle,
+ FILE* fp,
+ const char* uri);
/**
Function that ends the operations on the dynamic manifest generator.
@@ -144,7 +146,8 @@ int lv2_dyn_manifest_get_data(LV2_Dyn_Manifest_Handle handle,
@param handle Dynamic manifest generator handle.
*/
-void lv2_dyn_manifest_close(LV2_Dyn_Manifest_Handle handle);
+void
+lv2_dyn_manifest_close(LV2_Dyn_Manifest_Handle handle);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/lv2/event/event-helpers.h b/lv2/event/event-helpers.h
index 6b39235..7e3f19c 100644
--- a/lv2/event/event-helpers.h
+++ b/lv2/event/event-helpers.h
@@ -47,96 +47,87 @@ LV2_DISABLE_DEPRECATION_WARNINGS
* Note that these functions are all static inline which basically means:
* do not take the address of these functions. */
-
/** Pad a size to 64 bits (for event sizes) */
static inline uint16_t
lv2_event_pad_size(uint16_t size)
{
- return (uint16_t)(size + 7U) & (uint16_t)(~7U);
+ return (uint16_t)(size + 7U) & (uint16_t)(~7U);
}
-
/** Initialize (empty, reset..) an existing event buffer.
* The contents of buf are ignored entirely and overwritten, except capacity
* which is unmodified. */
static inline void
-lv2_event_buffer_reset(LV2_Event_Buffer* buf,
- uint16_t stamp_type,
- uint8_t* data)
+lv2_event_buffer_reset(LV2_Event_Buffer* buf,
+ uint16_t stamp_type,
+ uint8_t* data)
{
- buf->data = data;
- buf->header_size = sizeof(LV2_Event_Buffer);
- buf->stamp_type = stamp_type;
- buf->event_count = 0;
- buf->size = 0;
+ buf->data = data;
+ buf->header_size = sizeof(LV2_Event_Buffer);
+ buf->stamp_type = stamp_type;
+ buf->event_count = 0;
+ buf->size = 0;
}
-
/** Allocate a new, empty event buffer. */
static inline LV2_Event_Buffer*
lv2_event_buffer_new(uint32_t capacity, uint16_t stamp_type)
{
- const size_t size = sizeof(LV2_Event_Buffer) + capacity;
- LV2_Event_Buffer* buf = (LV2_Event_Buffer*)malloc(size);
- if (buf != NULL) {
- buf->capacity = capacity;
- lv2_event_buffer_reset(buf, stamp_type, (uint8_t *)(buf + 1));
- return buf;
- }
- return NULL;
+ const size_t size = sizeof(LV2_Event_Buffer) + capacity;
+ LV2_Event_Buffer* buf = (LV2_Event_Buffer*)malloc(size);
+ if (buf != NULL) {
+ buf->capacity = capacity;
+ lv2_event_buffer_reset(buf, stamp_type, (uint8_t*)(buf + 1));
+ return buf;
+ }
+ return NULL;
}
-
/** An iterator over an LV2_Event_Buffer.
*
* Multiple simultaneous read iterators over a single buffer is fine,
* but changing the buffer invalidates all iterators. */
typedef struct {
- LV2_Event_Buffer* buf;
- uint32_t offset;
+ LV2_Event_Buffer* buf;
+ uint32_t offset;
} LV2_Event_Iterator;
-
/** Reset an iterator to point to the start of `buf`.
* @return True if `iter` is valid, otherwise false (buffer is empty) */
static inline bool
-lv2_event_begin(LV2_Event_Iterator* iter,
- LV2_Event_Buffer* buf)
+lv2_event_begin(LV2_Event_Iterator* iter, LV2_Event_Buffer* buf)
{
- iter->buf = buf;
- iter->offset = 0;
- return (buf->size > 0);
+ iter->buf = buf;
+ iter->offset = 0;
+ return (buf->size > 0);
}
-
/** Check if `iter` is valid.
* @return True if `iter` is valid, otherwise false (past end of buffer) */
static inline bool
lv2_event_is_valid(LV2_Event_Iterator* iter)
{
- return (iter->buf && (iter->offset < iter->buf->size));
+ return (iter->buf && (iter->offset < iter->buf->size));
}
-
/** Advance `iter` forward one event.
* `iter` must be valid.
* @return True if `iter` is valid, otherwise false (reached end of buffer) */
static inline bool
lv2_event_increment(LV2_Event_Iterator* iter)
{
- if (!lv2_event_is_valid(iter)) {
- return false;
- }
+ if (!lv2_event_is_valid(iter)) {
+ return false;
+ }
- LV2_Event* const ev = (LV2_Event*)(iter->buf->data + iter->offset);
+ LV2_Event* const ev = (LV2_Event*)(iter->buf->data + iter->offset);
- iter->offset += lv2_event_pad_size(
- (uint16_t)((uint16_t)sizeof(LV2_Event) + ev->size));
+ iter->offset +=
+ lv2_event_pad_size((uint16_t)((uint16_t)sizeof(LV2_Event) + ev->size));
- return true;
+ return true;
}
-
/** Dereference an event iterator (get the event currently pointed at).
* `iter` must be valid.
* `data` if non-NULL, will be set to point to the contents of the event
@@ -145,23 +136,21 @@ lv2_event_increment(LV2_Event_Iterator* iter)
* if the end of the buffer is reached (in which case `data` is
* also set to NULL). */
static inline LV2_Event*
-lv2_event_get(LV2_Event_Iterator* iter,
- uint8_t** data)
+lv2_event_get(LV2_Event_Iterator* iter, uint8_t** data)
{
- if (!lv2_event_is_valid(iter)) {
- return NULL;
- }
+ if (!lv2_event_is_valid(iter)) {
+ return NULL;
+ }
- LV2_Event* const ev = (LV2_Event*)(iter->buf->data + iter->offset);
+ LV2_Event* const ev = (LV2_Event*)(iter->buf->data + iter->offset);
- if (data) {
- *data = (uint8_t*)ev + sizeof(LV2_Event);
- }
+ if (data) {
+ *data = (uint8_t*)ev + sizeof(LV2_Event);
+ }
- return ev;
+ return ev;
}
-
/** Write an event at `iter`.
* The event (if any) pointed to by `iter` will be overwritten, and `iter`
* incremented to point to the following event (i.e. several calls to this
@@ -175,62 +164,60 @@ lv2_event_write(LV2_Event_Iterator* iter,
uint16_t size,
const uint8_t* data)
{
- if (!iter->buf) {
- return false;
- }
+ if (!iter->buf) {
+ return false;
+ }
- if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + size) {
- return false;
- }
+ if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + size) {
+ return false;
+ }
- LV2_Event* const ev = (LV2_Event*)(iter->buf->data + iter->offset);
+ LV2_Event* const ev = (LV2_Event*)(iter->buf->data + iter->offset);
- ev->frames = frames;
- ev->subframes = subframes;
- ev->type = type;
- ev->size = size;
- memcpy((uint8_t*)ev + sizeof(LV2_Event), data, size);
- ++iter->buf->event_count;
+ ev->frames = frames;
+ ev->subframes = subframes;
+ ev->type = type;
+ ev->size = size;
+ memcpy((uint8_t*)ev + sizeof(LV2_Event), data, size);
+ ++iter->buf->event_count;
- size = lv2_event_pad_size((uint16_t)(sizeof(LV2_Event) + size));
- iter->buf->size += size;
- iter->offset += size;
+ size = lv2_event_pad_size((uint16_t)(sizeof(LV2_Event) + size));
+ iter->buf->size += size;
+ iter->offset += size;
- return true;
+ return true;
}
-
/** Reserve space for an event in the buffer and return a pointer to
the memory where the caller can write the event data, or NULL if there
is not enough room in the buffer. */
static inline uint8_t*
lv2_event_reserve(LV2_Event_Iterator* iter,
- uint32_t frames,
- uint32_t subframes,
- uint16_t type,
- uint16_t size)
+ uint32_t frames,
+ uint32_t subframes,
+ uint16_t type,
+ uint16_t size)
{
- const uint16_t total_size = (uint16_t)(sizeof(LV2_Event) + size);
- if (iter->buf->capacity - iter->buf->size < total_size) {
- return NULL;
- }
+ const uint16_t total_size = (uint16_t)(sizeof(LV2_Event) + size);
+ if (iter->buf->capacity - iter->buf->size < total_size) {
+ return NULL;
+ }
- LV2_Event* const ev = (LV2_Event*)(iter->buf->data + iter->offset);
+ LV2_Event* const ev = (LV2_Event*)(iter->buf->data + iter->offset);
- ev->frames = frames;
- ev->subframes = subframes;
- ev->type = type;
- ev->size = size;
- ++iter->buf->event_count;
+ ev->frames = frames;
+ ev->subframes = subframes;
+ ev->type = type;
+ ev->size = size;
+ ++iter->buf->event_count;
- const uint16_t padded_size = lv2_event_pad_size(total_size);
- iter->buf->size += padded_size;
- iter->offset += padded_size;
+ const uint16_t padded_size = lv2_event_pad_size(total_size);
+ iter->buf->size += padded_size;
+ iter->offset += padded_size;
- return (uint8_t*)ev + sizeof(LV2_Event);
+ return (uint8_t*)ev + sizeof(LV2_Event);
}
-
/** Write an event at `iter`.
* The event (if any) pointed to by `iter` will be overwritten, and `iter`
* incremented to point to the following event (i.e. several calls to this
@@ -241,28 +228,28 @@ lv2_event_write_event(LV2_Event_Iterator* iter,
const LV2_Event* ev,
const uint8_t* data)
{
- const uint16_t total_size = (uint16_t)(sizeof(LV2_Event) + ev->size);
- if (iter->buf->capacity - iter->buf->size < total_size) {
- return false;
- }
+ const uint16_t total_size = (uint16_t)(sizeof(LV2_Event) + ev->size);
+ if (iter->buf->capacity - iter->buf->size < total_size) {
+ return false;
+ }
- LV2_Event* const write_ev = (LV2_Event*)(iter->buf->data + iter->offset);
+ LV2_Event* const write_ev = (LV2_Event*)(iter->buf->data + iter->offset);
- *write_ev = *ev;
- memcpy((uint8_t*)write_ev + sizeof(LV2_Event), data, ev->size);
- ++iter->buf->event_count;
+ *write_ev = *ev;
+ memcpy((uint8_t*)write_ev + sizeof(LV2_Event), data, ev->size);
+ ++iter->buf->event_count;
- const uint16_t padded_size = lv2_event_pad_size(total_size);
- iter->buf->size += padded_size;
- iter->offset += padded_size;
+ const uint16_t padded_size = lv2_event_pad_size(total_size);
+ iter->buf->size += padded_size;
+ iter->offset += padded_size;
- return true;
+ return true;
}
LV2_RESTORE_WARNINGS
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
#endif /* LV2_EVENT_HELPERS_H */
diff --git a/lv2/event/event.h b/lv2/event/event.h
index ff91e3b..a0afd6c 100644
--- a/lv2/event/event.h
+++ b/lv2/event/event.h
@@ -47,7 +47,7 @@
// clang-format on
-#define LV2_EVENT_AUDIO_STAMP 0 ///< Special timestamp type for audio frames
+#define LV2_EVENT_AUDIO_STAMP 0 ///< Special timestamp type for audio frames
#include "lv2/core/attributes.h"
@@ -82,49 +82,48 @@ static const uint32_t LV2_EVENT_PPQN = 3136573440U;
*/
LV2_DEPRECATED
typedef struct {
- /**
- The frames portion of timestamp. The units used here can optionally be
- set for a port (with the lv2ev:timeUnits property), otherwise this is
- audio frames, corresponding to the sample_count parameter of the LV2 run
- method (frame 0 is the first frame for that call to run).
- */
- uint32_t frames;
-
- /**
- The sub-frames portion of timestamp. The units used here can optionally
- be set for a port (with the lv2ev:timeUnits property), otherwise this is
- 1/(2^32) of an audio frame.
- */
- uint32_t subframes;
-
- /**
- The type of this event, as a number which represents some URI
- defining an event type. This value MUST be some value previously
- returned from a call to the uri_to_id function defined in the LV2
- URI map extension (see lv2_uri_map.h).
- There are special rules which must be followed depending on the type
- of an event. If the plugin recognizes an event type, the definition
- of that event type will describe how to interpret the event, and
- any required behaviour. Otherwise, if the type is 0, this event is a
- non-POD event and lv2_event_unref MUST be called if the event is
- 'dropped' (see above). Even if the plugin does not understand an event,
- it may pass the event through to an output by simply copying (and NOT
- calling lv2_event_unref). These rules are designed to allow for generic
- event handling plugins and large non-POD events, but with minimal hassle
- on simple plugins that "don't care" about these more advanced features.
- */
- uint16_t type;
-
- /**
- The size of the data portion of this event in bytes, which immediately
- follows. The header size (12 bytes) is not included in this value.
- */
- uint16_t size;
-
- /* size bytes of data follow here */
+ /**
+ The frames portion of timestamp. The units used here can optionally be
+ set for a port (with the lv2ev:timeUnits property), otherwise this is
+ audio frames, corresponding to the sample_count parameter of the LV2 run
+ method (frame 0 is the first frame for that call to run).
+ */
+ uint32_t frames;
+
+ /**
+ The sub-frames portion of timestamp. The units used here can optionally
+ be set for a port (with the lv2ev:timeUnits property), otherwise this is
+ 1/(2^32) of an audio frame.
+ */
+ uint32_t subframes;
+
+ /**
+ The type of this event, as a number which represents some URI
+ defining an event type. This value MUST be some value previously
+ returned from a call to the uri_to_id function defined in the LV2
+ URI map extension (see lv2_uri_map.h).
+ There are special rules which must be followed depending on the type
+ of an event. If the plugin recognizes an event type, the definition
+ of that event type will describe how to interpret the event, and
+ any required behaviour. Otherwise, if the type is 0, this event is a
+ non-POD event and lv2_event_unref MUST be called if the event is
+ 'dropped' (see above). Even if the plugin does not understand an event,
+ it may pass the event through to an output by simply copying (and NOT
+ calling lv2_event_unref). These rules are designed to allow for generic
+ event handling plugins and large non-POD events, but with minimal hassle
+ on simple plugins that "don't care" about these more advanced features.
+ */
+ uint16_t type;
+
+ /**
+ The size of the data portion of this event in bytes, which immediately
+ follows. The header size (12 bytes) is not included in this value.
+ */
+ uint16_t size;
+
+ /* size bytes of data follow here */
} LV2_Event;
-
/**
A buffer of LV2 events (header only).
@@ -143,92 +142,90 @@ typedef struct {
*/
LV2_DEPRECATED
typedef struct {
- /**
- The contents of the event buffer. This may or may not reside in the
- same block of memory as this header, plugins must not assume either.
- The host guarantees this points to at least capacity bytes of allocated
- memory (though only size bytes of that are valid events).
- */
- uint8_t* data;
-
- /**
- The size of this event header in bytes (including everything).
-
- This is to allow for extending this header in the future without
- breaking binary compatibility. Whenever this header is copied,
- it MUST be done using this field (and NOT the sizeof this struct).
- */
- uint16_t header_size;
-
- /**
- The type of the time stamps for events in this buffer.
- As a special exception, '0' always means audio frames and subframes
- (1/UINT32_MAX'th of a frame) in the sample rate passed to instantiate.
-
- INPUTS: The host must set this field to the numeric ID of some URI
- defining the meaning of the frames/subframes fields of contained events
- (obtained by the LV2 URI Map uri_to_id function with the URI of this
- extension as the 'map' argument, see lv2_uri_map.h). The host must
- never pass a plugin a buffer which uses a stamp type the plugin does not
- 'understand'. The value of this field must never change, except when
- connect_port is called on the input port, at which time the host MUST
- have set the stamp_type field to the value that will be used for all
- subsequent run calls.
-
- OUTPUTS: The plugin may set this to any value that has been returned
- from uri_to_id with the URI of this extension for a 'map' argument.
- When connected to a buffer with connect_port, output ports MUST set this
- field to the type of time stamp they will be writing. On any call to
- connect_port on an event input port, the plugin may change this field on
- any output port, it is the responsibility of the host to check if any of
- these values have changed and act accordingly.
- */
- uint16_t stamp_type;
-
- /**
- The number of events in this buffer.
-
- INPUTS: The host must set this field to the number of events contained
- in the data buffer before calling run(). The plugin must not change
- this field.
-
- OUTPUTS: The plugin must set this field to the number of events it has
- written to the buffer before returning from run(). Any initial value
- should be ignored by the plugin.
- */
- uint32_t event_count;
-
- /**
- The size of the data buffer in bytes.
- This is set by the host and must not be changed by the plugin.
- The host is allowed to change this between run() calls.
- */
- uint32_t capacity;
-
- /**
- The size of the initial portion of the data buffer containing data.
-
- INPUTS: The host must set this field to the number of bytes used
- by all events it has written to the buffer (including headers)
- before calling the plugin's run().
- The plugin must not change this field.
-
- OUTPUTS: The plugin must set this field to the number of bytes
- used by all events it has written to the buffer (including headers)
- before returning from run().
- Any initial value should be ignored by the plugin.
- */
- uint32_t size;
+ /**
+ The contents of the event buffer. This may or may not reside in the
+ same block of memory as this header, plugins must not assume either.
+ The host guarantees this points to at least capacity bytes of allocated
+ memory (though only size bytes of that are valid events).
+ */
+ uint8_t* data;
+
+ /**
+ The size of this event header in bytes (including everything).
+
+ This is to allow for extending this header in the future without
+ breaking binary compatibility. Whenever this header is copied,
+ it MUST be done using this field (and NOT the sizeof this struct).
+ */
+ uint16_t header_size;
+
+ /**
+ The type of the time stamps for events in this buffer.
+ As a special exception, '0' always means audio frames and subframes
+ (1/UINT32_MAX'th of a frame) in the sample rate passed to instantiate.
+
+ INPUTS: The host must set this field to the numeric ID of some URI
+ defining the meaning of the frames/subframes fields of contained events
+ (obtained by the LV2 URI Map uri_to_id function with the URI of this
+ extension as the 'map' argument, see lv2_uri_map.h). The host must
+ never pass a plugin a buffer which uses a stamp type the plugin does not
+ 'understand'. The value of this field must never change, except when
+ connect_port is called on the input port, at which time the host MUST
+ have set the stamp_type field to the value that will be used for all
+ subsequent run calls.
+
+ OUTPUTS: The plugin may set this to any value that has been returned
+ from uri_to_id with the URI of this extension for a 'map' argument.
+ When connected to a buffer with connect_port, output ports MUST set this
+ field to the type of time stamp they will be writing. On any call to
+ connect_port on an event input port, the plugin may change this field on
+ any output port, it is the responsibility of the host to check if any of
+ these values have changed and act accordingly.
+ */
+ uint16_t stamp_type;
+
+ /**
+ The number of events in this buffer.
+
+ INPUTS: The host must set this field to the number of events contained
+ in the data buffer before calling run(). The plugin must not change
+ this field.
+
+ OUTPUTS: The plugin must set this field to the number of events it has
+ written to the buffer before returning from run(). Any initial value
+ should be ignored by the plugin.
+ */
+ uint32_t event_count;
+
+ /**
+ The size of the data buffer in bytes.
+ This is set by the host and must not be changed by the plugin.
+ The host is allowed to change this between run() calls.
+ */
+ uint32_t capacity;
+
+ /**
+ The size of the initial portion of the data buffer containing data.
+
+ INPUTS: The host must set this field to the number of bytes used
+ by all events it has written to the buffer (including headers)
+ before calling the plugin's run().
+ The plugin must not change this field.
+
+ OUTPUTS: The plugin must set this field to the number of bytes
+ used by all events it has written to the buffer (including headers)
+ before returning from run().
+ Any initial value should be ignored by the plugin.
+ */
+ uint32_t size;
} LV2_Event_Buffer;
-
/**
Opaque pointer to host data.
*/
LV2_DEPRECATED
typedef void* LV2_Event_Callback_Data;
-
/**
Non-POD events feature.
@@ -239,67 +236,67 @@ typedef void* LV2_Event_Callback_Data;
*/
LV2_DEPRECATED
typedef struct {
- /**
- Opaque pointer to host data.
-
- The plugin MUST pass this to any call to functions in this struct.
- Otherwise, it must not be interpreted in any way.
- */
- LV2_Event_Callback_Data callback_data;
-
- /**
- Take a reference to a non-POD event.
-
- If a plugin receives an event with type 0, it means the event is a
- pointer to some object in memory and not a flat sequence of bytes
- in the buffer. When receiving a non-POD event, the plugin already
- has an implicit reference to the event. If the event is stored AND
- passed to an output, lv2_event_ref MUST be called on that event.
- If the event is only stored OR passed through, this is not necessary
- (as the plugin already has 1 implicit reference).
-
- @param event An event received at an input that will not be copied to
- an output or stored in any way.
-
- @param context The calling context. Like event types, this is a mapped
- URI, see lv2_context.h. Simple plugin with just a run() method should
- pass 0 here (the ID of the 'standard' LV2 run context). The host
- guarantees that this function is realtime safe iff the context is
- realtime safe.
-
- PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS.
- */
- uint32_t (*lv2_event_ref)(LV2_Event_Callback_Data callback_data,
- LV2_Event* event);
-
- /**
- Drop a reference to a non-POD event.
-
- If a plugin receives an event with type 0, it means the event is a
- pointer to some object in memory and not a flat sequence of bytes
- in the buffer. If the plugin does not pass the event through to
- an output or store it internally somehow, it MUST call this function
- on the event (more information on using non-POD events below).
-
- @param event An event received at an input that will not be copied to an
- output or stored in any way.
-
- @param context The calling context. Like event types, this is a mapped
- URI, see lv2_context.h. Simple plugin with just a run() method should
- pass 0 here (the ID of the 'standard' LV2 run context). The host
- guarantees that this function is realtime safe iff the context is
- realtime safe.
-
- PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS.
- */
- uint32_t (*lv2_event_unref)(LV2_Event_Callback_Data callback_data,
- LV2_Event* event);
+ /**
+ Opaque pointer to host data.
+
+ The plugin MUST pass this to any call to functions in this struct.
+ Otherwise, it must not be interpreted in any way.
+ */
+ LV2_Event_Callback_Data callback_data;
+
+ /**
+ Take a reference to a non-POD event.
+
+ If a plugin receives an event with type 0, it means the event is a
+ pointer to some object in memory and not a flat sequence of bytes
+ in the buffer. When receiving a non-POD event, the plugin already
+ has an implicit reference to the event. If the event is stored AND
+ passed to an output, lv2_event_ref MUST be called on that event.
+ If the event is only stored OR passed through, this is not necessary
+ (as the plugin already has 1 implicit reference).
+
+ @param event An event received at an input that will not be copied to
+ an output or stored in any way.
+
+ @param context The calling context. Like event types, this is a mapped
+ URI, see lv2_context.h. Simple plugin with just a run() method should
+ pass 0 here (the ID of the 'standard' LV2 run context). The host
+ guarantees that this function is realtime safe iff the context is
+ realtime safe.
+
+ PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS.
+ */
+ uint32_t (*lv2_event_ref)(LV2_Event_Callback_Data callback_data,
+ LV2_Event* event);
+
+ /**
+ Drop a reference to a non-POD event.
+
+ If a plugin receives an event with type 0, it means the event is a
+ pointer to some object in memory and not a flat sequence of bytes
+ in the buffer. If the plugin does not pass the event through to
+ an output or store it internally somehow, it MUST call this function
+ on the event (more information on using non-POD events below).
+
+ @param event An event received at an input that will not be copied to an
+ output or stored in any way.
+
+ @param context The calling context. Like event types, this is a mapped
+ URI, see lv2_context.h. Simple plugin with just a run() method should
+ pass 0 here (the ID of the 'standard' LV2 run context). The host
+ guarantees that this function is realtime safe iff the context is
+ realtime safe.
+
+ PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS.
+ */
+ uint32_t (*lv2_event_unref)(LV2_Event_Callback_Data callback_data,
+ LV2_Event* event);
} LV2_Event_Feature;
LV2_RESTORE_WARNINGS
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
diff --git a/lv2/instance-access/instance-access.h b/lv2/instance-access/instance-access.h
index 4070fc0..99e6e80 100644
--- a/lv2/instance-access/instance-access.h
+++ b/lv2/instance-access/instance-access.h
@@ -39,4 +39,4 @@
@}
*/
-#endif /* LV2_INSTANCE_ACCESS_H */
+#endif /* LV2_INSTANCE_ACCESS_H */
diff --git a/lv2/log/log.h b/lv2/log/log.h
index cf938ca..92422bd 100644
--- a/lv2/log/log.h
+++ b/lv2/log/log.h
@@ -53,9 +53,9 @@ extern "C" {
/** @cond */
#ifdef __GNUC__
/** Allow type checking of printf-like functions. */
-# define LV2_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1)))
+# define LV2_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1)))
#else
-# define LV2_LOG_FUNC(fmt, arg1)
+# define LV2_LOG_FUNC(fmt, arg1)
#endif
/** @endcond */
@@ -68,48 +68,46 @@ typedef void* LV2_Log_Handle;
Log feature (LV2_LOG__log)
*/
typedef struct {
- /**
- Opaque pointer to host data.
-
- This MUST be passed to methods in this struct whenever they are called.
- Otherwise, it must not be interpreted in any way.
- */
- LV2_Log_Handle handle;
-
- /**
- Log a message, passing format parameters directly.
-
- The API of this function matches that of the standard C printf function,
- except for the addition of the first two parameters. This function may
- be called from any non-realtime context, or from any context if `type`
- is @ref LV2_LOG__Trace.
- */
- LV2_LOG_FUNC(3, 4)
- int (*printf)(LV2_Log_Handle handle,
- LV2_URID type,
- const char* fmt, ...);
-
- /**
- Log a message, passing format parameters in a va_list.
-
- The API of this function matches that of the standard C vprintf
- function, except for the addition of the first two parameters. This
- function may be called from any non-realtime context, or from any
- context if `type` is @ref LV2_LOG__Trace.
- */
- LV2_LOG_FUNC(3, 0)
- int (*vprintf)(LV2_Log_Handle handle,
- LV2_URID type,
- const char* fmt,
- va_list ap);
+ /**
+ Opaque pointer to host data.
+
+ This MUST be passed to methods in this struct whenever they are called.
+ Otherwise, it must not be interpreted in any way.
+ */
+ LV2_Log_Handle handle;
+
+ /**
+ Log a message, passing format parameters directly.
+
+ The API of this function matches that of the standard C printf function,
+ except for the addition of the first two parameters. This function may
+ be called from any non-realtime context, or from any context if `type`
+ is @ref LV2_LOG__Trace.
+ */
+ LV2_LOG_FUNC(3, 4)
+ int (*printf)(LV2_Log_Handle handle, LV2_URID type, const char* fmt, ...);
+
+ /**
+ Log a message, passing format parameters in a va_list.
+
+ The API of this function matches that of the standard C vprintf
+ function, except for the addition of the first two parameters. This
+ function may be called from any non-realtime context, or from any
+ context if `type` is @ref LV2_LOG__Trace.
+ */
+ LV2_LOG_FUNC(3, 0)
+ int (*vprintf)(LV2_Log_Handle handle,
+ LV2_URID type,
+ const char* fmt,
+ va_list ap);
} LV2_Log_Log;
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
@}
*/
-#endif /* LV2_LOG_H */
+#endif /* LV2_LOG_H */
diff --git a/lv2/log/logger.h b/lv2/log/logger.h
index 669069c..80459a7 100644
--- a/lv2/log/logger.h
+++ b/lv2/log/logger.h
@@ -42,12 +42,12 @@ extern "C" {
Logger convenience API state.
*/
typedef struct {
- LV2_Log_Log* log;
+ LV2_Log_Log* log;
- LV2_URID Error;
- LV2_URID Note;
- LV2_URID Trace;
- LV2_URID Warning;
+ LV2_URID Error;
+ LV2_URID Note;
+ LV2_URID Trace;
+ LV2_URID Warning;
} LV2_Log_Logger;
/**
@@ -59,14 +59,14 @@ typedef struct {
static inline void
lv2_log_logger_set_map(LV2_Log_Logger* logger, LV2_URID_Map* map)
{
- if (map) {
- logger->Error = map->map(map->handle, LV2_LOG__Error);
- logger->Note = map->map(map->handle, LV2_LOG__Note);
- logger->Trace = map->map(map->handle, LV2_LOG__Trace);
- logger->Warning = map->map(map->handle, LV2_LOG__Warning);
- } else {
- logger->Error = logger->Note = logger->Trace = logger->Warning = 0;
- }
+ if (map) {
+ logger->Error = map->map(map->handle, LV2_LOG__Error);
+ logger->Note = map->map(map->handle, LV2_LOG__Note);
+ logger->Trace = map->map(map->handle, LV2_LOG__Trace);
+ logger->Warning = map->map(map->handle, LV2_LOG__Warning);
+ } else {
+ logger->Error = logger->Note = logger->Trace = logger->Warning = 0;
+ }
}
/**
@@ -77,12 +77,10 @@ lv2_log_logger_set_map(LV2_Log_Logger* logger, LV2_URID_Map* map)
in which case the implementation will fall back to printing to stderr.
*/
static inline void
-lv2_log_logger_init(LV2_Log_Logger* logger,
- LV2_URID_Map* map,
- LV2_Log_Log* log)
+lv2_log_logger_init(LV2_Log_Logger* logger, LV2_URID_Map* map, LV2_Log_Log* log)
{
- logger->log = log;
- lv2_log_logger_set_map(logger, map);
+ logger->log = log;
+ lv2_log_logger_set_map(logger, map);
}
/**
@@ -95,9 +93,9 @@ lv2_log_vprintf(LV2_Log_Logger* logger,
const char* fmt,
va_list args)
{
- return ((logger && logger->log)
- ? logger->log->vprintf(logger->log->handle, type, fmt, args)
- : vfprintf(stderr, fmt, args));
+ return ((logger && logger->log)
+ ? logger->log->vprintf(logger->log->handle, type, fmt, args)
+ : vfprintf(stderr, fmt, args));
}
/** Log an error via lv2_log_vprintf(). */
@@ -105,11 +103,11 @@ LV2_LOG_FUNC(2, 3)
static inline int
lv2_log_error(LV2_Log_Logger* logger, const char* fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- const int ret = lv2_log_vprintf(logger, logger->Error, fmt, args);
- va_end(args);
- return ret;
+ va_list args;
+ va_start(args, fmt);
+ const int ret = lv2_log_vprintf(logger, logger->Error, fmt, args);
+ va_end(args);
+ return ret;
}
/** Log a note via lv2_log_vprintf(). */
@@ -117,11 +115,11 @@ LV2_LOG_FUNC(2, 3)
static inline int
lv2_log_note(LV2_Log_Logger* logger, const char* fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- const int ret = lv2_log_vprintf(logger, logger->Note, fmt, args);
- va_end(args);
- return ret;
+ va_list args;
+ va_start(args, fmt);
+ const int ret = lv2_log_vprintf(logger, logger->Note, fmt, args);
+ va_end(args);
+ return ret;
}
/** Log a trace via lv2_log_vprintf(). */
@@ -129,11 +127,11 @@ LV2_LOG_FUNC(2, 3)
static inline int
lv2_log_trace(LV2_Log_Logger* logger, const char* fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- const int ret = lv2_log_vprintf(logger, logger->Trace, fmt, args);
- va_end(args);
- return ret;
+ va_list args;
+ va_start(args, fmt);
+ const int ret = lv2_log_vprintf(logger, logger->Trace, fmt, args);
+ va_end(args);
+ return ret;
}
/** Log a warning via lv2_log_vprintf(). */
@@ -141,19 +139,19 @@ LV2_LOG_FUNC(2, 3)
static inline int
lv2_log_warning(LV2_Log_Logger* logger, const char* fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- const int ret = lv2_log_vprintf(logger, logger->Warning, fmt, args);
- va_end(args);
- return ret;
+ va_list args;
+ va_start(args, fmt);
+ const int ret = lv2_log_vprintf(logger, logger->Warning, fmt, args);
+ va_end(args);
+ return ret;
}
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
@}
*/
-#endif /* LV2_LOG_LOGGER_H */
+#endif /* LV2_LOG_LOGGER_H */
diff --git a/lv2/midi/midi.h b/lv2/midi/midi.h
index 6f70377..52f8131 100644
--- a/lv2/midi/midi.h
+++ b/lv2/midi/midi.h
@@ -93,124 +93,130 @@ extern "C" {
lv2_midi_get_type() on the status byte.
*/
typedef enum {
- LV2_MIDI_MSG_INVALID = 0, /**< Invalid Message */
- LV2_MIDI_MSG_NOTE_OFF = 0x80, /**< Note Off */
- LV2_MIDI_MSG_NOTE_ON = 0x90, /**< Note On */
- LV2_MIDI_MSG_NOTE_PRESSURE = 0xA0, /**< Note Pressure */
- LV2_MIDI_MSG_CONTROLLER = 0xB0, /**< Controller */
- LV2_MIDI_MSG_PGM_CHANGE = 0xC0, /**< Program Change */
- LV2_MIDI_MSG_CHANNEL_PRESSURE = 0xD0, /**< Channel Pressure */
- LV2_MIDI_MSG_BENDER = 0xE0, /**< Pitch Bender */
- LV2_MIDI_MSG_SYSTEM_EXCLUSIVE = 0xF0, /**< System Exclusive Begin */
- LV2_MIDI_MSG_MTC_QUARTER = 0xF1, /**< MTC Quarter Frame */
- LV2_MIDI_MSG_SONG_POS = 0xF2, /**< Song Position */
- LV2_MIDI_MSG_SONG_SELECT = 0xF3, /**< Song Select */
- LV2_MIDI_MSG_TUNE_REQUEST = 0xF6, /**< Tune Request */
- LV2_MIDI_MSG_CLOCK = 0xF8, /**< Clock */
- LV2_MIDI_MSG_START = 0xFA, /**< Start */
- LV2_MIDI_MSG_CONTINUE = 0xFB, /**< Continue */
- LV2_MIDI_MSG_STOP = 0xFC, /**< Stop */
- LV2_MIDI_MSG_ACTIVE_SENSE = 0xFE, /**< Active Sensing */
- LV2_MIDI_MSG_RESET = 0xFF /**< Reset */
+ LV2_MIDI_MSG_INVALID = 0, /**< Invalid Message */
+ LV2_MIDI_MSG_NOTE_OFF = 0x80, /**< Note Off */
+ LV2_MIDI_MSG_NOTE_ON = 0x90, /**< Note On */
+ LV2_MIDI_MSG_NOTE_PRESSURE = 0xA0, /**< Note Pressure */
+ LV2_MIDI_MSG_CONTROLLER = 0xB0, /**< Controller */
+ LV2_MIDI_MSG_PGM_CHANGE = 0xC0, /**< Program Change */
+ LV2_MIDI_MSG_CHANNEL_PRESSURE = 0xD0, /**< Channel Pressure */
+ LV2_MIDI_MSG_BENDER = 0xE0, /**< Pitch Bender */
+ LV2_MIDI_MSG_SYSTEM_EXCLUSIVE = 0xF0, /**< System Exclusive Begin */
+ LV2_MIDI_MSG_MTC_QUARTER = 0xF1, /**< MTC Quarter Frame */
+ LV2_MIDI_MSG_SONG_POS = 0xF2, /**< Song Position */
+ LV2_MIDI_MSG_SONG_SELECT = 0xF3, /**< Song Select */
+ LV2_MIDI_MSG_TUNE_REQUEST = 0xF6, /**< Tune Request */
+ LV2_MIDI_MSG_CLOCK = 0xF8, /**< Clock */
+ LV2_MIDI_MSG_START = 0xFA, /**< Start */
+ LV2_MIDI_MSG_CONTINUE = 0xFB, /**< Continue */
+ LV2_MIDI_MSG_STOP = 0xFC, /**< Stop */
+ LV2_MIDI_MSG_ACTIVE_SENSE = 0xFE, /**< Active Sensing */
+ LV2_MIDI_MSG_RESET = 0xFF /**< Reset */
} LV2_Midi_Message_Type;
/**
Standard MIDI Controller Numbers.
*/
typedef enum {
- LV2_MIDI_CTL_MSB_BANK = 0x00, /**< Bank Selection */
- LV2_MIDI_CTL_MSB_MODWHEEL = 0x01, /**< Modulation */
- LV2_MIDI_CTL_MSB_BREATH = 0x02, /**< Breath */
- LV2_MIDI_CTL_MSB_FOOT = 0x04, /**< Foot */
- LV2_MIDI_CTL_MSB_PORTAMENTO_TIME = 0x05, /**< Portamento Time */
- LV2_MIDI_CTL_MSB_DATA_ENTRY = 0x06, /**< Data Entry */
- LV2_MIDI_CTL_MSB_MAIN_VOLUME = 0x07, /**< Main Volume */
- LV2_MIDI_CTL_MSB_BALANCE = 0x08, /**< Balance */
- LV2_MIDI_CTL_MSB_PAN = 0x0A, /**< Panpot */
- LV2_MIDI_CTL_MSB_EXPRESSION = 0x0B, /**< Expression */
- LV2_MIDI_CTL_MSB_EFFECT1 = 0x0C, /**< Effect1 */
- LV2_MIDI_CTL_MSB_EFFECT2 = 0x0D, /**< Effect2 */
- LV2_MIDI_CTL_MSB_GENERAL_PURPOSE1 = 0x10, /**< General Purpose 1 */
- LV2_MIDI_CTL_MSB_GENERAL_PURPOSE2 = 0x11, /**< General Purpose 2 */
- LV2_MIDI_CTL_MSB_GENERAL_PURPOSE3 = 0x12, /**< General Purpose 3 */
- LV2_MIDI_CTL_MSB_GENERAL_PURPOSE4 = 0x13, /**< General Purpose 4 */
- LV2_MIDI_CTL_LSB_BANK = 0x20, /**< Bank Selection */
- LV2_MIDI_CTL_LSB_MODWHEEL = 0x21, /**< Modulation */
- LV2_MIDI_CTL_LSB_BREATH = 0x22, /**< Breath */
- LV2_MIDI_CTL_LSB_FOOT = 0x24, /**< Foot */
- LV2_MIDI_CTL_LSB_PORTAMENTO_TIME = 0x25, /**< Portamento Time */
- LV2_MIDI_CTL_LSB_DATA_ENTRY = 0x26, /**< Data Entry */
- LV2_MIDI_CTL_LSB_MAIN_VOLUME = 0x27, /**< Main Volume */
- LV2_MIDI_CTL_LSB_BALANCE = 0x28, /**< Balance */
- LV2_MIDI_CTL_LSB_PAN = 0x2A, /**< Panpot */
- LV2_MIDI_CTL_LSB_EXPRESSION = 0x2B, /**< Expression */
- LV2_MIDI_CTL_LSB_EFFECT1 = 0x2C, /**< Effect1 */
- LV2_MIDI_CTL_LSB_EFFECT2 = 0x2D, /**< Effect2 */
- LV2_MIDI_CTL_LSB_GENERAL_PURPOSE1 = 0x30, /**< General Purpose 1 */
- LV2_MIDI_CTL_LSB_GENERAL_PURPOSE2 = 0x31, /**< General Purpose 2 */
- LV2_MIDI_CTL_LSB_GENERAL_PURPOSE3 = 0x32, /**< General Purpose 3 */
- LV2_MIDI_CTL_LSB_GENERAL_PURPOSE4 = 0x33, /**< General Purpose 4 */
- LV2_MIDI_CTL_SUSTAIN = 0x40, /**< Sustain Pedal */
- LV2_MIDI_CTL_PORTAMENTO = 0x41, /**< Portamento */
- LV2_MIDI_CTL_SOSTENUTO = 0x42, /**< Sostenuto */
- LV2_MIDI_CTL_SOFT_PEDAL = 0x43, /**< Soft Pedal */
- LV2_MIDI_CTL_LEGATO_FOOTSWITCH = 0x44, /**< Legato Foot Switch */
- LV2_MIDI_CTL_HOLD2 = 0x45, /**< Hold2 */
- LV2_MIDI_CTL_SC1_SOUND_VARIATION = 0x46, /**< SC1 Sound Variation */
- LV2_MIDI_CTL_SC2_TIMBRE = 0x47, /**< SC2 Timbre */
- LV2_MIDI_CTL_SC3_RELEASE_TIME = 0x48, /**< SC3 Release Time */
- LV2_MIDI_CTL_SC4_ATTACK_TIME = 0x49, /**< SC4 Attack Time */
- LV2_MIDI_CTL_SC5_BRIGHTNESS = 0x4A, /**< SC5 Brightness */
- LV2_MIDI_CTL_SC6 = 0x4B, /**< SC6 */
- LV2_MIDI_CTL_SC7 = 0x4C, /**< SC7 */
- LV2_MIDI_CTL_SC8 = 0x4D, /**< SC8 */
- LV2_MIDI_CTL_SC9 = 0x4E, /**< SC9 */
- LV2_MIDI_CTL_SC10 = 0x4F, /**< SC10 */
- LV2_MIDI_CTL_GENERAL_PURPOSE5 = 0x50, /**< General Purpose 5 */
- LV2_MIDI_CTL_GENERAL_PURPOSE6 = 0x51, /**< General Purpose 6 */
- LV2_MIDI_CTL_GENERAL_PURPOSE7 = 0x52, /**< General Purpose 7 */
- LV2_MIDI_CTL_GENERAL_PURPOSE8 = 0x53, /**< General Purpose 8 */
- LV2_MIDI_CTL_PORTAMENTO_CONTROL = 0x54, /**< Portamento Control */
- LV2_MIDI_CTL_E1_REVERB_DEPTH = 0x5B, /**< E1 Reverb Depth */
- LV2_MIDI_CTL_E2_TREMOLO_DEPTH = 0x5C, /**< E2 Tremolo Depth */
- LV2_MIDI_CTL_E3_CHORUS_DEPTH = 0x5D, /**< E3 Chorus Depth */
- LV2_MIDI_CTL_E4_DETUNE_DEPTH = 0x5E, /**< E4 Detune Depth */
- LV2_MIDI_CTL_E5_PHASER_DEPTH = 0x5F, /**< E5 Phaser Depth */
- LV2_MIDI_CTL_DATA_INCREMENT = 0x60, /**< Data Increment */
- LV2_MIDI_CTL_DATA_DECREMENT = 0x61, /**< Data Decrement */
- LV2_MIDI_CTL_NRPN_LSB = 0x62, /**< Non-registered Parameter Number */
- LV2_MIDI_CTL_NRPN_MSB = 0x63, /**< Non-registered Parameter Number */
- LV2_MIDI_CTL_RPN_LSB = 0x64, /**< Registered Parameter Number */
- LV2_MIDI_CTL_RPN_MSB = 0x65, /**< Registered Parameter Number */
- LV2_MIDI_CTL_ALL_SOUNDS_OFF = 0x78, /**< All Sounds Off */
- LV2_MIDI_CTL_RESET_CONTROLLERS = 0x79, /**< Reset Controllers */
- LV2_MIDI_CTL_LOCAL_CONTROL_SWITCH = 0x7A, /**< Local Control Switch */
- LV2_MIDI_CTL_ALL_NOTES_OFF = 0x7B, /**< All Notes Off */
- LV2_MIDI_CTL_OMNI_OFF = 0x7C, /**< Omni Off */
- LV2_MIDI_CTL_OMNI_ON = 0x7D, /**< Omni On */
- LV2_MIDI_CTL_MONO1 = 0x7E, /**< Mono1 */
- LV2_MIDI_CTL_MONO2 = 0x7F /**< Mono2 */
+ LV2_MIDI_CTL_MSB_BANK = 0x00, /**< Bank Selection */
+ LV2_MIDI_CTL_MSB_MODWHEEL = 0x01, /**< Modulation */
+ LV2_MIDI_CTL_MSB_BREATH = 0x02, /**< Breath */
+ LV2_MIDI_CTL_MSB_FOOT = 0x04, /**< Foot */
+ LV2_MIDI_CTL_MSB_PORTAMENTO_TIME = 0x05, /**< Portamento Time */
+ LV2_MIDI_CTL_MSB_DATA_ENTRY = 0x06, /**< Data Entry */
+ LV2_MIDI_CTL_MSB_MAIN_VOLUME = 0x07, /**< Main Volume */
+ LV2_MIDI_CTL_MSB_BALANCE = 0x08, /**< Balance */
+ LV2_MIDI_CTL_MSB_PAN = 0x0A, /**< Panpot */
+ LV2_MIDI_CTL_MSB_EXPRESSION = 0x0B, /**< Expression */
+ LV2_MIDI_CTL_MSB_EFFECT1 = 0x0C, /**< Effect1 */
+ LV2_MIDI_CTL_MSB_EFFECT2 = 0x0D, /**< Effect2 */
+ LV2_MIDI_CTL_MSB_GENERAL_PURPOSE1 = 0x10, /**< General Purpose 1 */
+ LV2_MIDI_CTL_MSB_GENERAL_PURPOSE2 = 0x11, /**< General Purpose 2 */
+ LV2_MIDI_CTL_MSB_GENERAL_PURPOSE3 = 0x12, /**< General Purpose 3 */
+ LV2_MIDI_CTL_MSB_GENERAL_PURPOSE4 = 0x13, /**< General Purpose 4 */
+ LV2_MIDI_CTL_LSB_BANK = 0x20, /**< Bank Selection */
+ LV2_MIDI_CTL_LSB_MODWHEEL = 0x21, /**< Modulation */
+ LV2_MIDI_CTL_LSB_BREATH = 0x22, /**< Breath */
+ LV2_MIDI_CTL_LSB_FOOT = 0x24, /**< Foot */
+ LV2_MIDI_CTL_LSB_PORTAMENTO_TIME = 0x25, /**< Portamento Time */
+ LV2_MIDI_CTL_LSB_DATA_ENTRY = 0x26, /**< Data Entry */
+ LV2_MIDI_CTL_LSB_MAIN_VOLUME = 0x27, /**< Main Volume */
+ LV2_MIDI_CTL_LSB_BALANCE = 0x28, /**< Balance */
+ LV2_MIDI_CTL_LSB_PAN = 0x2A, /**< Panpot */
+ LV2_MIDI_CTL_LSB_EXPRESSION = 0x2B, /**< Expression */
+ LV2_MIDI_CTL_LSB_EFFECT1 = 0x2C, /**< Effect1 */
+ LV2_MIDI_CTL_LSB_EFFECT2 = 0x2D, /**< Effect2 */
+ LV2_MIDI_CTL_LSB_GENERAL_PURPOSE1 = 0x30, /**< General Purpose 1 */
+ LV2_MIDI_CTL_LSB_GENERAL_PURPOSE2 = 0x31, /**< General Purpose 2 */
+ LV2_MIDI_CTL_LSB_GENERAL_PURPOSE3 = 0x32, /**< General Purpose 3 */
+ LV2_MIDI_CTL_LSB_GENERAL_PURPOSE4 = 0x33, /**< General Purpose 4 */
+ LV2_MIDI_CTL_SUSTAIN = 0x40, /**< Sustain Pedal */
+ LV2_MIDI_CTL_PORTAMENTO = 0x41, /**< Portamento */
+ LV2_MIDI_CTL_SOSTENUTO = 0x42, /**< Sostenuto */
+ LV2_MIDI_CTL_SOFT_PEDAL = 0x43, /**< Soft Pedal */
+ LV2_MIDI_CTL_LEGATO_FOOTSWITCH = 0x44, /**< Legato Foot Switch */
+ LV2_MIDI_CTL_HOLD2 = 0x45, /**< Hold2 */
+ LV2_MIDI_CTL_SC1_SOUND_VARIATION = 0x46, /**< SC1 Sound Variation */
+ LV2_MIDI_CTL_SC2_TIMBRE = 0x47, /**< SC2 Timbre */
+ LV2_MIDI_CTL_SC3_RELEASE_TIME = 0x48, /**< SC3 Release Time */
+ LV2_MIDI_CTL_SC4_ATTACK_TIME = 0x49, /**< SC4 Attack Time */
+ LV2_MIDI_CTL_SC5_BRIGHTNESS = 0x4A, /**< SC5 Brightness */
+ LV2_MIDI_CTL_SC6 = 0x4B, /**< SC6 */
+ LV2_MIDI_CTL_SC7 = 0x4C, /**< SC7 */
+ LV2_MIDI_CTL_SC8 = 0x4D, /**< SC8 */
+ LV2_MIDI_CTL_SC9 = 0x4E, /**< SC9 */
+ LV2_MIDI_CTL_SC10 = 0x4F, /**< SC10 */
+ LV2_MIDI_CTL_GENERAL_PURPOSE5 = 0x50, /**< General Purpose 5 */
+ LV2_MIDI_CTL_GENERAL_PURPOSE6 = 0x51, /**< General Purpose 6 */
+ LV2_MIDI_CTL_GENERAL_PURPOSE7 = 0x52, /**< General Purpose 7 */
+ LV2_MIDI_CTL_GENERAL_PURPOSE8 = 0x53, /**< General Purpose 8 */
+ LV2_MIDI_CTL_PORTAMENTO_CONTROL = 0x54, /**< Portamento Control */
+ LV2_MIDI_CTL_E1_REVERB_DEPTH = 0x5B, /**< E1 Reverb Depth */
+ LV2_MIDI_CTL_E2_TREMOLO_DEPTH = 0x5C, /**< E2 Tremolo Depth */
+ LV2_MIDI_CTL_E3_CHORUS_DEPTH = 0x5D, /**< E3 Chorus Depth */
+ LV2_MIDI_CTL_E4_DETUNE_DEPTH = 0x5E, /**< E4 Detune Depth */
+ LV2_MIDI_CTL_E5_PHASER_DEPTH = 0x5F, /**< E5 Phaser Depth */
+ LV2_MIDI_CTL_DATA_INCREMENT = 0x60, /**< Data Increment */
+ LV2_MIDI_CTL_DATA_DECREMENT = 0x61, /**< Data Decrement */
+ LV2_MIDI_CTL_NRPN_LSB = 0x62, /**< Non-registered Parameter Number */
+ LV2_MIDI_CTL_NRPN_MSB = 0x63, /**< Non-registered Parameter Number */
+ LV2_MIDI_CTL_RPN_LSB = 0x64, /**< Registered Parameter Number */
+ LV2_MIDI_CTL_RPN_MSB = 0x65, /**< Registered Parameter Number */
+ LV2_MIDI_CTL_ALL_SOUNDS_OFF = 0x78, /**< All Sounds Off */
+ LV2_MIDI_CTL_RESET_CONTROLLERS = 0x79, /**< Reset Controllers */
+ LV2_MIDI_CTL_LOCAL_CONTROL_SWITCH = 0x7A, /**< Local Control Switch */
+ LV2_MIDI_CTL_ALL_NOTES_OFF = 0x7B, /**< All Notes Off */
+ LV2_MIDI_CTL_OMNI_OFF = 0x7C, /**< Omni Off */
+ LV2_MIDI_CTL_OMNI_ON = 0x7D, /**< Omni On */
+ LV2_MIDI_CTL_MONO1 = 0x7E, /**< Mono1 */
+ LV2_MIDI_CTL_MONO2 = 0x7F /**< Mono2 */
} LV2_Midi_Controller;
/**
Return true iff `msg` is a MIDI voice message (which has a channel).
*/
static inline bool
-lv2_midi_is_voice_message(const uint8_t* msg) {
- return msg[0] >= 0x80 && msg[0] < 0xF0;
+lv2_midi_is_voice_message(const uint8_t* msg)
+{
+ return msg[0] >= 0x80 && msg[0] < 0xF0;
}
/**
Return true iff `msg` is a MIDI system message (which has no channel).
*/
static inline bool
-lv2_midi_is_system_message(const uint8_t* msg) {
- switch (msg[0]) {
- case 0xF4: case 0xF5: case 0xF7: case 0xF9: case 0xFD:
- return false;
- default:
- return (msg[0] & 0xF0) == 0xF0;
- }
+lv2_midi_is_system_message(const uint8_t* msg)
+{
+ switch (msg[0]) {
+ case 0xF4:
+ case 0xF5:
+ case 0xF7:
+ case 0xF9:
+ case 0xFD:
+ return false;
+ default:
+ return (msg[0] & 0xF0) == 0xF0;
+ }
}
/**
@@ -218,24 +224,25 @@ lv2_midi_is_system_message(const uint8_t* msg) {
@param msg Pointer to the start (status byte) of a MIDI message.
*/
static inline LV2_Midi_Message_Type
-lv2_midi_message_type(const uint8_t* msg) {
- if (lv2_midi_is_voice_message(msg)) {
- return (LV2_Midi_Message_Type)(msg[0] & 0xF0);
- }
+lv2_midi_message_type(const uint8_t* msg)
+{
+ if (lv2_midi_is_voice_message(msg)) {
+ return (LV2_Midi_Message_Type)(msg[0] & 0xF0);
+ }
- if (lv2_midi_is_system_message(msg)) {
- return (LV2_Midi_Message_Type)msg[0];
- }
+ if (lv2_midi_is_system_message(msg)) {
+ return (LV2_Midi_Message_Type)msg[0];
+ }
- return LV2_MIDI_MSG_INVALID;
+ return LV2_MIDI_MSG_INVALID;
}
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
@}
*/
-#endif /* LV2_MIDI_H */
+#endif /* LV2_MIDI_H */
diff --git a/lv2/morph/morph.h b/lv2/morph/morph.h
index 8b096e0..08dee94 100644
--- a/lv2/morph/morph.h
+++ b/lv2/morph/morph.h
@@ -45,4 +45,4 @@
@}
*/
-#endif /* LV2_MORPH_H */
+#endif /* LV2_MORPH_H */
diff --git a/lv2/options/options.h b/lv2/options/options.h
index b0f8274..a403788 100644
--- a/lv2/options/options.h
+++ b/lv2/options/options.h
@@ -54,29 +54,29 @@ extern "C" {
The context of an Option, which defines the subject it applies to.
*/
typedef enum {
- /**
- This option applies to the instance itself. The subject must be
- ignored.
- */
- LV2_OPTIONS_INSTANCE,
-
- /**
- This option applies to some named resource. The subject is a URI mapped
- to an integer (a LV2_URID, like the key)
- */
- LV2_OPTIONS_RESOURCE,
-
- /**
- This option applies to some blank node. The subject is a blank node
- identifier, which is valid only within the current local scope.
- */
- LV2_OPTIONS_BLANK,
-
- /**
- This option applies to a port on the instance. The subject is the
- port's index.
- */
- LV2_OPTIONS_PORT
+ /**
+ This option applies to the instance itself. The subject must be
+ ignored.
+ */
+ LV2_OPTIONS_INSTANCE,
+
+ /**
+ This option applies to some named resource. The subject is a URI mapped
+ to an integer (a LV2_URID, like the key)
+ */
+ LV2_OPTIONS_RESOURCE,
+
+ /**
+ This option applies to some blank node. The subject is a blank node
+ identifier, which is valid only within the current local scope.
+ */
+ LV2_OPTIONS_BLANK,
+
+ /**
+ This option applies to a port on the instance. The subject is the
+ port's index.
+ */
+ LV2_OPTIONS_PORT
} LV2_Options_Context;
/**
@@ -92,60 +92,58 @@ typedef enum {
accessed/manipulated using LV2_Options_Interface.
*/
typedef struct {
- LV2_Options_Context context; /**< Context (type of subject). */
- uint32_t subject; /**< Subject. */
- LV2_URID key; /**< Key (property). */
- uint32_t size; /**< Size of value in bytes. */
- LV2_URID type; /**< Type of value (datatype). */
- const void* value; /**< Pointer to value (object). */
+ LV2_Options_Context context; /**< Context (type of subject). */
+ uint32_t subject; /**< Subject. */
+ LV2_URID key; /**< Key (property). */
+ uint32_t size; /**< Size of value in bytes. */
+ LV2_URID type; /**< Type of value (datatype). */
+ const void* value; /**< Pointer to value (object). */
} LV2_Options_Option;
/** A status code for option functions. */
typedef enum {
- LV2_OPTIONS_SUCCESS = 0, /**< Completed successfully. */
- LV2_OPTIONS_ERR_UNKNOWN = 1, /**< Unknown error. */
- LV2_OPTIONS_ERR_BAD_SUBJECT = 1 << 1, /**< Invalid/unsupported subject. */
- LV2_OPTIONS_ERR_BAD_KEY = 1 << 2, /**< Invalid/unsupported key. */
- LV2_OPTIONS_ERR_BAD_VALUE = 1 << 3 /**< Invalid/unsupported value. */
+ LV2_OPTIONS_SUCCESS = 0, /**< Completed successfully. */
+ LV2_OPTIONS_ERR_UNKNOWN = 1, /**< Unknown error. */
+ LV2_OPTIONS_ERR_BAD_SUBJECT = 1 << 1, /**< Invalid/unsupported subject. */
+ LV2_OPTIONS_ERR_BAD_KEY = 1 << 2, /**< Invalid/unsupported key. */
+ LV2_OPTIONS_ERR_BAD_VALUE = 1 << 3 /**< Invalid/unsupported value. */
} LV2_Options_Status;
/**
Interface for dynamically setting options (LV2_OPTIONS__interface).
*/
typedef struct {
- /**
- Get the given options.
+ /**
+ Get the given options.
- Each element of the passed options array MUST have type, subject, and
- key set. All other fields (size, type, value) MUST be initialised to
- zero, and are set to the option value if such an option is found.
+ Each element of the passed options array MUST have type, subject, and
+ key set. All other fields (size, type, value) MUST be initialised to
+ zero, and are set to the option value if such an option is found.
- This function is in the "instantiation" LV2 threading class, so no other
- instance functions may be called concurrently.
+ This function is in the "instantiation" LV2 threading class, so no other
+ instance functions may be called concurrently.
- @return Bitwise OR of LV2_Options_Status values.
- */
- uint32_t (*get)(LV2_Handle instance,
- LV2_Options_Option* options);
+ @return Bitwise OR of LV2_Options_Status values.
+ */
+ uint32_t (*get)(LV2_Handle instance, LV2_Options_Option* options);
- /**
- Set the given options.
+ /**
+ Set the given options.
- This function is in the "instantiation" LV2 threading class, so no other
- instance functions may be called concurrently.
+ This function is in the "instantiation" LV2 threading class, so no other
+ instance functions may be called concurrently.
- @return Bitwise OR of LV2_Options_Status values.
- */
- uint32_t (*set)(LV2_Handle instance,
- const LV2_Options_Option* options);
+ @return Bitwise OR of LV2_Options_Status values.
+ */
+ uint32_t (*set)(LV2_Handle instance, const LV2_Options_Option* options);
} LV2_Options_Interface;
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
@}
*/
-#endif /* LV2_OPTIONS_H */
+#endif /* LV2_OPTIONS_H */
diff --git a/lv2/parameters/parameters.h b/lv2/parameters/parameters.h
index 49a3364..842f4da 100644
--- a/lv2/parameters/parameters.h
+++ b/lv2/parameters/parameters.h
@@ -65,4 +65,4 @@
@}
*/
-#endif /* LV2_PARAMETERS_H */
+#endif /* LV2_PARAMETERS_H */
diff --git a/lv2/patch/patch.h b/lv2/patch/patch.h
index a68b0bb..2c35714 100644
--- a/lv2/patch/patch.h
+++ b/lv2/patch/patch.h
@@ -70,4 +70,4 @@
@}
*/
-#endif /* LV2_PATCH_H */
+#endif /* LV2_PATCH_H */
diff --git a/lv2/port-groups/port-groups.h b/lv2/port-groups/port-groups.h
index 0dd3c0d..3e967f0 100644
--- a/lv2/port-groups/port-groups.h
+++ b/lv2/port-groups/port-groups.h
@@ -74,4 +74,4 @@
@}
*/
-#endif /* LV2_PORT_GROUPS_H */
+#endif /* LV2_PORT_GROUPS_H */
diff --git a/lv2/port-props/port-props.h b/lv2/port-props/port-props.h
index a413d54..94b34ee 100644
--- a/lv2/port-props/port-props.h
+++ b/lv2/port-props/port-props.h
@@ -50,4 +50,4 @@
@}
*/
-#endif /* LV2_PORT_PROPS_H */
+#endif /* LV2_PORT_PROPS_H */
diff --git a/lv2/presets/presets.h b/lv2/presets/presets.h
index d09b71f..9c1f8bd 100644
--- a/lv2/presets/presets.h
+++ b/lv2/presets/presets.h
@@ -45,4 +45,4 @@
@}
*/
-#endif /* LV2_PRESETS_H */
+#endif /* LV2_PRESETS_H */
diff --git a/lv2/resize-port/resize-port.h b/lv2/resize-port/resize-port.h
index 068001c..c6a5fa1 100644
--- a/lv2/resize-port/resize-port.h
+++ b/lv2/resize-port/resize-port.h
@@ -46,9 +46,9 @@ extern "C" {
/** A status code for state functions. */
typedef enum {
- LV2_RESIZE_PORT_SUCCESS = 0, /**< Completed successfully. */
- LV2_RESIZE_PORT_ERR_UNKNOWN = 1, /**< Unknown error. */
- LV2_RESIZE_PORT_ERR_NO_SPACE = 2 /**< Insufficient space. */
+ LV2_RESIZE_PORT_SUCCESS = 0, /**< Completed successfully. */
+ LV2_RESIZE_PORT_ERR_UNKNOWN = 1, /**< Unknown error. */
+ LV2_RESIZE_PORT_ERR_NO_SPACE = 2 /**< Insufficient space. */
} LV2_Resize_Port_Status;
/** Opaque data for resize method. */
@@ -56,34 +56,34 @@ typedef void* LV2_Resize_Port_Feature_Data;
/** Host feature to allow plugins to resize their port buffers. */
typedef struct {
- /** Opaque data for resize method. */
- LV2_Resize_Port_Feature_Data data;
+ /** Opaque data for resize method. */
+ LV2_Resize_Port_Feature_Data data;
- /**
- Resize a port buffer to at least `size` bytes.
+ /**
+ Resize a port buffer to at least `size` bytes.
- This function MAY return an error, in which case the port buffer was not
- resized and the port is still connected to the same location. Plugins
- MUST gracefully handle this situation.
+ This function MAY return an error, in which case the port buffer was not
+ resized and the port is still connected to the same location. Plugins
+ MUST gracefully handle this situation.
- This function is in the audio threading class.
+ This function is in the audio threading class.
- The host MUST preserve the contents of the port buffer when resizing.
+ The host MUST preserve the contents of the port buffer when resizing.
- Plugins MAY resize a port many times in a single run callback. Hosts
- SHOULD make this as inexpensive as possible.
- */
- LV2_Resize_Port_Status (*resize)(LV2_Resize_Port_Feature_Data data,
- uint32_t index,
- size_t size);
+ Plugins MAY resize a port many times in a single run callback. Hosts
+ SHOULD make this as inexpensive as possible.
+ */
+ LV2_Resize_Port_Status (*resize)(LV2_Resize_Port_Feature_Data data,
+ uint32_t index,
+ size_t size);
} LV2_Resize_Port_Resize;
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
@}
*/
-#endif /* LV2_RESIZE_PORT_H */
+#endif /* LV2_RESIZE_PORT_H */
diff --git a/lv2/state/state.h b/lv2/state/state.h
index 0de3ee4..55db43b 100644
--- a/lv2/state/state.h
+++ b/lv2/state/state.h
@@ -55,10 +55,13 @@
extern "C" {
#endif
-typedef void* LV2_State_Handle; ///< Opaque handle for state save/restore
-typedef void* LV2_State_Free_Path_Handle; ///< Opaque handle for state:freePath feature
-typedef void* LV2_State_Map_Path_Handle; ///< Opaque handle for state:mapPath feature
-typedef void* LV2_State_Make_Path_Handle; ///< Opaque handle for state:makePath feature
+typedef void* LV2_State_Handle; ///< Opaque handle for state save/restore
+typedef void*
+ LV2_State_Free_Path_Handle; ///< Opaque handle for state:freePath feature
+typedef void*
+ LV2_State_Map_Path_Handle; ///< Opaque handle for state:mapPath feature
+typedef void*
+ LV2_State_Make_Path_Handle; ///< Opaque handle for state:makePath feature
/**
Flags describing value characteristics.
@@ -67,52 +70,52 @@ typedef void* LV2_State_Make_Path_Handle; ///< Opaque handle for state:makePath
(de-)serialise the value data, or whether it is even possible to do so.
*/
typedef enum {
- /**
- Plain Old Data.
-
- Values with this flag contain no pointers or references to other areas
- of memory. It is safe to copy POD values with a simple memcpy and store
- them for the duration of the process. A POD value is not necessarily
- safe to trasmit between processes or machines (for example, filenames
- are POD), see LV2_STATE_IS_PORTABLE for details.
-
- Implementations MUST NOT attempt to copy or serialise a non-POD value if
- they do not understand its type (and thus know how to correctly do so).
- */
- LV2_STATE_IS_POD = 1,
-
- /**
- Portable (architecture independent) data.
-
- Values with this flag are in a format that is usable on any
- architecture. A portable value saved on one machine can be restored on
- another machine regardless of architecture. The format of portable
- values MUST NOT depend on architecture-specific properties like
- endianness or alignment. Portable values MUST NOT contain filenames.
- */
- LV2_STATE_IS_PORTABLE = 1 << 1,
-
- /**
- Native data.
-
- This flag is used by the host to indicate that the saved data is only
- going to be used locally in the currently running process (for things
- like instance duplication or snapshots), so the plugin should use the
- most efficient representation possible and not worry about serialisation
- and portability.
- */
- LV2_STATE_IS_NATIVE = 1 << 2
+ /**
+ Plain Old Data.
+
+ Values with this flag contain no pointers or references to other areas
+ of memory. It is safe to copy POD values with a simple memcpy and store
+ them for the duration of the process. A POD value is not necessarily
+ safe to trasmit between processes or machines (for example, filenames
+ are POD), see LV2_STATE_IS_PORTABLE for details.
+
+ Implementations MUST NOT attempt to copy or serialise a non-POD value if
+ they do not understand its type (and thus know how to correctly do so).
+ */
+ LV2_STATE_IS_POD = 1,
+
+ /**
+ Portable (architecture independent) data.
+
+ Values with this flag are in a format that is usable on any
+ architecture. A portable value saved on one machine can be restored on
+ another machine regardless of architecture. The format of portable
+ values MUST NOT depend on architecture-specific properties like
+ endianness or alignment. Portable values MUST NOT contain filenames.
+ */
+ LV2_STATE_IS_PORTABLE = 1 << 1,
+
+ /**
+ Native data.
+
+ This flag is used by the host to indicate that the saved data is only
+ going to be used locally in the currently running process (for things
+ like instance duplication or snapshots), so the plugin should use the
+ most efficient representation possible and not worry about serialisation
+ and portability.
+ */
+ LV2_STATE_IS_NATIVE = 1 << 2
} LV2_State_Flags;
/** A status code for state functions. */
typedef enum {
- LV2_STATE_SUCCESS = 0, /**< Completed successfully. */
- LV2_STATE_ERR_UNKNOWN = 1, /**< Unknown error. */
- LV2_STATE_ERR_BAD_TYPE = 2, /**< Failed due to unsupported type. */
- LV2_STATE_ERR_BAD_FLAGS = 3, /**< Failed due to unsupported flags. */
- LV2_STATE_ERR_NO_FEATURE = 4, /**< Failed due to missing features. */
- LV2_STATE_ERR_NO_PROPERTY = 5, /**< Failed due to missing property. */
- LV2_STATE_ERR_NO_SPACE = 6 /**< Failed due to insufficient space. */
+ LV2_STATE_SUCCESS = 0, /**< Completed successfully. */
+ LV2_STATE_ERR_UNKNOWN = 1, /**< Unknown error. */
+ LV2_STATE_ERR_BAD_TYPE = 2, /**< Failed due to unsupported type. */
+ LV2_STATE_ERR_BAD_FLAGS = 3, /**< Failed due to unsupported flags. */
+ LV2_STATE_ERR_NO_FEATURE = 4, /**< Failed due to missing features. */
+ LV2_STATE_ERR_NO_PROPERTY = 5, /**< Failed due to missing property. */
+ LV2_STATE_ERR_NO_SPACE = 6 /**< Failed due to insufficient space. */
} LV2_State_Status;
/**
@@ -148,13 +151,12 @@ typedef enum {
The plugin MUST NOT attempt to use this function outside of the
LV2_State_Interface.restore() context.
*/
-typedef LV2_State_Status (*LV2_State_Store_Function)(
- LV2_State_Handle handle,
- uint32_t key,
- const void* value,
- size_t size,
- uint32_t type,
- uint32_t flags);
+typedef LV2_State_Status (*LV2_State_Store_Function)(LV2_State_Handle handle,
+ uint32_t key,
+ const void* value,
+ size_t size,
+ uint32_t type,
+ uint32_t flags);
/**
A host-provided function to retrieve a property.
@@ -174,12 +176,11 @@ typedef LV2_State_Status (*LV2_State_Store_Function)(
returns. The plugin MUST NOT attempt to use this function, or any value
returned from it, outside of the LV2_State_Interface.restore() context.
*/
-typedef const void* (*LV2_State_Retrieve_Function)(
- LV2_State_Handle handle,
- uint32_t key,
- size_t* size,
- uint32_t* type,
- uint32_t* flags);
+typedef const void* (*LV2_State_Retrieve_Function)(LV2_State_Handle handle,
+ uint32_t key,
+ size_t* size,
+ uint32_t* type,
+ uint32_t* flags);
/**
LV2 Plugin State Interface.
@@ -200,186 +201,184 @@ typedef const void* (*LV2_State_Retrieve_Function)(
with meaningful types to avoid such problems in the future.
*/
typedef struct {
- /**
- Save plugin state using a host-provided `store` callback.
-
- @param instance The instance handle of the plugin.
- @param store The host-provided store callback.
- @param handle An opaque pointer to host data which MUST be passed as the
- handle parameter to `store` if it is called.
- @param flags Flags describing desired properties of this save. These
- flags may be used to determine the most appropriate values to store.
- @param features Extensible parameter for passing any additional
- features to be used for this save.
-
- The plugin is expected to store everything necessary to completely
- restore its state later. Plugins SHOULD store simple POD data whenever
- possible, and consider the possibility of state being restored much
- later on a different machine.
-
- The `handle` pointer and `store` function MUST NOT be used
- beyond the scope of save().
-
- This function has its own special threading class: it may not be called
- concurrently with any "Instantiation" function, but it may be called
- concurrently with functions in any other class, unless the definition of
- that class prohibits it (for example, it may not be called concurrently
- with a "Discovery" function, but it may be called concurrently with an
- "Audio" function. The plugin is responsible for any locking or
- lock-free techniques necessary to make this possible.
-
- Note that in the simple case where state is only modified by restore(),
- there are no synchronization issues since save() is never called
- concurrently with restore() (though run() may read it during a save).
-
- Plugins that dynamically modify state while running, however, must take
- care to do so in such a way that a concurrent call to save() will save a
- consistent representation of plugin state for a single instant in time.
- */
- LV2_State_Status (*save)(LV2_Handle instance,
- LV2_State_Store_Function store,
- LV2_State_Handle handle,
- uint32_t flags,
- const LV2_Feature *const * features);
-
- /**
- Restore plugin state using a host-provided `retrieve` callback.
-
- @param instance The instance handle of the plugin.
- @param retrieve The host-provided retrieve callback.
- @param handle An opaque pointer to host data which MUST be passed as the
- handle parameter to `retrieve` if it is called.
- @param flags Currently unused.
- @param features Extensible parameter for passing any additional
- features to be used for this restore.
-
- The plugin MAY assume a restored value was set by a previous call to
- LV2_State_Interface.save() by a plugin with the same URI.
-
- The plugin MUST gracefully fall back to a default value when a value can
- not be retrieved. This allows the host to reset the plugin state with
- an empty map.
-
- The `handle` pointer and `store` function MUST NOT be used
- beyond the scope of restore().
-
- This function is in the "Instantiation" threading class as defined by
- LV2. This means it MUST NOT be called concurrently with any other
- function on the same plugin instance.
- */
- LV2_State_Status (*restore)(LV2_Handle instance,
- LV2_State_Retrieve_Function retrieve,
- LV2_State_Handle handle,
- uint32_t flags,
- const LV2_Feature *const * features);
+ /**
+ Save plugin state using a host-provided `store` callback.
+
+ @param instance The instance handle of the plugin.
+ @param store The host-provided store callback.
+ @param handle An opaque pointer to host data which MUST be passed as the
+ handle parameter to `store` if it is called.
+ @param flags Flags describing desired properties of this save. These
+ flags may be used to determine the most appropriate values to store.
+ @param features Extensible parameter for passing any additional
+ features to be used for this save.
+
+ The plugin is expected to store everything necessary to completely
+ restore its state later. Plugins SHOULD store simple POD data whenever
+ possible, and consider the possibility of state being restored much
+ later on a different machine.
+
+ The `handle` pointer and `store` function MUST NOT be used
+ beyond the scope of save().
+
+ This function has its own special threading class: it may not be called
+ concurrently with any "Instantiation" function, but it may be called
+ concurrently with functions in any other class, unless the definition of
+ that class prohibits it (for example, it may not be called concurrently
+ with a "Discovery" function, but it may be called concurrently with an
+ "Audio" function. The plugin is responsible for any locking or
+ lock-free techniques necessary to make this possible.
+
+ Note that in the simple case where state is only modified by restore(),
+ there are no synchronization issues since save() is never called
+ concurrently with restore() (though run() may read it during a save).
+
+ Plugins that dynamically modify state while running, however, must take
+ care to do so in such a way that a concurrent call to save() will save a
+ consistent representation of plugin state for a single instant in time.
+ */
+ LV2_State_Status (*save)(LV2_Handle instance,
+ LV2_State_Store_Function store,
+ LV2_State_Handle handle,
+ uint32_t flags,
+ const LV2_Feature* const* features);
+
+ /**
+ Restore plugin state using a host-provided `retrieve` callback.
+
+ @param instance The instance handle of the plugin.
+ @param retrieve The host-provided retrieve callback.
+ @param handle An opaque pointer to host data which MUST be passed as the
+ handle parameter to `retrieve` if it is called.
+ @param flags Currently unused.
+ @param features Extensible parameter for passing any additional
+ features to be used for this restore.
+
+ The plugin MAY assume a restored value was set by a previous call to
+ LV2_State_Interface.save() by a plugin with the same URI.
+
+ The plugin MUST gracefully fall back to a default value when a value can
+ not be retrieved. This allows the host to reset the plugin state with
+ an empty map.
+
+ The `handle` pointer and `store` function MUST NOT be used
+ beyond the scope of restore().
+
+ This function is in the "Instantiation" threading class as defined by
+ LV2. This means it MUST NOT be called concurrently with any other
+ function on the same plugin instance.
+ */
+ LV2_State_Status (*restore)(LV2_Handle instance,
+ LV2_State_Retrieve_Function retrieve,
+ LV2_State_Handle handle,
+ uint32_t flags,
+ const LV2_Feature* const* features);
} LV2_State_Interface;
/**
Feature data for state:mapPath (@ref LV2_STATE__mapPath).
*/
typedef struct {
- /**
- Opaque host data.
- */
- LV2_State_Map_Path_Handle handle;
-
- /**
- Map an absolute path to an abstract path for use in plugin state.
- @param handle MUST be the `handle` member of this struct.
- @param absolute_path The absolute path of a file.
- @return An abstract path suitable for use in plugin state.
-
- The plugin MUST use this function to map any paths that will be stored
- in plugin state. The returned value is an abstract path which MAY not
- be an actual file system path; absolute_path() MUST be used to map
- it to an actual path in order to use the file.
-
- Plugins MUST NOT make any assumptions about abstract paths except that
- they can be mapped back to the absolute path of the "same" file (though
- not necessarily the same original path) using absolute_path().
-
- This function may only be called within the context of
- LV2_State_Interface methods. The caller must free the returned value
- with LV2_State_Free_Path.free_path().
- */
- char* (*abstract_path)(LV2_State_Map_Path_Handle handle,
- const char* absolute_path);
-
- /**
- Map an abstract path from plugin state to an absolute path.
- @param handle MUST be the `handle` member of this struct.
- @param abstract_path An abstract path (typically from plugin state).
- @return An absolute file system path.
-
- The plugin MUST use this function in order to actually open or otherwise
- use any paths loaded from plugin state.
-
- This function may only be called within the context of
- LV2_State_Interface methods. The caller must free the returned value
- with LV2_State_Free_Path.free_path().
- */
- char* (*absolute_path)(LV2_State_Map_Path_Handle handle,
- const char* abstract_path);
+ /**
+ Opaque host data.
+ */
+ LV2_State_Map_Path_Handle handle;
+
+ /**
+ Map an absolute path to an abstract path for use in plugin state.
+ @param handle MUST be the `handle` member of this struct.
+ @param absolute_path The absolute path of a file.
+ @return An abstract path suitable for use in plugin state.
+
+ The plugin MUST use this function to map any paths that will be stored
+ in plugin state. The returned value is an abstract path which MAY not
+ be an actual file system path; absolute_path() MUST be used to map
+ it to an actual path in order to use the file.
+
+ Plugins MUST NOT make any assumptions about abstract paths except that
+ they can be mapped back to the absolute path of the "same" file (though
+ not necessarily the same original path) using absolute_path().
+
+ This function may only be called within the context of
+ LV2_State_Interface methods. The caller must free the returned value
+ with LV2_State_Free_Path.free_path().
+ */
+ char* (*abstract_path)(LV2_State_Map_Path_Handle handle,
+ const char* absolute_path);
+
+ /**
+ Map an abstract path from plugin state to an absolute path.
+ @param handle MUST be the `handle` member of this struct.
+ @param abstract_path An abstract path (typically from plugin state).
+ @return An absolute file system path.
+
+ The plugin MUST use this function in order to actually open or otherwise
+ use any paths loaded from plugin state.
+
+ This function may only be called within the context of
+ LV2_State_Interface methods. The caller must free the returned value
+ with LV2_State_Free_Path.free_path().
+ */
+ char* (*absolute_path)(LV2_State_Map_Path_Handle handle,
+ const char* abstract_path);
} LV2_State_Map_Path;
/**
Feature data for state:makePath (@ref LV2_STATE__makePath).
*/
typedef struct {
- /**
- Opaque host data.
- */
- LV2_State_Make_Path_Handle handle;
-
- /**
- Return a path the plugin may use to create a new file.
- @param handle MUST be the `handle` member of this struct.
- @param path The path of the new file within a namespace unique to this
- plugin instance.
- @return The absolute path to use for the new file.
-
- This function can be used by plugins to create files and directories,
- either at state saving time (if this feature is passed to
- LV2_State_Interface.save()) or any time (if this feature is passed to
- LV2_Descriptor.instantiate()).
-
- The host MUST do whatever is necessary for the plugin to be able to
- create a file at the returned path (for example, using fopen()),
- including creating any leading directories.
-
- If this function is passed to LV2_Descriptor.instantiate(), it may be
- called from any non-realtime context. If it is passed to
- LV2_State_Interface.save(), it may only be called within the dynamic
- scope of that function call.
-
- The caller must free the returned value with
- LV2_State_Free_Path.free_path().
- */
- char* (*path)(LV2_State_Make_Path_Handle handle,
- const char* path);
+ /**
+ Opaque host data.
+ */
+ LV2_State_Make_Path_Handle handle;
+
+ /**
+ Return a path the plugin may use to create a new file.
+ @param handle MUST be the `handle` member of this struct.
+ @param path The path of the new file within a namespace unique to this
+ plugin instance.
+ @return The absolute path to use for the new file.
+
+ This function can be used by plugins to create files and directories,
+ either at state saving time (if this feature is passed to
+ LV2_State_Interface.save()) or any time (if this feature is passed to
+ LV2_Descriptor.instantiate()).
+
+ The host MUST do whatever is necessary for the plugin to be able to
+ create a file at the returned path (for example, using fopen()),
+ including creating any leading directories.
+
+ If this function is passed to LV2_Descriptor.instantiate(), it may be
+ called from any non-realtime context. If it is passed to
+ LV2_State_Interface.save(), it may only be called within the dynamic
+ scope of that function call.
+
+ The caller must free the returned value with
+ LV2_State_Free_Path.free_path().
+ */
+ char* (*path)(LV2_State_Make_Path_Handle handle, const char* path);
} LV2_State_Make_Path;
/**
Feature data for state:freePath (@ref LV2_STATE__freePath).
*/
typedef struct {
- /**
- Opaque host data.
- */
- LV2_State_Free_Path_Handle handle;
-
- /**
- Free a path returned by a state feature.
-
- @param handle MUST be the `handle` member of this struct.
- @param path The path previously returned by a state feature.
-
- This function can be used by plugins to free paths allocated by the host
- and returned by state features (LV2_State_Map_Path.abstract_path(),
- LV2_State_Map_Path.absolute_path(), and LV2_State_Make_Path.path()).
- */
- void (*free_path)(LV2_State_Free_Path_Handle handle,
- char* path);
+ /**
+ Opaque host data.
+ */
+ LV2_State_Free_Path_Handle handle;
+
+ /**
+ Free a path returned by a state feature.
+
+ @param handle MUST be the `handle` member of this struct.
+ @param path The path previously returned by a state feature.
+
+ This function can be used by plugins to free paths allocated by the host
+ and returned by state features (LV2_State_Map_Path.abstract_path(),
+ LV2_State_Map_Path.absolute_path(), and LV2_State_Make_Path.path()).
+ */
+ void (*free_path)(LV2_State_Free_Path_Handle handle, char* path);
} LV2_State_Free_Path;
#ifdef __cplusplus
diff --git a/lv2/time/time.h b/lv2/time/time.h
index 10337ae..0bb3fbd 100644
--- a/lv2/time/time.h
+++ b/lv2/time/time.h
@@ -56,4 +56,4 @@
@}
*/
-#endif /* LV2_TIME_H */
+#endif /* LV2_TIME_H */
diff --git a/lv2/ui/ui.h b/lv2/ui/ui.h
index ee3c47d..61b3b54 100644
--- a/lv2/ui/ui.h
+++ b/lv2/ui/ui.h
@@ -145,86 +145,85 @@ typedef void (*LV2UI_Write_Function)(LV2UI_Controller controller,
function.
*/
typedef struct LV2UI_Descriptor {
- /**
- The URI for this UI (not for the plugin it controls).
- */
- const char* URI;
-
- /**
- Create a new UI and return a handle to it. This function works
- similarly to LV2_Descriptor::instantiate().
-
- @param descriptor The descriptor for the UI to instantiate.
-
- @param plugin_uri The URI of the plugin that this UI will control.
-
- @param bundle_path The path to the bundle containing this UI, including
- the trailing directory separator.
-
- @param write_function A function that the UI can use to send data to the
- plugin's input ports.
-
- @param controller A handle for the UI instance to be passed as the
- first parameter of UI methods.
-
- @param widget (output) widget pointer. The UI points this at its main
- widget, which has the type defined by the UI type in the data file.
-
- @param features An array of LV2_Feature pointers. The host must pass
- all feature URIs that it and the UI supports and any additional data, as
- in LV2_Descriptor::instantiate(). Note that UI features and plugin
- features are not necessarily the same.
-
- */
- LV2UI_Handle (*instantiate)(const struct LV2UI_Descriptor* descriptor,
- const char* plugin_uri,
- const char* bundle_path,
- LV2UI_Write_Function write_function,
- LV2UI_Controller controller,
- LV2UI_Widget* widget,
- const LV2_Feature* const* features);
-
-
- /**
- Destroy the UI. The host must not try to access the widget after
- calling this function.
- */
- void (*cleanup)(LV2UI_Handle ui);
-
- /**
- Tell the UI that something interesting has happened at a plugin port.
-
- What is "interesting" and how it is written to `buffer` is defined by
- `format`, which has the same meaning as in LV2UI_Write_Function().
- Format 0 is a special case for lv2:ControlPort, where this function
- should be called when the port value changes (but not necessarily for
- every change), `buffer_size` must be sizeof(float), and `buffer`
- points to a single IEEE-754 float.
-
- By default, the host should only call this function for lv2:ControlPort
- inputs. However, the UI can request updates for other ports statically
- with ui:portNotification or dynamicaly with ui:portSubscribe.
-
- The UI MUST NOT retain any reference to `buffer` after this function
- returns, it is only valid for the duration of the call.
-
- This member may be NULL if the UI is not interested in any port events.
- */
- void (*port_event)(LV2UI_Handle ui,
- uint32_t port_index,
- uint32_t buffer_size,
- uint32_t format,
- const void* buffer);
-
- /**
- Return a data structure associated with an extension URI, typically an
- interface struct with additional function pointers
-
- This member may be set to NULL if the UI is not interested in supporting
- any extensions. This is similar to LV2_Descriptor::extension_data().
-
- */
- const void* (*extension_data)(const char* uri);
+ /**
+ The URI for this UI (not for the plugin it controls).
+ */
+ const char* URI;
+
+ /**
+ Create a new UI and return a handle to it. This function works
+ similarly to LV2_Descriptor::instantiate().
+
+ @param descriptor The descriptor for the UI to instantiate.
+
+ @param plugin_uri The URI of the plugin that this UI will control.
+
+ @param bundle_path The path to the bundle containing this UI, including
+ the trailing directory separator.
+
+ @param write_function A function that the UI can use to send data to the
+ plugin's input ports.
+
+ @param controller A handle for the UI instance to be passed as the
+ first parameter of UI methods.
+
+ @param widget (output) widget pointer. The UI points this at its main
+ widget, which has the type defined by the UI type in the data file.
+
+ @param features An array of LV2_Feature pointers. The host must pass
+ all feature URIs that it and the UI supports and any additional data, as
+ in LV2_Descriptor::instantiate(). Note that UI features and plugin
+ features are not necessarily the same.
+
+ */
+ LV2UI_Handle (*instantiate)(const struct LV2UI_Descriptor* descriptor,
+ const char* plugin_uri,
+ const char* bundle_path,
+ LV2UI_Write_Function write_function,
+ LV2UI_Controller controller,
+ LV2UI_Widget* widget,
+ const LV2_Feature* const* features);
+
+ /**
+ Destroy the UI. The host must not try to access the widget after
+ calling this function.
+ */
+ void (*cleanup)(LV2UI_Handle ui);
+
+ /**
+ Tell the UI that something interesting has happened at a plugin port.
+
+ What is "interesting" and how it is written to `buffer` is defined by
+ `format`, which has the same meaning as in LV2UI_Write_Function().
+ Format 0 is a special case for lv2:ControlPort, where this function
+ should be called when the port value changes (but not necessarily for
+ every change), `buffer_size` must be sizeof(float), and `buffer`
+ points to a single IEEE-754 float.
+
+ By default, the host should only call this function for lv2:ControlPort
+ inputs. However, the UI can request updates for other ports statically
+ with ui:portNotification or dynamicaly with ui:portSubscribe.
+
+ The UI MUST NOT retain any reference to `buffer` after this function
+ returns, it is only valid for the duration of the call.
+
+ This member may be NULL if the UI is not interested in any port events.
+ */
+ void (*port_event)(LV2UI_Handle ui,
+ uint32_t port_index,
+ uint32_t buffer_size,
+ uint32_t format,
+ const void* buffer);
+
+ /**
+ Return a data structure associated with an extension URI, typically an
+ interface struct with additional function pointers
+
+ This member may be set to NULL if the UI is not interested in supporting
+ any extensions. This is similar to LV2_Descriptor::extension_data().
+
+ */
+ const void* (*extension_data)(const char* uri);
} LV2UI_Descriptor;
/**
@@ -235,24 +234,24 @@ typedef struct LV2UI_Descriptor {
LV2UI_Descriptor::extension_data()).
*/
typedef struct {
- /**
- Pointer to opaque data which must be passed to ui_resize().
- */
- LV2UI_Feature_Handle handle;
+ /**
+ Pointer to opaque data which must be passed to ui_resize().
+ */
+ LV2UI_Feature_Handle handle;
- /**
- Request/advertise a size change.
+ /**
+ Request/advertise a size change.
- When provided by the host, the UI may call this function to inform the
- host about the size of the UI.
+ When provided by the host, the UI may call this function to inform the
+ host about the size of the UI.
- When provided by the UI, the host may call this function to notify the
- UI that it should change its size accordingly. In this case, the host
- must pass the LV2UI_Handle to provide access to the UI instance.
+ When provided by the UI, the host may call this function to notify the
+ UI that it should change its size accordingly. In this case, the host
+ must pass the LV2UI_Handle to provide access to the UI instance.
- @return 0 on success.
- */
- int (*ui_resize)(LV2UI_Feature_Handle handle, int width, int height);
+ @return 0 on success.
+ */
+ int (*ui_resize)(LV2UI_Feature_Handle handle, int width, int height);
} LV2UI_Resize;
/**
@@ -263,181 +262,179 @@ typedef struct {
from the plugin (since symbol, unlike index, is a stable port identifier).
*/
typedef struct {
- /**
- Pointer to opaque data which must be passed to port_index().
- */
- LV2UI_Feature_Handle handle;
-
- /**
- Get the index for the port with the given `symbol`.
-
- @return The index of the port, or LV2UI_INVALID_PORT_INDEX if no such
- port is found.
- */
- uint32_t (*port_index)(LV2UI_Feature_Handle handle, const char* symbol);
+ /**
+ Pointer to opaque data which must be passed to port_index().
+ */
+ LV2UI_Feature_Handle handle;
+
+ /**
+ Get the index for the port with the given `symbol`.
+
+ @return The index of the port, or LV2UI_INVALID_PORT_INDEX if no such
+ port is found.
+ */
+ uint32_t (*port_index)(LV2UI_Feature_Handle handle, const char* symbol);
} LV2UI_Port_Map;
/**
Feature to subscribe to port updates (LV2_UI__portSubscribe).
*/
typedef struct {
- /**
- Pointer to opaque data which must be passed to subscribe() and
- unsubscribe().
- */
- LV2UI_Feature_Handle handle;
-
- /**
- Subscribe to updates for a port.
-
- This means that the host will call the UI's port_event() function when
- the port value changes (as defined by protocol).
-
- Calling this function with the same `port_index` and `port_protocol`
- as an already active subscription has no effect.
-
- @param handle The handle field of this struct.
- @param port_index The index of the port.
- @param port_protocol The URID of the ui:PortProtocol.
- @param features Features for this subscription.
- @return 0 on success.
- */
- uint32_t (*subscribe)(LV2UI_Feature_Handle handle,
- uint32_t port_index,
- uint32_t port_protocol,
- const LV2_Feature* const* features);
-
- /**
- Unsubscribe from updates for a port.
-
- This means that the host will cease calling calling port_event() when
- the port value changes.
-
- Calling this function with a `port_index` and `port_protocol` that
- does not refer to an active port subscription has no effect.
-
- @param handle The handle field of this struct.
- @param port_index The index of the port.
- @param port_protocol The URID of the ui:PortProtocol.
- @param features Features for this subscription.
- @return 0 on success.
- */
- uint32_t (*unsubscribe)(LV2UI_Feature_Handle handle,
- uint32_t port_index,
- uint32_t port_protocol,
- const LV2_Feature* const* features);
+ /**
+ Pointer to opaque data which must be passed to subscribe() and
+ unsubscribe().
+ */
+ LV2UI_Feature_Handle handle;
+
+ /**
+ Subscribe to updates for a port.
+
+ This means that the host will call the UI's port_event() function when
+ the port value changes (as defined by protocol).
+
+ Calling this function with the same `port_index` and `port_protocol`
+ as an already active subscription has no effect.
+
+ @param handle The handle field of this struct.
+ @param port_index The index of the port.
+ @param port_protocol The URID of the ui:PortProtocol.
+ @param features Features for this subscription.
+ @return 0 on success.
+ */
+ uint32_t (*subscribe)(LV2UI_Feature_Handle handle,
+ uint32_t port_index,
+ uint32_t port_protocol,
+ const LV2_Feature* const* features);
+
+ /**
+ Unsubscribe from updates for a port.
+
+ This means that the host will cease calling calling port_event() when
+ the port value changes.
+
+ Calling this function with a `port_index` and `port_protocol` that
+ does not refer to an active port subscription has no effect.
+
+ @param handle The handle field of this struct.
+ @param port_index The index of the port.
+ @param port_protocol The URID of the ui:PortProtocol.
+ @param features Features for this subscription.
+ @return 0 on success.
+ */
+ uint32_t (*unsubscribe)(LV2UI_Feature_Handle handle,
+ uint32_t port_index,
+ uint32_t port_protocol,
+ const LV2_Feature* const* features);
} LV2UI_Port_Subscribe;
/**
A feature to notify the host that the user has grabbed a UI control.
*/
typedef struct {
- /**
- Pointer to opaque data which must be passed to touch().
- */
- LV2UI_Feature_Handle handle;
-
- /**
- Notify the host that a control has been grabbed or released.
-
- The host should cease automating the port or otherwise manipulating the
- port value until the control has been ungrabbed.
-
- @param handle The handle field of this struct.
- @param port_index The index of the port associated with the control.
- @param grabbed If true, the control has been grabbed, otherwise the
- control has been released.
- */
- void (*touch)(LV2UI_Feature_Handle handle,
- uint32_t port_index,
- bool grabbed);
+ /**
+ Pointer to opaque data which must be passed to touch().
+ */
+ LV2UI_Feature_Handle handle;
+
+ /**
+ Notify the host that a control has been grabbed or released.
+
+ The host should cease automating the port or otherwise manipulating the
+ port value until the control has been ungrabbed.
+
+ @param handle The handle field of this struct.
+ @param port_index The index of the port associated with the control.
+ @param grabbed If true, the control has been grabbed, otherwise the
+ control has been released.
+ */
+ void (*touch)(LV2UI_Feature_Handle handle, uint32_t port_index, bool grabbed);
} LV2UI_Touch;
/**
A status code for LV2UI_Request_Value::request().
*/
typedef enum {
- /**
- Completed successfully.
-
- The host will set the parameter later if the user choses a new value.
- */
- LV2UI_REQUEST_VALUE_SUCCESS,
-
- /**
- Parameter already being requested.
-
- The host is already requesting a parameter from the user (for example, a
- dialog is visible), or the UI is otherwise busy and can not make this
- request.
- */
- LV2UI_REQUEST_VALUE_BUSY,
-
- /**
- Unknown parameter.
-
- The host is not aware of this parameter, and is not able to set a new
- value for it.
- */
- LV2UI_REQUEST_VALUE_ERR_UNKNOWN,
-
- /**
- Unsupported parameter.
-
- The host knows about this parameter, but does not support requesting a
- new value for it from the user. This is likely because the host does
- not have UI support for choosing a value with the appropriate type.
- */
- LV2UI_REQUEST_VALUE_ERR_UNSUPPORTED
+ /**
+ Completed successfully.
+
+ The host will set the parameter later if the user choses a new value.
+ */
+ LV2UI_REQUEST_VALUE_SUCCESS,
+
+ /**
+ Parameter already being requested.
+
+ The host is already requesting a parameter from the user (for example, a
+ dialog is visible), or the UI is otherwise busy and can not make this
+ request.
+ */
+ LV2UI_REQUEST_VALUE_BUSY,
+
+ /**
+ Unknown parameter.
+
+ The host is not aware of this parameter, and is not able to set a new
+ value for it.
+ */
+ LV2UI_REQUEST_VALUE_ERR_UNKNOWN,
+
+ /**
+ Unsupported parameter.
+
+ The host knows about this parameter, but does not support requesting a
+ new value for it from the user. This is likely because the host does
+ not have UI support for choosing a value with the appropriate type.
+ */
+ LV2UI_REQUEST_VALUE_ERR_UNSUPPORTED
} LV2UI_Request_Value_Status;
/**
A feature to request a new parameter value from the host.
*/
typedef struct {
- /**
- Pointer to opaque data which must be passed to request().
- */
- LV2UI_Feature_Handle handle;
-
- /**
- Request a value for a parameter from the host.
-
- This is mainly used by UIs to request values for complex parameters that
- don't change often, such as file paths, but it may be used to request
- any parameter value.
-
- This function returns immediately, and the return value indicates
- whether the host can fulfill the request. The host may notify the
- plugin about the new parameter value, for example when a file is
- selected by the user, via the usual mechanism. Typically, the host will
- send a message to the plugin that sets the new parameter value, and the
- plugin will notify the UI via a message as usual for any other parameter
- change.
-
- To provide an appropriate UI, the host can determine details about the
- parameter from the plugin data as usual. The additional parameters of
- this function provide support for more advanced use cases, but in the
- simple common case, the plugin will simply pass the key of the desired
- parameter and zero for everything else.
-
- @param handle The handle field of this struct.
-
- @param key The URID of the parameter.
-
- @param type The optional type of the value to request. This can be used
- to request a specific value type for parameters that support several.
- If non-zero, it must be the URID of an instance of rdfs:Class or
- rdfs:Datatype.
-
- @param features Additional features for this request, or NULL.
-
- @return A status code which is 0 on success.
- */
- LV2UI_Request_Value_Status (*request)(LV2UI_Feature_Handle handle,
- LV2_URID key,
- LV2_URID type,
- const LV2_Feature* const* features);
+ /**
+ Pointer to opaque data which must be passed to request().
+ */
+ LV2UI_Feature_Handle handle;
+
+ /**
+ Request a value for a parameter from the host.
+
+ This is mainly used by UIs to request values for complex parameters that
+ don't change often, such as file paths, but it may be used to request
+ any parameter value.
+
+ This function returns immediately, and the return value indicates
+ whether the host can fulfill the request. The host may notify the
+ plugin about the new parameter value, for example when a file is
+ selected by the user, via the usual mechanism. Typically, the host will
+ send a message to the plugin that sets the new parameter value, and the
+ plugin will notify the UI via a message as usual for any other parameter
+ change.
+
+ To provide an appropriate UI, the host can determine details about the
+ parameter from the plugin data as usual. The additional parameters of
+ this function provide support for more advanced use cases, but in the
+ simple common case, the plugin will simply pass the key of the desired
+ parameter and zero for everything else.
+
+ @param handle The handle field of this struct.
+
+ @param key The URID of the parameter.
+
+ @param type The optional type of the value to request. This can be used
+ to request a specific value type for parameters that support several.
+ If non-zero, it must be the URID of an instance of rdfs:Class or
+ rdfs:Datatype.
+
+ @param features Additional features for this request, or NULL.
+
+ @return A status code which is 0 on success.
+ */
+ LV2UI_Request_Value_Status (*request)(LV2UI_Feature_Handle handle,
+ LV2_URID key,
+ LV2_URID type,
+ const LV2_Feature* const* features);
} LV2UI_Request_Value;
@@ -448,19 +445,19 @@ typedef struct {
rapidly to update the UI.
*/
typedef struct {
- /**
- Run a single iteration of the UI's idle loop.
-
- This will be called rapidly in the UI thread at a rate appropriate
- for a toolkit main loop. There are no precise timing guarantees, but
- the host should attempt to call idle() at a high enough rate for smooth
- animation, at least 30Hz.
-
- @return non-zero if the UI has been closed, in which case the host
- should stop calling idle(), and can either completely destroy the UI, or
- re-show it and resume calling idle().
- */
- int (*idle)(LV2UI_Handle ui);
+ /**
+ Run a single iteration of the UI's idle loop.
+
+ This will be called rapidly in the UI thread at a rate appropriate
+ for a toolkit main loop. There are no precise timing guarantees, but
+ the host should attempt to call idle() at a high enough rate for smooth
+ animation, at least 30Hz.
+
+ @return non-zero if the UI has been closed, in which case the host
+ should stop calling idle(), and can either completely destroy the UI, or
+ re-show it and resume calling idle().
+ */
+ int (*idle)(LV2UI_Handle ui);
} LV2UI_Idle_Interface;
/**
@@ -472,51 +469,52 @@ typedef struct {
If used:
- The host MUST use LV2UI_Idle_Interface to drive the UI.
- - The UI MUST return non-zero from LV2UI_Idle_Interface::idle() when it has been closed.
+ - The UI MUST return non-zero from LV2UI_Idle_Interface::idle() when it has
+ been closed.
- If idle() returns non-zero, the host MUST call hide() and stop calling
idle(). It MAY later call show() then resume calling idle().
*/
typedef struct {
- /**
- Show a window for this UI.
+ /**
+ Show a window for this UI.
- The window title MAY have been passed by the host to
- LV2UI_Descriptor::instantiate() as an LV2_Options_Option with key
- LV2_UI__windowTitle.
+ The window title MAY have been passed by the host to
+ LV2UI_Descriptor::instantiate() as an LV2_Options_Option with key
+ LV2_UI__windowTitle.
- @return 0 on success, or anything else to stop being called.
- */
- int (*show)(LV2UI_Handle ui);
+ @return 0 on success, or anything else to stop being called.
+ */
+ int (*show)(LV2UI_Handle ui);
- /**
- Hide the window for this UI.
+ /**
+ Hide the window for this UI.
- @return 0 on success, or anything else to stop being called.
- */
- int (*hide)(LV2UI_Handle ui);
+ @return 0 on success, or anything else to stop being called.
+ */
+ int (*hide)(LV2UI_Handle ui);
} LV2UI_Show_Interface;
/**
Peak data for a slice of time, the update format for ui:peakProtocol.
*/
typedef struct {
- /**
- The start of the measurement period. This is just a running counter
- that is only meaningful in comparison to previous values and must not be
- interpreted as an absolute time.
- */
- uint32_t period_start;
-
- /**
- The size of the measurement period, in the same units as period_start.
- */
- uint32_t period_size;
-
- /**
- The peak value for the measurement period. This should be the maximal
- value for abs(sample) over all the samples in the period.
- */
- float peak;
+ /**
+ The start of the measurement period. This is just a running counter
+ that is only meaningful in comparison to previous values and must not be
+ interpreted as an absolute time.
+ */
+ uint32_t period_start;
+
+ /**
+ The size of the measurement period, in the same units as period_start.
+ */
+ uint32_t period_size;
+
+ /**
+ The peak value for the measurement period. This should be the maximal
+ value for abs(sample) over all the samples in the period.
+ */
+ float peak;
} LV2UI_Peak_Data;
/**
@@ -526,7 +524,8 @@ typedef struct {
lv2_descriptor() but for UIs rather than plugins.
*/
LV2_SYMBOL_EXPORT
-const LV2UI_Descriptor* lv2ui_descriptor(uint32_t index);
+const LV2UI_Descriptor*
+lv2ui_descriptor(uint32_t index);
/**
The type of the lv2ui_descriptor() function.
diff --git a/lv2/units/units.h b/lv2/units/units.h
index 07db081..a9017d2 100644
--- a/lv2/units/units.h
+++ b/lv2/units/units.h
@@ -72,4 +72,4 @@
@}
*/
-#endif /* LV2_UNITS_H */
+#endif /* LV2_UNITS_H */
diff --git a/lv2/uri-map/uri-map.h b/lv2/uri-map/uri-map.h
index 31e485a..be5068c 100644
--- a/lv2/uri-map/uri-map.h
+++ b/lv2/uri-map/uri-map.h
@@ -68,50 +68,50 @@ typedef void* LV2_URI_Map_Callback_Data;
*/
LV2_DEPRECATED
typedef struct {
- /**
- Opaque pointer to host data.
-
- The plugin MUST pass this to any call to functions in this struct.
- Otherwise, it must not be interpreted in any way.
- */
- LV2_URI_Map_Callback_Data callback_data;
-
- /**
- Get the numeric ID of a URI from the host.
-
- @param callback_data Must be the callback_data member of this struct.
- @param map The 'context' of this URI. Certain extensions may define a
- URI that must be passed here with certain restrictions on the return
- value (e.g. limited range). This value may be NULL if the plugin needs
- an ID for a URI in general. Extensions SHOULD NOT define a context
- unless there is a specific need to do so, e.g. to restrict the range of
- the returned value.
- @param uri The URI to be mapped to an integer ID.
-
- This function is referentially transparent; any number of calls with the
- same arguments is guaranteed to return the same value over the life of a
- plugin instance (though the same URI may return different values with a
- different map parameter). However, this function is not necessarily very
- fast: plugins SHOULD cache any IDs they might need in performance
- critical situations.
-
- The return value 0 is reserved and indicates that an ID for that URI
- could not be created for whatever reason. Extensions MAY define more
- precisely what this means in a certain context, but in general plugins
- SHOULD handle this situation as gracefully as possible. However, hosts
- SHOULD NOT return 0 from this function in non-exceptional circumstances
- (e.g. the URI map SHOULD be dynamic). Hosts that statically support only
- a fixed set of URIs should not expect plugins to function correctly.
- */
- uint32_t (*uri_to_id)(LV2_URI_Map_Callback_Data callback_data,
- const char* map,
- const char* uri);
+ /**
+ Opaque pointer to host data.
+
+ The plugin MUST pass this to any call to functions in this struct.
+ Otherwise, it must not be interpreted in any way.
+ */
+ LV2_URI_Map_Callback_Data callback_data;
+
+ /**
+ Get the numeric ID of a URI from the host.
+
+ @param callback_data Must be the callback_data member of this struct.
+ @param map The 'context' of this URI. Certain extensions may define a
+ URI that must be passed here with certain restrictions on the return
+ value (e.g. limited range). This value may be NULL if the plugin needs
+ an ID for a URI in general. Extensions SHOULD NOT define a context
+ unless there is a specific need to do so, e.g. to restrict the range of
+ the returned value.
+ @param uri The URI to be mapped to an integer ID.
+
+ This function is referentially transparent; any number of calls with the
+ same arguments is guaranteed to return the same value over the life of a
+ plugin instance (though the same URI may return different values with a
+ different map parameter). However, this function is not necessarily very
+ fast: plugins SHOULD cache any IDs they might need in performance
+ critical situations.
+
+ The return value 0 is reserved and indicates that an ID for that URI
+ could not be created for whatever reason. Extensions MAY define more
+ precisely what this means in a certain context, but in general plugins
+ SHOULD handle this situation as gracefully as possible. However, hosts
+ SHOULD NOT return 0 from this function in non-exceptional circumstances
+ (e.g. the URI map SHOULD be dynamic). Hosts that statically support only
+ a fixed set of URIs should not expect plugins to function correctly.
+ */
+ uint32_t (*uri_to_id)(LV2_URI_Map_Callback_Data callback_data,
+ const char* map,
+ const char* uri);
} LV2_URI_Map_Feature;
LV2_RESTORE_WARNINGS
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
diff --git a/lv2/urid/urid.h b/lv2/urid/urid.h
index 60aeffb..f9f1ad2 100644
--- a/lv2/urid/urid.h
+++ b/lv2/urid/urid.h
@@ -67,72 +67,70 @@ typedef uint32_t LV2_URID;
URID Map Feature (LV2_URID__map)
*/
typedef struct {
- /**
- Opaque pointer to host data.
+ /**
+ Opaque pointer to host data.
- This MUST be passed to map_uri() whenever it is called.
- Otherwise, it must not be interpreted in any way.
- */
- LV2_URID_Map_Handle handle;
+ This MUST be passed to map_uri() whenever it is called.
+ Otherwise, it must not be interpreted in any way.
+ */
+ LV2_URID_Map_Handle handle;
- /**
- Get the numeric ID of a URI.
+ /**
+ Get the numeric ID of a URI.
- If the ID does not already exist, it will be created.
+ If the ID does not already exist, it will be created.
- This function is referentially transparent; any number of calls with the
- same arguments is guaranteed to return the same value over the life of a
- plugin instance. Note, however, that several URIs MAY resolve to the
- same ID if the host considers those URIs equivalent.
+ This function is referentially transparent; any number of calls with the
+ same arguments is guaranteed to return the same value over the life of a
+ plugin instance. Note, however, that several URIs MAY resolve to the
+ same ID if the host considers those URIs equivalent.
- This function is not necessarily very fast or RT-safe: plugins SHOULD
- cache any IDs they might need in performance critical situations.
+ This function is not necessarily very fast or RT-safe: plugins SHOULD
+ cache any IDs they might need in performance critical situations.
- The return value 0 is reserved and indicates that an ID for that URI
- could not be created for whatever reason. However, hosts SHOULD NOT
- return 0 from this function in non-exceptional circumstances (i.e. the
- URI map SHOULD be dynamic).
+ The return value 0 is reserved and indicates that an ID for that URI
+ could not be created for whatever reason. However, hosts SHOULD NOT
+ return 0 from this function in non-exceptional circumstances (i.e. the
+ URI map SHOULD be dynamic).
- @param handle Must be the callback_data member of this struct.
- @param uri The URI to be mapped to an integer ID.
- */
- LV2_URID (*map)(LV2_URID_Map_Handle handle,
- const char* uri);
+ @param handle Must be the callback_data member of this struct.
+ @param uri The URI to be mapped to an integer ID.
+ */
+ LV2_URID (*map)(LV2_URID_Map_Handle handle, const char* uri);
} LV2_URID_Map;
/**
URI Unmap Feature (LV2_URID__unmap)
*/
typedef struct {
- /**
- Opaque pointer to host data.
-
- This MUST be passed to unmap() whenever it is called.
- Otherwise, it must not be interpreted in any way.
- */
- LV2_URID_Unmap_Handle handle;
-
- /**
- Get the URI for a previously mapped numeric ID.
-
- Returns NULL if `urid` is not yet mapped. Otherwise, the corresponding
- URI is returned in a canonical form. This MAY not be the exact same
- string that was originally passed to LV2_URID_Map::map(), but it MUST be
- an identical URI according to the URI syntax specification (RFC3986). A
- non-NULL return for a given `urid` will always be the same for the life
- of the plugin. Plugins that intend to perform string comparison on
- unmapped URIs SHOULD first canonicalise URI strings with a call to
- map_uri() followed by a call to unmap_uri().
-
- @param handle Must be the callback_data member of this struct.
- @param urid The ID to be mapped back to the URI string.
- */
- const char* (*unmap)(LV2_URID_Unmap_Handle handle,
- LV2_URID urid);
+ /**
+ Opaque pointer to host data.
+
+ This MUST be passed to unmap() whenever it is called.
+ Otherwise, it must not be interpreted in any way.
+ */
+ LV2_URID_Unmap_Handle handle;
+
+ /**
+ Get the URI for a previously mapped numeric ID.
+
+ Returns NULL if `urid` is not yet mapped. Otherwise, the corresponding
+ URI is returned in a canonical form. This MAY not be the exact same
+ string that was originally passed to LV2_URID_Map::map(), but it MUST be
+ an identical URI according to the URI syntax specification (RFC3986). A
+ non-NULL return for a given `urid` will always be the same for the life
+ of the plugin. Plugins that intend to perform string comparison on
+ unmapped URIs SHOULD first canonicalise URI strings with a call to
+ map_uri() followed by a call to unmap_uri().
+
+ @param handle Must be the callback_data member of this struct.
+ @param urid The ID to be mapped back to the URI string.
+ */
+ const char* (*unmap)(LV2_URID_Unmap_Handle handle, LV2_URID urid);
} LV2_URID_Unmap;
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
diff --git a/lv2/worker/worker.h b/lv2/worker/worker.h
index d9b1051..94e56b4 100644
--- a/lv2/worker/worker.h
+++ b/lv2/worker/worker.h
@@ -50,9 +50,9 @@ extern "C" {
Status code for worker functions.
*/
typedef enum {
- LV2_WORKER_SUCCESS = 0, /**< Completed successfully. */
- LV2_WORKER_ERR_UNKNOWN = 1, /**< Unknown error. */
- LV2_WORKER_ERR_NO_SPACE = 2 /**< Failed due to lack of space. */
+ LV2_WORKER_SUCCESS = 0, /**< Completed successfully. */
+ LV2_WORKER_ERR_UNKNOWN = 1, /**< Unknown error. */
+ LV2_WORKER_ERR_NO_SPACE = 2 /**< Failed due to lack of space. */
} LV2_Worker_Status;
/** Opaque handle for LV2_Worker_Interface::work(). */
@@ -66,9 +66,9 @@ typedef void* LV2_Worker_Respond_Handle;
passed to work_response() if this function returns LV2_WORKER_SUCCESS.
*/
typedef LV2_Worker_Status (*LV2_Worker_Respond_Function)(
- LV2_Worker_Respond_Handle handle,
- uint32_t size,
- const void* data);
+ LV2_Worker_Respond_Handle handle,
+ uint32_t size,
+ const void* data);
/**
Plugin Worker Interface.
@@ -78,52 +78,52 @@ typedef LV2_Worker_Status (*LV2_Worker_Respond_Function)(
when called with LV2_WORKER__interface as its argument.
*/
typedef struct {
- /**
- The worker method. This is called by the host in a non-realtime context
- as requested, possibly with an arbitrary message to handle.
-
- A response can be sent to run() using `respond`. The plugin MUST NOT
- make any assumptions about which thread calls this method, except that
- there are no real-time requirements and only one call may be executed at
- a time. That is, the host MAY call this method from any non-real-time
- thread, but MUST NOT make concurrent calls to this method from several
- threads.
-
- @param instance The LV2 instance this is a method on.
- @param respond A function for sending a response to run().
- @param handle Must be passed to `respond` if it is called.
- @param size The size of `data`.
- @param data Data from run(), or NULL.
- */
- LV2_Worker_Status (*work)(LV2_Handle instance,
- LV2_Worker_Respond_Function respond,
- LV2_Worker_Respond_Handle handle,
- uint32_t size,
- const void* data);
-
- /**
- Handle a response from the worker. This is called by the host in the
- run() context when a response from the worker is ready.
-
- @param instance The LV2 instance this is a method on.
- @param size The size of `body`.
- @param body Message body, or NULL.
- */
- LV2_Worker_Status (*work_response)(LV2_Handle instance,
- uint32_t size,
- const void* body);
-
- /**
- Called when all responses for this cycle have been delivered.
-
- Since work_response() may be called after run() finished, this provides
- a hook for code that must run after the cycle is completed.
-
- This field may be NULL if the plugin has no use for it. Otherwise, the
- host MUST call it after every run(), regardless of whether or not any
- responses were sent that cycle.
- */
- LV2_Worker_Status (*end_run)(LV2_Handle instance);
+ /**
+ The worker method. This is called by the host in a non-realtime context
+ as requested, possibly with an arbitrary message to handle.
+
+ A response can be sent to run() using `respond`. The plugin MUST NOT
+ make any assumptions about which thread calls this method, except that
+ there are no real-time requirements and only one call may be executed at
+ a time. That is, the host MAY call this method from any non-real-time
+ thread, but MUST NOT make concurrent calls to this method from several
+ threads.
+
+ @param instance The LV2 instance this is a method on.
+ @param respond A function for sending a response to run().
+ @param handle Must be passed to `respond` if it is called.
+ @param size The size of `data`.
+ @param data Data from run(), or NULL.
+ */
+ LV2_Worker_Status (*work)(LV2_Handle instance,
+ LV2_Worker_Respond_Function respond,
+ LV2_Worker_Respond_Handle handle,
+ uint32_t size,
+ const void* data);
+
+ /**
+ Handle a response from the worker. This is called by the host in the
+ run() context when a response from the worker is ready.
+
+ @param instance The LV2 instance this is a method on.
+ @param size The size of `body`.
+ @param body Message body, or NULL.
+ */
+ LV2_Worker_Status (*work_response)(LV2_Handle instance,
+ uint32_t size,
+ const void* body);
+
+ /**
+ Called when all responses for this cycle have been delivered.
+
+ Since work_response() may be called after run() finished, this provides
+ a hook for code that must run after the cycle is completed.
+
+ This field may be NULL if the plugin has no use for it. Otherwise, the
+ host MUST call it after every run(), regardless of whether or not any
+ responses were sent that cycle.
+ */
+ LV2_Worker_Status (*end_run)(LV2_Handle instance);
} LV2_Worker_Interface;
/** Opaque handle for LV2_Worker_Schedule. */
@@ -136,48 +136,48 @@ typedef void* LV2_Worker_Schedule_Handle;
the plugin can use to schedule a worker call from run().
*/
typedef struct {
- /**
- Opaque host data.
- */
- LV2_Worker_Schedule_Handle handle;
-
- /**
- Request from run() that the host call the worker.
-
- This function is in the audio threading class. It should be called from
- run() to request that the host call the work() method in a non-realtime
- context with the given arguments.
-
- This function is always safe to call from run(), but it is not
- guaranteed that the worker is actually called from a different thread.
- In particular, when free-wheeling (for example, during offline
- rendering), the worker may be executed immediately. This allows
- single-threaded processing with sample accuracy and avoids timing
- problems when run() is executing much faster or slower than real-time.
-
- Plugins SHOULD be written in such a way that if the worker runs
- immediately, and responses from the worker are delivered immediately,
- the effect of the work takes place immediately with sample accuracy.
-
- The `data` MUST be safe for the host to copy and later pass to work(),
- and the host MUST guarantee that it will be eventually passed to work()
- if this function returns LV2_WORKER_SUCCESS.
-
- @param handle The handle field of this struct.
- @param size The size of `data`.
- @param data Message to pass to work(), or NULL.
- */
- LV2_Worker_Status (*schedule_work)(LV2_Worker_Schedule_Handle handle,
- uint32_t size,
- const void* data);
+ /**
+ Opaque host data.
+ */
+ LV2_Worker_Schedule_Handle handle;
+
+ /**
+ Request from run() that the host call the worker.
+
+ This function is in the audio threading class. It should be called from
+ run() to request that the host call the work() method in a non-realtime
+ context with the given arguments.
+
+ This function is always safe to call from run(), but it is not
+ guaranteed that the worker is actually called from a different thread.
+ In particular, when free-wheeling (for example, during offline
+ rendering), the worker may be executed immediately. This allows
+ single-threaded processing with sample accuracy and avoids timing
+ problems when run() is executing much faster or slower than real-time.
+
+ Plugins SHOULD be written in such a way that if the worker runs
+ immediately, and responses from the worker are delivered immediately,
+ the effect of the work takes place immediately with sample accuracy.
+
+ The `data` MUST be safe for the host to copy and later pass to work(),
+ and the host MUST guarantee that it will be eventually passed to work()
+ if this function returns LV2_WORKER_SUCCESS.
+
+ @param handle The handle field of this struct.
+ @param size The size of `data`.
+ @param data Message to pass to work(), or NULL.
+ */
+ LV2_Worker_Status (*schedule_work)(LV2_Worker_Schedule_Handle handle,
+ uint32_t size,
+ const void* data);
} LV2_Worker_Schedule;
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
/**
@}
*/
-#endif /* LV2_WORKER_H */
+#endif /* LV2_WORKER_H */