Skip to content

Commit 456d5c2

Browse files
committed
Start split of lilv details into separate file
Signed-off-by: falkTX <falktx@falktx.com>
1 parent 59e6304 commit 456d5c2

3 files changed

Lines changed: 493 additions & 280 deletions

File tree

src/effects.c

Lines changed: 3 additions & 280 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,17 @@ typedef unsigned int uint;
7474

7575
/* LV2 and Lilv */
7676
#include <lilv/lilv.h>
77-
#include <lv2/atom/atom.h>
7877
#include <lv2/atom/forge.h>
7978
#include <lv2/buf-size/buf-size.h>
8079
#include <lv2/event/event.h>
8180
#include <lv2/log/log.h>
82-
#include <lv2/midi/midi.h>
8381
#include <lv2/options/options.h>
84-
#include <lv2/patch/patch.h>
85-
#include <lv2/parameters/parameters.h>
86-
#include <lv2/port-props/port-props.h>
87-
#include <lv2/presets/presets.h>
88-
#include <lv2/resize-port/resize-port.h>
8982
#include <lv2/state/state.h>
90-
#include <lv2/time/time.h>
9183
#include <lv2/urid/urid.h>
9284
#include <lv2/uri-map/uri-map.h>
9385
#include <lv2/worker/worker.h>
9486
#include "lv2/control-input-port-change-request.h"
9587
#include "lv2/control-port-state-update.h"
96-
#include "lv2/kxstudio-properties.h"
9788
#include "lv2/lv2-hmi.h"
9889
#include "lv2/mod-license.h"
9990

@@ -151,8 +142,6 @@ typedef struct {
151142
} LV2_State_Free_Path;
152143
#endif
153144

