From: Good Guy Date: Tue, 28 Sep 2021 21:04:01 +0000 (-0600) Subject: MatN mods to fix LV2 better and prevent crashes at startup X-Git-Tag: 2021-09~1 X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=a7449f690c376b598d56ace484c6449c95acc7de;p=goodguy%2Fcinelerra.git MatN mods to fix LV2 better and prevent crashes at startup --- diff --git a/cinelerra-5.1/cinelerra/pluginlv2.C b/cinelerra-5.1/cinelerra/pluginlv2.C index c6ef09cb..538e533c 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2.C +++ b/cinelerra-5.1/cinelerra/pluginlv2.C @@ -170,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)); @@ -209,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); @@ -222,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; } diff --git a/cinelerra-5.1/cinelerra/pluginlv2client.C b/cinelerra-5.1/cinelerra/pluginlv2client.C index 6c5e468b..fcb60404 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2client.C +++ b/cinelerra-5.1/cinelerra/pluginlv2client.C @@ -383,7 +383,7 @@ PluginClient *PluginServer::new_lv2_plugin() { PluginLV2Client *client = new PluginLV2Client(this); if( client->load_lv2(path, client->title) ) { delete client; return client = 0; } - client->init_lv2(); + if( client->init_lv2() ) { delete client; return client = 0; }; return client; } @@ -400,12 +400,19 @@ int MWindow::init_lv2_index(MWindow *mwindow, Preferences *preferences, FILE *fp const LilvPlugin *lilv = lilv_plugins_get(all_plugins, i); const char *uri = lilv_node_as_uri(lilv_plugin_get_uri(lilv)); if( blacklist.is_badboy(uri) ) continue; -printf("LOAD: %s\n", uri); +// TODO It would be nice to print the full path of this particular plugin +// in case it fails, because the systems' LV2 path might include multiple +// directories. But function lilv_uri_to_path does not like the uri. + +// Don't print the newline, so called functions can concatenate their +// error to the name. + printf("LOAD: %s ", uri); PluginServer server(mwindow, uri, PLUGIN_TYPE_LV2); int result = server.open_plugin(1, preferences, 0, 0); if( !result ) { server.write_table(fp, uri, PLUGIN_LV2_ID, 0); server.close_plugin(); + printf(" \n"); } } diff --git a/cinelerra-5.1/cinelerra/pluginlv2ui.C b/cinelerra-5.1/cinelerra/pluginlv2ui.C index 80bf250f..2b0c9926 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2ui.C +++ b/cinelerra-5.1/cinelerra/pluginlv2ui.C @@ -168,28 +168,7 @@ void PluginLV2ChildUI::start_gui() update_lv2_input(config.ctls, 1); connect_ports(config, PORTS_CONTROL | PORTS_ATOM); int n = 0; -#if 1 -// some plugins must have pointers, or they crash - float inp[nb_inputs], out[nb_outputs]; - memset(&inp, 0, nb_inputs*sizeof(float)); - memset(&out, 0, nb_outputs*sizeof(float)); - int ich = 0, och = 0; - for( int i=0; i