Skip to content

Commit c6a66b4

Browse files
committed
Verify if required options can be satisfied
1 parent 2f8703e commit c6a66b4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/lv2ttl.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@
3434
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
3535
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
3636
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
37+
#include "lv2/lv2plug.in/ns/ext/buf-size/buf-size.h"
3738
#include "lv2/lv2plug.in/ns/ext/event/event.h"
3839
#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
40+
#include "lv2/lv2plug.in/ns/ext/options/options.h"
3941
#include "lv2/lv2plug.in/ns/ext/resize-port/resize-port.h"
4042
#include "lv2/lv2plug.in/ns/ext/state/state.h"
4143
#include "lv2/lv2plug.in/ns/ext/time/time.h"
44+
#include "lv2/lv2plug.in/ns/ext/parameters/parameters.h"
4245
#include "lv2/lv2plug.in/ns/ext/port-props/port-props.h"
4346

4447
#include "lilv/lilv.h"
@@ -185,6 +188,7 @@ class LV2Parser
185188
LilvNode* ext_causesArtifacts;
186189
LilvNode* ext_notAutomatic;
187190
LilvNode* lv2_enabled;
191+
LilvNode* lv2_requiredOption;
188192
LilvNode* lv2_InputPort;
189193
};
190194

@@ -237,6 +241,7 @@ LV2Parser::LV2Parser (RtkLv2Description* d, char const* const* bundles)
237241
ext_causesArtifacts = lilv_new_uri (world, LV2_PORT_PROPS__causesArtifacts);
238242
ext_notAutomatic = lilv_new_uri (world, LV2_PORT_PROPS__notAutomatic);
239243
lv2_enabled = lilv_new_uri (world, LV2_CORE_PREFIX "enabled");
244+
lv2_requiredOption = lilv_new_uri (world, LV2_OPTIONS__requiredOption);
240245
lv2_InputPort = lilv_new_uri (world, LILV_URI_INPUT_PORT);
241246
}
242247

@@ -261,6 +266,7 @@ LV2Parser::~LV2Parser ()
261266
lilv_node_free (ext_causesArtifacts);
262267
lilv_node_free (ext_notAutomatic);
263268
lilv_node_free (lv2_enabled);
269+
lilv_node_free (lv2_requiredOption);
264270
lilv_node_free (lv2_InputPort);
265271
lilv_world_free (world);
266272
}
@@ -348,6 +354,29 @@ int LV2Parser::parse (const char* plugin_uri)
348354
return err;
349355
}
350356

357+
uri = lilv_new_uri (world, plugin_uri);
358+
LilvNodes* options = lilv_world_find_nodes (world, uri, lv2_requiredOption, NULL);
359+
if (options) {
360+
LILV_FOREACH(nodes, i, options) {
361+
const char* ro = lilv_node_as_uri (lilv_nodes_get (options, i));
362+
bool ok = false;
363+
if (!strcmp (ro, LV2_PARAMETERS__sampleRate)) { ok = true; }
364+
if (!strcmp (ro, LV2_BUF_SIZE__minBlockLength)) { ok = true; }
365+
if (!strcmp (ro, LV2_BUF_SIZE__maxBlockLength)) { ok = true; }
366+
if (!strcmp (ro, LV2_BUF_SIZE__sequenceSize)) { ok = true; }
367+
if (!ok) {
368+
fprintf (stderr, "Unsupported required option: '%s' in '%s'\n", ro, plugin_uri);
369+
err = 1;
370+
}
371+
}
372+
}
373+
lilv_node_free (uri);
374+
lilv_nodes_free(options);
375+
376+
if (err) {
377+
return err;
378+
}
379+
351380
LilvUIs* uis = lilv_plugin_get_uis (p);
352381
#ifdef _WIN32
353382
static const char* suppored_ui = LV2_UI__WindowsUI;

0 commit comments

Comments
 (0)