154-
#define LILV_NS_MOD "http://moddevices.com/ns/mod#"
155-
156145
// custom jack flag used for cv
157146
// needed because we prefer jack2 which doesn't have metadata yet
158147
#define JackPortIsControlVoltage 0x100
@@ -168,13 +157,12 @@ typedef struct {
168157

169158
/* Local */
170159
#include "effects.h"
160+
#include "lilv.h"
171161
#include "monitor.h"
172162
#include "socket.h"
173-
#include "uridmap.h"
174163
#include "lv2_evbuf.h"
175164
#include "worker.h"
176165
#include "state-paths.h"
177-
#include "symap.h"
178166
#include "monitor/monitor-client.h"
179167
#include "sha1/sha1.h"
180168
#include "rtmempool/list.h"
@@ -496,99 +484,6 @@ typedef struct EFFECT_T {
496484
#endif
497485
} effect_t;
498486

499-
typedef struct LILV_NODES_T {
500-
LilvNode *atom_port;
501-
LilvNode *audio;
502-
LilvNode *control;
503-
LilvNode *control_in;
504-
LilvNode *cv;
505-
LilvNode *default_;
506-
LilvNode *enabled;
507-
LilvNode *enumeration;
508-
LilvNode *event;
509-
LilvNode *freeWheeling;
510-
LilvNode *hmi_interface;
511-
LilvNode *input;
512-
LilvNode *integer;
513-
LilvNode *is_live;
514-
LilvNode *license_interface;
515-
LilvNode *logarithmic;
516-
LilvNode *maximum;
517-
LilvNode *midiEvent;
518-
LilvNode *minimum;
519-
LilvNode *minimumSize;
520-
LilvNode *mod_cvport;
521-
LilvNode *mod_default;
522-
LilvNode *mod_default_custom;
523-
LilvNode *mod_maximum;
524-
LilvNode *mod_minimum;
525-
LilvNode *noPreRun;
526-
LilvNode *options_interface;
527-
LilvNode *output;
528-
LilvNode *patch_readable;
529-
LilvNode *patch_writable;
530-
LilvNode *preferMomentaryOff;
531-
LilvNode *preferMomentaryOn;
532-
LilvNode *preset;
533-
LilvNode *rawMIDIClockAccess;
534-
LilvNode *rdfs_range;
535-
LilvNode *reset;
536-
LilvNode *sample_rate;
537-
LilvNode *state_interface;
538-
LilvNode *state_load_default_state;
539-
LilvNode *state_thread_safe_restore;
540-
LilvNode *timeBeatsPerBar;
541-
LilvNode *timeBeatsPerMinute;
542-
LilvNode *timePosition;
543-
LilvNode *timeSpeed;
544-
LilvNode *toggled;
545-
LilvNode *trigger;
546-
LilvNode *worker_interface;
547-
} lilv_nodes_t;
548-
549-
typedef struct URIDS_T {
550-
LV2_URID atom_Bool;
551-
LV2_URID atom_Double;
552-
LV2_URID atom_Float;
553-
LV2_URID atom_Int;
554-
LV2_URID atom_Long;
555-
LV2_URID atom_Object;
556-
LV2_URID atom_Path;
557-
LV2_URID atom_String;
558-
LV2_URID atom_Tuple;
559-
LV2_URID atom_URI;
560-
LV2_URID atom_Vector;
561-
LV2_URID atom_eventTransfer;
562-
LV2_URID bufsz_maxBlockLength;
563-
LV2_URID bufsz_minBlockLength;
564-
LV2_URID bufsz_nomimalBlockLength;
565-
LV2_URID bufsz_sequenceSize;
566-
LV2_URID jack_client;
567-
LV2_URID log_Error;
568-
LV2_URID log_Note;
569-
LV2_URID log_Trace;
570-
LV2_URID log_Warning;
571-
LV2_URID midi_MidiEvent;
572-
LV2_URID param_sampleRate;
573-
LV2_URID patch_Get;
574-
LV2_URID patch_Set;
575-
LV2_URID patch_property;
576-
LV2_URID patch_sequence;
577-
LV2_URID patch_value;
578-
LV2_URID time_Position;
579-
LV2_URID time_bar;
580-
LV2_URID time_barBeat;
581-
LV2_URID time_beat;
582-
LV2_URID time_beatUnit;
583-
LV2_URID time_beatsPerBar;
584-
LV2_URID time_beatsPerMinute;
585-
LV2_URID time_ticksPerBeat;
586-
LV2_URID time_frame;
587-
LV2_URID time_speed;
588-
LV2_URID threads_schedPolicy;
589-
LV2_URID threads_schedPriority;
590-
} urids_t;
591-
592487
typedef struct MIDI_CC_T {
593488
int8_t channel;
594489
uint8_t controller;
@@ -817,15 +712,7 @@ static uint64_t g_monotonic_frame_count = 0;
817712
// Used for the MIDI Beat Clock Slave
818713
static volatile uint64_t g_previous_midi_event_time = 0;
819714

820-
/* LV2 and Lilv */
821-
static LilvWorld *g_lv2_data;
822-
static const LilvPlugins *g_plugins;
823-
static char *g_lv2_scratch_dir;
824-
825715
/* Global features */
826-
static Symap* g_symap;
827-
static lilv_nodes_t g_lilv_nodes;
828-
static urids_t g_urids;
829716
#ifdef MOD_HMI_CONTROL_ENABLED
830717
static LV2_HMI_WidgetControl g_hmi_wc;
831718
#endif
@@ -4683,76 +4570,7 @@ int effects_init(void* client)
46834570
}
46844571
#endif
46854572

4686-
/* Load all LV2 data */
4687-
g_lv2_data = lilv_world_new();
4688-
#ifdef LILV_OPTION_OBJECT_INDEX
4689-
lilv_world_set_option(g_lv2_data, LILV_OPTION_OBJECT_INDEX, NULL);
4690-
#endif
4691-
lilv_world_load_all(g_lv2_data);
4692-
g_plugins = lilv_world_get_all_plugins(g_lv2_data);
4693-
4694-
/* Lilv Nodes initialization */
4695-
g_lilv_nodes.atom_port = lilv_new_uri(g_lv2_data, LV2_ATOM__AtomPort);
4696-
g_lilv_nodes.audio = lilv_new_uri(g_lv2_data, LILV_URI_AUDIO_PORT);
4697-
g_lilv_nodes.control = lilv_new_uri(g_lv2_data, LILV_URI_CONTROL_PORT);
4698-
g_lilv_nodes.control_in = lilv_new_uri(g_lv2_data, LV2_CORE__control);
4699-
g_lilv_nodes.cv = lilv_new_uri(g_lv2_data, LILV_URI_CV_PORT);
4700-
g_lilv_nodes.default_ = lilv_new_uri(g_lv2_data, LV2_CORE__default);
4701-
g_lilv_nodes.enabled = lilv_new_uri(g_lv2_data, LV2_CORE__enabled);
4702-
g_lilv_nodes.enumeration = lilv_new_uri(g_lv2_data, LV2_CORE__enumeration);
4703-
g_lilv_nodes.event = lilv_new_uri(g_lv2_data, LILV_URI_EVENT_PORT);
4704-
g_lilv_nodes.freeWheeling = lilv_new_uri(g_lv2_data, LV2_CORE__freeWheeling);
4705-
g_lilv_nodes.hmi_interface = lilv_new_uri(g_lv2_data, LV2_HMI__PluginNotification);
4706-
g_lilv_nodes.input = lilv_new_uri(g_lv2_data, LILV_URI_INPUT_PORT);
4707-
g_lilv_nodes.integer = lilv_new_uri(g_lv2_data, LV2_CORE__integer);
4708-
g_lilv_nodes.license_interface = lilv_new_uri(g_lv2_data, MOD_LICENSE__interface);
4709-
g_lilv_nodes.is_live = lilv_new_uri(g_lv2_data, LV2_CORE__isLive);
4710-
g_lilv_nodes.logarithmic = lilv_new_uri(g_lv2_data, LV2_PORT_PROPS__logarithmic);
4711-
g_lilv_nodes.maximum = lilv_new_uri(g_lv2_data, LV2_CORE__maximum);
4712-
g_lilv_nodes.midiEvent = lilv_new_uri(g_lv2_data, LV2_MIDI__MidiEvent);
4713-
g_lilv_nodes.minimum = lilv_new_uri(g_lv2_data, LV2_CORE__minimum);
4714-
g_lilv_nodes.minimumSize = lilv_new_uri(g_lv2_data, LV2_RESIZE_PORT__minimumSize);
4715-
g_lilv_nodes.mod_cvport = lilv_new_uri(g_lv2_data, LILV_NS_MOD "CVPort");
4716-
g_lilv_nodes.mod_default = lilv_new_uri(g_lv2_data, LILV_NS_MOD "default");
4717-
#if defined(_MOD_DEVICE_DUO)
4718-
g_lilv_nodes.mod_default_custom = lilv_new_uri(g_lv2_data, LILV_NS_MOD "default_duo");
4719-
#elif defined(_MOD_DEVICE_DUOX)
4720-
g_lilv_nodes.mod_default_custom = lilv_new_uri(g_lv2_data, LILV_NS_MOD "default_duox");
4721-
#elif defined(_MOD_DEVICE_DWARF)
4722-
g_lilv_nodes.mod_default_custom = lilv_new_uri(g_lv2_data, LILV_NS_MOD "default_dwarf");
4723-
#elif defined(_MOD_DEVICE_X86_64)
4724-
g_lilv_nodes.mod_default_custom = lilv_new_uri(g_lv2_data, LILV_NS_MOD "default_x64");
4725-
#else
4726-
g_lilv_nodes.mod_default_custom = NULL;
4727-
#endif
4728-
g_lilv_nodes.mod_maximum = lilv_new_uri(g_lv2_data, LILV_NS_MOD "maximum");
4729-
g_lilv_nodes.mod_minimum = lilv_new_uri(g_lv2_data, LILV_NS_MOD "minimum");
4730-
g_lilv_nodes.noPreRun = lilv_new_uri(g_lv2_data, "http://www.darkglass.com/lv2/ns#noPreRun");
4731-
g_lilv_nodes.options_interface = lilv_new_uri(g_lv2_data, LV2_OPTIONS__interface);
4732-
g_lilv_nodes.output = lilv_new_uri(g_lv2_data, LILV_URI_OUTPUT_PORT);
4733-
g_lilv_nodes.patch_writable = lilv_new_uri(g_lv2_data, LV2_PATCH__writable);
4734-
g_lilv_nodes.patch_readable = lilv_new_uri(g_lv2_data, LV2_PATCH__readable);
4735-
g_lilv_nodes.preferMomentaryOff = lilv_new_uri(g_lv2_data, LILV_NS_MOD "preferMomentaryOffByDefault");
4736-
g_lilv_nodes.preferMomentaryOn = lilv_new_uri(g_lv2_data, LILV_NS_MOD "preferMomentaryOnByDefault");
4737-
g_lilv_nodes.preset = lilv_new_uri(g_lv2_data, LV2_PRESETS__Preset);
4738-
g_lilv_nodes.rawMIDIClockAccess = lilv_new_uri(g_lv2_data, LILV_NS_MOD "rawMIDIClockAccess");
4739-
g_lilv_nodes.rdfs_range = lilv_new_uri(g_lv2_data, LILV_NS_RDFS "range");
4740-
g_lilv_nodes.reset = lilv_new_uri(g_lv2_data, LV2_KXSTUDIO_PROPERTIES__Reset);
4741-
g_lilv_nodes.sample_rate = lilv_new_uri(g_lv2_data, LV2_CORE__sampleRate);
4742-
g_lilv_nodes.state_interface = lilv_new_uri(g_lv2_data, LV2_STATE__interface);
4743-
g_lilv_nodes.state_load_default_state = lilv_new_uri(g_lv2_data, LV2_STATE__loadDefaultState);
4744-
g_lilv_nodes.state_thread_safe_restore = lilv_new_uri(g_lv2_data, LV2_STATE__threadSafeRestore);
4745-
g_lilv_nodes.timeBeatsPerBar = lilv_new_uri(g_lv2_data, LV2_TIME__beatsPerBar);
4746-
g_lilv_nodes.timeBeatsPerMinute = lilv_new_uri(g_lv2_data, LV2_TIME__beatsPerMinute);
4747-
g_lilv_nodes.timePosition = lilv_new_uri(g_lv2_data, LV2_TIME__Position);
4748-
g_lilv_nodes.timeSpeed = lilv_new_uri(g_lv2_data, LV2_TIME__speed);
4749-
g_lilv_nodes.toggled = lilv_new_uri(g_lv2_data, LV2_CORE__toggled);
4750-
g_lilv_nodes.trigger = lilv_new_uri(g_lv2_data, LV2_PORT_PROPS__trigger);
4751-
g_lilv_nodes.worker_interface = lilv_new_uri(g_lv2_data, LV2_WORKER__interface);
4752-
4753-
/* URI and URID Feature initialization */
4754-
urid_sem_init();
4755-
g_symap = symap_new();
4573+
lilv_init();
47564574

47574575
g_uri_map.callback_data = g_symap;
47584576
g_uri_map.uri_to_id = &uri_to_id;
@@ -4762,54 +4580,6 @@ int effects_init(void* client)
47624580
g_urid_unmap.handle = g_symap;
47634581
g_urid_unmap.unmap = id_to_urid;
47644582

4765-
g_urids.atom_Double = urid_to_id(g_symap, LV2_ATOM__Double);
4766-
g_urids.atom_Bool = urid_to_id(g_symap, LV2_ATOM__Bool);
4767-
g_urids.atom_Float = urid_to_id(g_symap, LV2_ATOM__Float);
4768-
g_urids.atom_Int = urid_to_id(g_symap, LV2_ATOM__Int);
4769-
g_urids.atom_Long = urid_to_id(g_symap, LV2_ATOM__Long);
4770-
g_urids.atom_Object = urid_to_id(g_symap, LV2_ATOM__Object);
4771-
g_urids.atom_Path = urid_to_id(g_symap, LV2_ATOM__Path);
4772-
g_urids.atom_String = urid_to_id(g_symap, LV2_ATOM__String);
4773-
g_urids.atom_Tuple = urid_to_id(g_symap, LV2_ATOM__Tuple);
4774-
g_urids.atom_URI = urid_to_id(g_symap, LV2_ATOM__URI);
4775-
g_urids.atom_Vector = urid_to_id(g_symap, LV2_ATOM__Vector);
4776-
g_urids.atom_eventTransfer = urid_to_id(g_symap, LV2_ATOM__eventTransfer);
4777-
4778-
g_urids.bufsz_maxBlockLength = urid_to_id(g_symap, LV2_BUF_SIZE__maxBlockLength);
4779-
g_urids.bufsz_minBlockLength = urid_to_id(g_symap, LV2_BUF_SIZE__minBlockLength);
4780-
g_urids.bufsz_nomimalBlockLength = urid_to_id(g_symap, LV2_BUF_SIZE__nominalBlockLength);
4781-
g_urids.bufsz_sequenceSize = urid_to_id(g_symap, LV2_BUF_SIZE__sequenceSize);
4782-
4783-
g_urids.jack_client = urid_to_id(g_symap, "http://jackaudio.org/metadata/client");
4784-
4785-
g_urids.log_Error = urid_to_id(g_symap, LV2_LOG__Error);
4786-
g_urids.log_Note = urid_to_id(g_symap, LV2_LOG__Note);
4787-
g_urids.log_Trace = urid_to_id(g_symap, LV2_LOG__Trace);
4788-
g_urids.log_Warning = urid_to_id(g_symap, LV2_LOG__Warning);
4789-
4790-
g_urids.midi_MidiEvent = urid_to_id(g_symap, LV2_MIDI__MidiEvent);
4791-
g_urids.param_sampleRate = urid_to_id(g_symap, LV2_PARAMETERS__sampleRate);
4792-
4793-
g_urids.patch_Get = urid_to_id(g_symap, LV2_PATCH__Get);
4794-
g_urids.patch_Set = urid_to_id(g_symap, LV2_PATCH__Set);
4795-
g_urids.patch_property = urid_to_id(g_symap, LV2_PATCH__property);
4796-
g_urids.patch_sequence = urid_to_id(g_symap, LV2_PATCH__sequenceNumber);
4797-
g_urids.patch_value = urid_to_id(g_symap, LV2_PATCH__value);
4798-
4799-
g_urids.time_Position = urid_to_id(g_symap, LV2_TIME__Position);
4800-
g_urids.time_bar = urid_to_id(g_symap, LV2_TIME__bar);
4801-
g_urids.time_barBeat = urid_to_id(g_symap, LV2_TIME__barBeat);
4802-
g_urids.time_beat = urid_to_id(g_symap, LV2_TIME__beat);
4803-
g_urids.time_beatUnit = urid_to_id(g_symap, LV2_TIME__beatUnit);
4804-
g_urids.time_beatsPerBar = urid_to_id(g_symap, LV2_TIME__beatsPerBar);
4805-
g_urids.time_beatsPerMinute = urid_to_id(g_symap, LV2_TIME__beatsPerMinute);
4806-
g_urids.time_ticksPerBeat = urid_to_id(g_symap, LV2_KXSTUDIO_PROPERTIES__TimePositionTicksPerBeat);
4807-
g_urids.time_frame = urid_to_id(g_symap, LV2_TIME__frame);
4808-
g_urids.time_speed = urid_to_id(g_symap, LV2_TIME__speed);
4809-
4810-
g_urids.threads_schedPolicy = urid_to_id(g_symap, "http://ardour.org/lv2/threads/#schedPolicy");
4811-
g_urids.threads_schedPriority = urid_to_id(g_symap, "http://ardour.org/lv2/threads/#schedPriority");
4812-
48134583
/* Options Feature initialization */
48144584
g_options[0].context = LV2_OPTIONS_INSTANCE;
48154585
g_options[0].subject = 0;
@@ -5052,54 +4822,7 @@ int effects_finish(int close_client)
50524822
if (g_capture_ports) jack_free(g_capture_ports);
50534823
if (g_playback_ports) jack_free(g_playback_ports);
50544824
if (close_client) jack_client_close(g_jack_global_client);
5055-
symap_free(g_symap);
5056-
lilv_node_free(g_lilv_nodes.atom_port);
5057-
lilv_node_free(g_lilv_nodes.audio);
5058-
lilv_node_free(g_lilv_nodes.control);
5059-
lilv_node_free(g_lilv_nodes.control_in);
5060-
lilv_node_free(g_lilv_nodes.cv);
5061-
lilv_node_free(g_lilv_nodes.default_);
5062-
lilv_node_free(g_lilv_nodes.enabled);
5063-
lilv_node_free(g_lilv_nodes.enumeration);
5064-
lilv_node_free(g_lilv_nodes.event);
5065-
lilv_node_free(g_lilv_nodes.freeWheeling);
5066-
lilv_node_free(g_lilv_nodes.hmi_interface);
5067-
lilv_node_free(g_lilv_nodes.input);
5068-
lilv_node_free(g_lilv_nodes.integer);
5069-
lilv_node_free(g_lilv_nodes.license_interface);
5070-
lilv_node_free(g_lilv_nodes.logarithmic);
5071-
lilv_node_free(g_lilv_nodes.is_live);
5072-
lilv_node_free(g_lilv_nodes.maximum);
5073-
lilv_node_free(g_lilv_nodes.midiEvent);
5074-
lilv_node_free(g_lilv_nodes.minimum);
5075-
lilv_node_free(g_lilv_nodes.minimumSize);
5076-
lilv_node_free(g_lilv_nodes.mod_cvport);
5077-
lilv_node_free(g_lilv_nodes.mod_default);
5078-
lilv_node_free(g_lilv_nodes.mod_default_custom);
5079-
lilv_node_free(g_lilv_nodes.mod_maximum);
5080-
lilv_node_free(g_lilv_nodes.mod_minimum);
5081-
lilv_node_free(g_lilv_nodes.noPreRun);
5082-
lilv_node_free(g_lilv_nodes.output);
5083-
lilv_node_free(g_lilv_nodes.patch_readable);
5084-
lilv_node_free(g_lilv_nodes.patch_writable);
5085-
lilv_node_free(g_lilv_nodes.preferMomentaryOff);
5086-
lilv_node_free(g_lilv_nodes.preferMomentaryOn);
5087-
lilv_node_free(g_lilv_nodes.preset);
5088-
lilv_node_free(g_lilv_nodes.rawMIDIClockAccess);
5089-
lilv_node_free(g_lilv_nodes.rdfs_range);
5090-
lilv_node_free(g_lilv_nodes.reset);
5091-
lilv_node_free(g_lilv_nodes.sample_rate);
5092-
lilv_node_free(g_lilv_nodes.state_interface);
5093-
lilv_node_free(g_lilv_nodes.state_load_default_state);
5094-
lilv_node_free(g_lilv_nodes.state_thread_safe_restore);
5095-
lilv_node_free(g_lilv_nodes.timeBeatsPerBar);
5096-
lilv_node_free(g_lilv_nodes.timeBeatsPerMinute);
5097-
lilv_node_free(g_lilv_nodes.timePosition);
5098-
lilv_node_free(g_lilv_nodes.timeSpeed);
5099-
lilv_node_free(g_lilv_nodes.toggled);
5100-
lilv_node_free(g_lilv_nodes.trigger);
5101-
lilv_node_free(g_lilv_nodes.worker_interface);
5102-
lilv_world_free(g_lv2_data);
4825+
lilv_cleanup();
51034826
rtsafe_memory_pool_destroy(g_rtsafe_mem_pool);
51044827
sem_destroy(&g_postevents_semaphore);
51054828
pthread_mutex_destroy(&g_rtsafe_mutex);

0 commit comments

Comments
 (0)