lv2 phase 2 fixups
[goodguy/history.git] / cinelerra-5.1 / cinelerra / pluginlv2.h
index 01fc461f94baa8f61f9d701c05dd2602b3cf5a42..9cd516a084e8fa4c2ac3f39e1b6dbba854823ee4 100644 (file)
@@ -23,6 +23,30 @@ typedef struct {
 #define PORTS_OUTPUT  0x10
 #define PORTS_UPDATE  0x20
 
+class PluginLV2Options : public ArrayList<LV2_Options_Option>
+{
+public:
+       PluginLV2Options() {}
+       ~PluginLV2Options() {}
+       void add(LV2_URID key, unsigned sz, LV2_URID typ, void *vp) {
+               LV2_Options_Option *ap = &append();
+               ap->context = LV2_OPTIONS_INSTANCE; ap->subject = 0;
+               ap->key = key; ap->size = sz; ap->type = typ; ap->value = vp;
+       }
+};
+
+class PluginLV2Work
+{
+public:
+       PluginLV2Work();
+       ~PluginLV2Work();
+       void load(const void *vp, unsigned size);
+
+       PluginLV2Work *next;
+       unsigned alloc, used;
+       char *data;
+};
+
 class PluginLV2
 {
 public:
@@ -39,9 +63,12 @@ public:
        void reset_lv2();
        int load_lv2(const char *path,char *title=0);
        int init_lv2(PluginLV2ClientConfig &conf, int sample_rate);
+       virtual int is_forked() { return 0; }
 
        static LV2_URID uri_table_map(LV2_URID_Map_Handle handle, const char *uri);
        static const char *uri_table_unmap(LV2_URID_Map_Handle handle, LV2_URID urid);
+       static uint32_t uri_to_id(LV2_URI_Map_Callback_Data callback_data,
+                       const char *map, const char *uri);
        void connect_ports(PluginLV2ClientConfig &conf, int ports);
        void del_buffer();
        void new_buffer(int64_t sz);
@@ -53,14 +80,19 @@ public:
        const LilvPlugin  *lilv;
        LilvUIs           *lilv_uis;
 
+       LV2_URI_Map_Feature uri_map;
        PluginLV2UriTable  uri_table;
        LV2_URID_Map       map;
        LV2_Feature        map_feature;
        LV2_URID_Unmap     unmap;
        LV2_Feature        unmap_feature;
+
+       PluginLV2Options   options;
        Lv2Features        features;
        LV2_Atom_Sequence  seq_in[2];
        LV2_Atom_Sequence  *seq_out;
+       float samplerate, refreshrate;
+       int block_length, midi_buf_size;
 
        LilvInstance *inst;
        SuilInstance *sinst;
@@ -77,6 +109,38 @@ public:
        LilvNode *powerOf2BlockLength;
        LilvNode *fixedBlockLength;
        LilvNode *boundedBlockLength;
+
+       LV2_URID atom_int;
+       LV2_URID atom_float;
+
+       LV2_URID param_sampleRate;
+       LV2_URID bufsz_minBlockLength;
+       LV2_URID bufsz_maxBlockLength;
+       LV2_URID bufsz_sequenceSize;
+       LV2_URID ui_updateRate;
+
+       pthread_t worker_thread;
+       LV2_Worker_Interface *worker_iface;
+       static void *worker_func(void *vp);
+       void *worker_func();
+       void worker_start();
+       void worker_stop();
+       LV2_Worker_Status worker_schedule(uint32_t inp_size, const void *inp_data);
+       static LV2_Worker_Status lv2_worker_schedule(LV2_Worker_Schedule_Handle vp,
+                       uint32_t inp_size, const void *inp_data);
+       LV2_Worker_Status worker_respond(uint32_t out_size, const void *out_data);
+       static LV2_Worker_Status lv2_worker_respond(LV2_Worker_Respond_Handle vp,
+                       uint32_t out_size, const void *out_data);
+       PluginLV2Work *get_work();
+       void work_stop(PluginLV2Work *&work);
+       void worker_responses();
+
+       LV2_Worker_Schedule schedule;
+       PluginLV2Work *work_avail, *work_input;
+       PluginLV2Work *work_output, **work_tail;
+       pthread_mutex_t worker_lock;
+       pthread_cond_t worker_ready;
+       int worker_done;
 };
 
 typedef struct { int sample_rate;  char path[1]; } open_bfr_t;