X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fpluginlv2.C;h=538e533c33550e0c68b0d367f0d20a3b4bdc0c03;hb=afc97a7cc7560ff3220da1f6f02e9bc372755e86;hp=7b7dc678e717b2dd1578bfb3f4f3cad2092852e4;hpb=a70cf593410cada9f0ca8bc515534c635a9cb495;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/pluginlv2.C b/cinelerra-5.1/cinelerra/pluginlv2.C index 7b7dc678..538e533c 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2.C +++ b/cinelerra-5.1/cinelerra/pluginlv2.C @@ -52,6 +52,8 @@ PluginLV2::PluginLV2() schedule.schedule_work = lv2_worker_schedule; worker_iface = 0; worker_done = -1; pthread_mutex_init(&worker_lock, 0); + pthread_mutex_init(&startup_lock, 0); + pthread_mutex_lock(&startup_lock); pthread_cond_init(&worker_ready, 0); work_avail = 0; work_input = 0; work_output = 0; work_tail = &work_output; @@ -168,6 +170,12 @@ int PluginLV2::init_lv2(PluginLV2ClientConfig &conf, int sample_rate, int bfrsz) } } + if( !nb_inputs || !nb_outputs ) { + printf(": Unsupported lv2 plugin, missing audio input or output\n"); + reset_lv2(); + return 1; + } + uri_map.handle = (LV2_URID_Map_Handle)this; uri_map.map = map_uri; features.append(new Lv2Feature(LV2_URID__map, &uri_map)); @@ -207,7 +215,15 @@ int PluginLV2::init_lv2(PluginLV2ClientConfig &conf, int sample_rate, int bfrsz) printf("lv2: lilv_plugin_instantiate failed\n"); return 1; } + +// After instantiate, some plugins require fields to be filled in before +// activate is called. This is done via ConnectPort, which connects a +// port to a data structure in the host (CinGG). So these have to be +// allocated first. + init_buffer(bfrsz); + connect_ports(conf, PORTS_ALL); + const LV2_Descriptor *lilv_desc = inst->lv2_descriptor; worker_iface = !lilv_desc->extension_data ? 0 : (LV2_Worker_Interface*)lilv_desc->extension_data(LV2_WORKER__interface); @@ -220,7 +236,7 @@ int PluginLV2::init_lv2(PluginLV2ClientConfig &conf, int sample_rate, int bfrsz) (lilv_plugin_has_feature(lilv, powerOf2BlockLength) || lilv_plugin_has_feature(lilv, fixedBlockLength) || lilv_plugin_has_feature(lilv, boundedBlockLength)) ? 4096 : 0; - init_buffer(bfrsz); + return 0; } @@ -417,6 +433,7 @@ PluginLV2Work *PluginLV2::get_work() void *PluginLV2::worker_func() { pthread_mutex_lock(&worker_lock); + pthread_mutex_unlock(&startup_lock); for(;;) { while( !worker_done && !work_input ) pthread_cond_wait(&worker_ready, &worker_lock); @@ -440,6 +457,7 @@ void *PluginLV2::worker_func(void* vp) void PluginLV2::worker_start() { pthread_create(&worker_thread, 0, worker_func, this); + pthread_mutex_lock(&startup_lock); } void PluginLV2::worker_stop()