aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-09 23:07:48 +0000
committerDavid Robillard <d@drobilla.net>2012-04-09 23:07:48 +0000
commit34b66b65a9c212bc13d62fdfbfcd4be198141e0f (patch)
treee1b24e4386c2824fe178db505467218079145dc9
parent9ca650bafe893d3285c7e27d4e3447bf9921105b (diff)
downloadjalv-34b66b65a9c212bc13d62fdfbfcd4be198141e0f.tar.gz
jalv-34b66b65a9c212bc13d62fdfbfcd4be198141e0f.tar.bz2
jalv-34b66b65a9c212bc13d62fdfbfcd4be198141e0f.zip
More sensible URI node cacheing structure.
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@4153 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/jalv.c68
-rw-r--r--src/jalv_internal.h33
-rw-r--r--src/state.c4
3 files changed, 52 insertions, 53 deletions
diff --git a/src/jalv.c b/src/jalv.c
index d05a546..59c4839 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -37,6 +37,8 @@
#endif
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
+#include "lv2/lv2plug.in/ns/ext/event/event.h"
+#include "lv2/lv2plug.in/ns/ext/presets/presets.h"
#include "lv2/lv2plug.in/ns/ext/time/time.h"
#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
@@ -138,31 +140,31 @@ create_port(Jalv* host,
const bool optional = lilv_port_has_property(host->plugin,
port->lilv_port,
- host->optional);
+ host->nodes.lv2_connectionOptional);
/* Set the port flow (input or output) */
- if (lilv_port_is_a(host->plugin, port->lilv_port, host->input_class)) {
+ if (lilv_port_is_a(host->plugin, port->lilv_port, host->nodes.lv2_InputPort)) {
port->flow = FLOW_INPUT;
} else if (lilv_port_is_a(host->plugin, port->lilv_port,
- host->output_class)) {
+ host->nodes.lv2_OutputPort)) {
port->flow = FLOW_OUTPUT;
} else if (!optional) {
die("Mandatory port has unknown type (neither input nor output)");
}
/* Set control values */
- if (lilv_port_is_a(host->plugin, port->lilv_port, host->control_class)) {
+ if (lilv_port_is_a(host->plugin, port->lilv_port, host->nodes.lv2_ControlPort)) {
port->type = TYPE_CONTROL;
port->control = isnan(default_value) ? 0.0 : default_value;
} else if (lilv_port_is_a(host->plugin, port->lilv_port,
- host->audio_class)) {
+ host->nodes.lv2_AudioPort)) {
port->type = TYPE_AUDIO;
} else if (lilv_port_is_a(host->plugin, port->lilv_port,
- host->event_class)) {
+ host->nodes.ev_EventPort)) {
port->type = TYPE_EVENT;
port->old_api = true;
} else if (lilv_port_is_a(host->plugin, port->lilv_port,
- host->atom_port_class)) {
+ host->nodes.atom_AtomPort)) {
port->type = TYPE_EVENT;
port->old_api = false;
} else if (!optional) {
@@ -209,9 +211,9 @@ jalv_allocate_port_buffers(Jalv* jalv)
jalv->midi_buf_size,
port->old_api ? LV2_EVBUF_EVENT : LV2_EVBUF_ATOM,
jalv->map.map(jalv->map.handle,
- lilv_node_as_string(jalv->chunk_class)),
+ lilv_node_as_string(jalv->nodes.atom_Chunk)),
jalv->map.map(jalv->map.handle,
- lilv_node_as_string(jalv->seq_class)));
+ lilv_node_as_string(jalv->nodes.atom_Sequence)));
lilv_instance_connect_port(
jalv->instance, i, lv2_evbuf_get_buffer(port->evbuf));
default: break;
@@ -708,22 +710,21 @@ main(int argc, char** argv)
host.world = world;
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- /* Set up the port classes this app supports */
- host.input_class = lilv_new_uri(world, LILV_URI_INPUT_PORT);
- host.output_class = lilv_new_uri(world, LILV_URI_OUTPUT_PORT);
- host.control_class = lilv_new_uri(world, LILV_URI_CONTROL_PORT);
- host.audio_class = lilv_new_uri(world, LILV_URI_AUDIO_PORT);
- host.event_class = lilv_new_uri(world, LILV_URI_EVENT_PORT);
- host.chunk_class = lilv_new_uri(world, LV2_ATOM__Chunk);
- host.seq_class = lilv_new_uri(world, LV2_ATOM__Sequence);
- host.atom_port_class = lilv_new_uri(world, LV2_ATOM__AtomPort);
- host.midi_class = lilv_new_uri(world, LILV_URI_MIDI_EVENT);
- host.preset_class = lilv_new_uri(world, NS_PSET "Preset");
- host.label_pred = lilv_new_uri(world, LILV_NS_RDFS "label");
- host.work_interface = lilv_new_uri(world, LV2_WORKER__interface);
- host.work_schedule = lilv_new_uri(world, LV2_WORKER__schedule);
- host.optional = lilv_new_uri(world, LILV_NS_LV2
- "connectionOptional");
+ /* Cache URIs for concepts we'll use */
+ host.nodes.atom_AtomPort = lilv_new_uri(world, LV2_ATOM__AtomPort);
+ host.nodes.atom_Chunk = lilv_new_uri(world, LV2_ATOM__Chunk);
+ host.nodes.atom_Sequence = lilv_new_uri(world, LV2_ATOM__Sequence);
+ host.nodes.ev_EventPort = lilv_new_uri(world, LV2_EVENT__EventPort);
+ host.nodes.lv2_AudioPort = lilv_new_uri(world, LV2_CORE__AudioPort);
+ host.nodes.lv2_ControlPort = lilv_new_uri(world, LV2_CORE__ControlPort);
+ host.nodes.lv2_InputPort = lilv_new_uri(world, LV2_CORE__InputPort);
+ host.nodes.lv2_OutputPort = lilv_new_uri(world, LV2_CORE__OutputPort);
+ host.nodes.lv2_connectionOptional = lilv_new_uri(world, LV2_CORE__connectionOptional);
+ host.nodes.midi_MidiEvent = lilv_new_uri(world, LV2_MIDI__MidiEvent);
+ host.nodes.pset_Preset = lilv_new_uri(world, LV2_PRESETS__Preset);
+ host.nodes.rdfs_label = lilv_new_uri(world, LILV_NS_RDFS "label");
+ host.nodes.work_interface = lilv_new_uri(world, LV2_WORKER__interface);
+ host.nodes.work_schedule = lilv_new_uri(world, LV2_WORKER__schedule);
/* Get plugin URI from loaded state or command line */
LilvState* state = NULL;
@@ -850,8 +851,8 @@ main(int argc, char** argv)
}
/* Create thread and ringbuffers for worker if necessary */
- if (lilv_plugin_has_feature(host.plugin, host.work_schedule)
- && lilv_plugin_has_extension_data(host.plugin, host.work_interface)) {
+ if (lilv_plugin_has_feature(host.plugin, host.nodes.work_schedule)
+ && lilv_plugin_has_extension_data(host.plugin, host.nodes.work_interface)) {
jalv_worker_init(
&host, &host.worker,
(LV2_Worker_Interface*)lilv_instance_get_extension_data(
@@ -952,16 +953,9 @@ main(int argc, char** argv)
jack_ringbuffer_free(host.plugin_events);
}
lilv_node_free(native_ui_type);
- lilv_node_free(host.input_class);
- lilv_node_free(host.output_class);
- lilv_node_free(host.control_class);
- lilv_node_free(host.audio_class);
- lilv_node_free(host.event_class);
- lilv_node_free(host.midi_class);
- lilv_node_free(host.preset_class);
- lilv_node_free(host.label_pred);
- lilv_node_free(host.work_schedule);
- lilv_node_free(host.optional);
+ for (LilvNode** n = (LilvNode**)&host.nodes; *n; ++n) {
+ lilv_node_free(*n);
+ }
symap_free(host.symap);
suil_host_free(ui_host);
lilv_world_free(world);
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 2143f7b..f2b1b95 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -30,6 +30,7 @@
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "lv2/lv2plug.in/ns/ext/atom/forge.h"
#include "lv2/lv2plug.in/ns/ext/log/log.h"
+#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
#include "lv2/lv2plug.in/ns/ext/state/state.h"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
#include "lv2/lv2plug.in/ns/ext/worker/worker.h"
@@ -102,6 +103,23 @@ typedef struct {
LV2_URID time_speed;
} JalvURIDs;
+typedef struct {
+ LilvNode* atom_AtomPort;
+ LilvNode* atom_Chunk;
+ LilvNode* atom_Sequence;
+ LilvNode* ev_EventPort;
+ LilvNode* lv2_AudioPort;
+ LilvNode* lv2_ControlPort;
+ LilvNode* lv2_InputPort;
+ LilvNode* lv2_OutputPort;
+ LilvNode* lv2_connectionOptional;
+ LilvNode* midi_MidiEvent;
+ LilvNode* pset_Preset;
+ LilvNode* rdfs_label;
+ LilvNode* work_interface;
+ LilvNode* work_schedule;
+} JalvNodes;
+
typedef enum {
JALV_RUNNING,
JALV_PAUSE_REQUESTED,
@@ -120,6 +138,7 @@ typedef struct {
typedef struct {
JalvOptions opts; ///< Command-line options
JalvURIDs urids; ///< URIDs
+ JalvNodes nodes; ///< Nodes
LV2_Atom_Forge forge; ///< Atom forge
const char* prog_name; ///< Program name (argv[0])
LilvWorld* world; ///< Lilv World
@@ -147,20 +166,6 @@ typedef struct {
uint32_t longest_sym; ///< Longest port symbol
jack_nframes_t sample_rate; ///< Sample rate
jack_nframes_t event_delta_t; ///< Frames since last update sent to UI
- LilvNode* audio_class; ///< Audio port class (URI)
- LilvNode* chunk_class; ///< Atom sequence class (URI)
- LilvNode* control_class; ///< Control port class (URI)
- LilvNode* event_class; ///< Event port class (URI)
- LilvNode* input_class; ///< Input port class (URI)
- LilvNode* label_pred; ///< rdfs:label
- LilvNode* midi_class; ///< MIDI event class (URI)
- LilvNode* atom_port_class; ///< Atom event port class (URI)
- LilvNode* optional; ///< lv2:connectionOptional port property
- LilvNode* output_class; ///< Output port class (URI)
- LilvNode* preset_class; ///< Preset class (URI)
- LilvNode* seq_class; ///< Atom sequence class (URI)
- LilvNode* work_interface; ///< Worker interface (URI)
- LilvNode* work_schedule; ///< Worker schedule feature (URI)
uint32_t midi_event_id; ///< MIDI event class ID in event context
bool buf_size_set; ///< True iff buffer size callback fired
bool exit; ///< True if execution is finished
diff --git a/src/state.c b/src/state.c
index e738ef5..8c60776 100644
--- a/src/state.c
+++ b/src/state.c
@@ -102,12 +102,12 @@ int
jalv_load_presets(Jalv* jalv, PresetSink sink, void* data)
{
LilvNodes* presets = lilv_plugin_get_related(jalv->plugin,
- jalv->preset_class);
+ jalv->nodes.pset_Preset);
LILV_FOREACH(nodes, i, presets) {
const LilvNode* preset = lilv_nodes_get(presets, i);
lilv_world_load_resource(jalv->world, preset);
LilvNodes* labels = lilv_world_find_nodes(
- jalv->world, preset, jalv->label_pred, NULL);
+ jalv->world, preset, jalv->nodes.rdfs_label, NULL);
if (labels) {
const LilvNode* label = lilv_nodes_get_first(labels);
sink(jalv, preset, label, data);