aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-02-14 00:10:57 +0000
committerDavid Robillard <d@drobilla.net>2012-02-14 00:10:57 +0000
commit5ed1257408da33ac6b4cfbc15bf8034d47558976 (patch)
tree876de5f8605b50e959c7dc1abd59d26719da1f74 /plugins
parent563e19d485b503e3b798f8740cd551c4ebce5476 (diff)
downloadlv2-5ed1257408da33ac6b4cfbc15bf8034d47558976.tar.xz
Add lv2_object_getv.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/eg-sampler.lv2/sampler.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c
index 90d5cbe..960a391 100644
--- a/plugins/eg-sampler.lv2/sampler.c
+++ b/plugins/eg-sampler.lv2/sampler.c
@@ -251,6 +251,13 @@ cleanup(LV2_Handle instance)
}
static bool
+is_object_type(Sampler* plugin, LV2_URID type)
+{
+ return type == plugin->uris.atom_Resource
+ || type == plugin->uris.atom_Blank;
+}
+
+static bool
handle_message(Sampler* plugin,
const LV2_Atom_Object* obj)
{
@@ -259,29 +266,32 @@ handle_message(Sampler* plugin,
return false;
}
+ /* Message should look like this:
+ * [
+ * a msg:SetMessage ;
+ * msg:body [
+ * eg:filename "/some/value.wav" ;
+ * ] ;
+ * ]
+ */
+
/* Get body of message */
const LV2_Atom_Object* body = NULL;
- LV2_Atom_Object_Query q1[] = {
- { plugin->uris.msg_body, (const LV2_Atom**)&body },
- LV2_OBJECT_QUERY_END
- };
- lv2_object_get(obj, q1);
-
- if (!body) { // TODO: check type
- fprintf(stderr, "Malformed set message with no body.\n");
+ lv2_object_getv(obj, plugin->uris.msg_body, &body, 0);
+ if (!body) {
+ fprintf(stderr, "Malformed set message has no body.\n");
+ return false;
+ }
+ if (!is_object_type(plugin, body->atom.type)) {
+ fprintf(stderr, "Malformed set message has non-object body.\n");
return false;
}
/* Get filename from body */
const LV2_Atom* filename = NULL;
- LV2_Atom_Object_Query q2[] = {
- { plugin->uris.eg_filename, &filename },
- LV2_OBJECT_QUERY_END
- };
- lv2_object_get((LV2_Atom_Object*)body, q2);
-
+ lv2_object_getv(body, plugin->uris.eg_filename, &filename, 0);
if (!filename) {
- fprintf(stderr, "Ignored set message with no filename\n");
+ fprintf(stderr, "Ignored set message with no filename.\n");
return false;
}