1 #ifndef __PLUGINLV2_H__
2 #define __PLUGINLV2_H__
4 #define LV2_SEQ_SIZE 9624
6 #include "pluginlv2config.h"
10 #define NS_EXT "http://lv2plug.in/ns/ext/"
15 int nb_inputs, nb_outputs;
18 #define PORTS_AUDIO 0x01
19 #define PORTS_CONTROL 0x02
20 #define PORTS_ATOM 0x04
21 #define PORTS_ALL (PORTS_AUDIO | PORTS_CONTROL | PORTS_ATOM)
22 #define PORTS_INPUT 0x08
23 #define PORTS_OUTPUT 0x10
24 #define PORTS_UPDATE 0x20
26 class PluginLV2Options : public ArrayList<LV2_Options_Option>
30 ~PluginLV2Options() {}
31 void add(LV2_URID key, unsigned sz, LV2_URID typ, void *vp) {
32 LV2_Options_Option *ap = &append();
33 ap->context = LV2_OPTIONS_INSTANCE; ap->subject = 0;
34 ap->key = key; ap->size = sz; ap->type = typ; ap->value = vp;
43 void load(const void *vp, unsigned size);
58 float **in_buffers, **out_buffers;
60 int nb_inputs, nb_outputs;
61 int max_bufsz, ui_features;
64 int load_lv2(const char *path,char *title=0);
65 int init_lv2(PluginLV2ClientConfig &conf, int sample_rate, int bfrsz);
66 virtual int is_forked() { return 0; }
68 static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri);
69 static const char *uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid);
70 static uint32_t uri_to_id(LV2_URI_Map_Callback_Data callback_data,
71 const char *map, const char *uri);
72 void connect_ports(PluginLV2ClientConfig &conf, int ports);
74 void new_buffer(int64_t sz);
75 shm_bfr_t *shm_buffer(int shmid);
76 void init_buffer(int samples);
80 const LilvPlugin *lilv;
83 LV2_URI_Map_Feature uri_map;
84 PluginLV2UriTable uri_table;
86 LV2_Feature map_feature;
88 LV2_Feature unmap_feature;
90 PluginLV2Options options;
92 LV2_Atom_Sequence seq_in[2];
93 LV2_Atom_Sequence *seq_out;
94 float samplerate, refreshrate;
95 int block_length, midi_buf_size;
101 LilvNode *atom_AtomPort;
102 LilvNode *atom_Sequence;
103 LilvNode *lv2_AudioPort;
104 LilvNode *lv2_CVPort;
105 LilvNode *lv2_ControlPort;
106 LilvNode *lv2_Optional;
107 LilvNode *lv2_InputPort;
108 LilvNode *lv2_OutputPort;
109 LilvNode *powerOf2BlockLength;
110 LilvNode *fixedBlockLength;
111 LilvNode *boundedBlockLength;
116 LV2_URID param_sampleRate;
117 LV2_URID bufsz_minBlockLength;
118 LV2_URID bufsz_maxBlockLength;
119 LV2_URID bufsz_sequenceSize;
120 LV2_URID ui_updateRate;
122 pthread_t worker_thread;
123 LV2_Worker_Interface *worker_iface;
124 static void *worker_func(void *vp);
128 LV2_Worker_Status worker_schedule(uint32_t inp_size, const void *inp_data);
129 static LV2_Worker_Status lv2_worker_schedule(LV2_Worker_Schedule_Handle vp,
130 uint32_t inp_size, const void *inp_data);
131 LV2_Worker_Status worker_respond(uint32_t out_size, const void *out_data);
132 static LV2_Worker_Status lv2_worker_respond(LV2_Worker_Respond_Handle vp,
133 uint32_t out_size, const void *out_data);
134 PluginLV2Work *get_work();
135 void work_stop(PluginLV2Work *&work);
136 void worker_responses();
138 LV2_Worker_Schedule schedule;
139 PluginLV2Work *work_avail, *work_input;
140 PluginLV2Work *work_output, **work_tail;
141 pthread_mutex_t worker_lock;
142 pthread_cond_t worker_ready;
146 typedef struct { int sample_rate, bfrsz; char path[1]; } open_bfr_t;