X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fpluginlv2.h;h=913caed068b44e2fcf35616a2b0234a5575877c4;hp=9b449b48ab44e3d9f324fbd1457043f7cc79bcaf;hb=7e5a0760f40ff787cc3d93cb7768a901ebe52809;hpb=803cf48f8f7ee246eb5473e55fc2125e8b398250 diff --git a/cinelerra-5.1/cinelerra/pluginlv2.h b/cinelerra-5.1/cinelerra/pluginlv2.h index 9b449b48..913caed0 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2.h +++ b/cinelerra-5.1/cinelerra/pluginlv2.h @@ -15,10 +15,37 @@ typedef struct { int nb_inputs, nb_outputs; } shm_bfr_t; -#define TYP_AUDIO 1 -#define TYP_CONTROL 2 -#define TYP_ATOM 4 -#define TYP_ALL ~0 +#define PORTS_AUDIO 0x01 +#define PORTS_CONTROL 0x02 +#define PORTS_ATOM 0x04 +#define PORTS_ALL (PORTS_AUDIO | PORTS_CONTROL | PORTS_ATOM) +#define PORTS_INPUT 0x08 +#define PORTS_OUTPUT 0x10 +#define PORTS_UPDATE 0x20 + +class PluginLV2Options : public ArrayList +{ +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 { @@ -35,11 +62,14 @@ public: void reset_lv2(); int load_lv2(const char *path,char *title=0); - int init_lv2(PluginLV2ClientConfig &conf, int sample_rate); + int init_lv2(PluginLV2ClientConfig &conf, int sample_rate, int bfrsz); + 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); - void connect_ports(PluginLV2ClientConfig &conf, int typ=TYP_ALL); + 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); shm_bfr_t *shm_buffer(int shmid); @@ -50,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; @@ -74,10 +109,41 @@ 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; -typedef struct { int idx; float value; } control_bfr_t; +typedef struct { int sample_rate, bfrsz; char path[1]; } open_bfr_t; enum { NO_COMMAND, LV2_OPEN, @@ -85,7 +151,6 @@ enum { NO_COMMAND, LV2_UPDATE, LV2_SHOW, LV2_HIDE, - LV2_SET, LV2_SHMID, NB_COMMANDS };