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; }
67 static uint32_t map_uri(LV2_URID_Map_Handle handle, const char *uri);
68 static const char *unmap_uri(LV2_URID_Unmap_Handle handle, LV2_URID urid);
70 LV2_URID_Unmap uri_unmap;
71 void connect_ports(PluginLV2ClientConfig &conf, int ports);
73 void new_buffer(int64_t sz);
74 shm_bfr_t *shm_buffer(int shmid);
75 void init_buffer(int samples);
79 const LilvPlugin *lilv;
82 PluginLV2UriTable uri_table;
84 LV2_Feature map_feature;
86 LV2_Feature unmap_feature;
88 PluginLV2Options options;
90 LV2_Atom_Sequence seq_in[2];
91 LV2_Atom_Sequence *seq_out;
92 float samplerate, refreshrate;
93 int min_block_length, block_length;
100 LilvNode *atom_AtomPort;
101 LilvNode *atom_Sequence;
102 LilvNode *lv2_AudioPort;
103 LilvNode *lv2_CVPort;
104 LilvNode *lv2_ControlPort;
105 LilvNode *lv2_Optional;
106 LilvNode *lv2_InputPort;
107 LilvNode *lv2_OutputPort;
108 LilvNode *powerOf2BlockLength;
109 LilvNode *fixedBlockLength;
110 LilvNode *boundedBlockLength;
115 LV2_URID param_sampleRate;
116 LV2_URID bufsz_minBlockLength;
117 LV2_URID bufsz_maxBlockLength;
118 LV2_URID bufsz_sequenceSize;
119 LV2_URID ui_updateRate;
121 pthread_t worker_thread;
122 LV2_Worker_Interface *worker_iface;
123 static void *worker_func(void *vp);
127 LV2_Worker_Status worker_schedule(uint32_t inp_size, const void *inp_data);
128 static LV2_Worker_Status lv2_worker_schedule(LV2_Worker_Schedule_Handle vp,
129 uint32_t inp_size, const void *inp_data);
130 LV2_Worker_Status worker_respond(uint32_t out_size, const void *out_data);
131 static LV2_Worker_Status lv2_worker_respond(LV2_Worker_Respond_Handle vp,
132 uint32_t out_size, const void *out_data);
133 PluginLV2Work *get_work();
134 void work_stop(PluginLV2Work *&work);
135 void worker_responses();
137 LV2_Worker_Schedule schedule;
138 PluginLV2Work *work_avail, *work_input;
139 PluginLV2Work *work_output, **work_tail;
140 pthread_mutex_t startup_lock, worker_lock;
141 pthread_cond_t worker_ready;
145 typedef struct { int sample_rate, bfrsz; char path[1]; } open_bfr_t;