MatN mods to fix LV2 better and prevent crashes at startup
authorGood Guy <good1.2guy@gmail.com>
Tue, 28 Sep 2021 21:04:01 +0000 (15:04 -0600)
committerGood Guy <good1.2guy@gmail.com>
Tue, 28 Sep 2021 21:04:01 +0000 (15:04 -0600)
cinelerra-5.1/cinelerra/pluginlv2.C
cinelerra-5.1/cinelerra/pluginlv2client.C
cinelerra-5.1/cinelerra/pluginlv2ui.C
cinelerra-5.1/guicast/bootstrap.c
cinelerra-5.1/lv2_blacklist.txt

index c6ef09cbe2125257a6dc07c004b9402f11b750fd..538e533c33550e0c68b0d367f0d20a3b4bdc0c03 100644 (file)
@@ -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;
 }
 
index 6c5e468b0380f06af03fe67aa053e1e985efa0bf..fcb604046ee4c160d9f45de1722e2059c63ae8c7 100644 (file)
@@ -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");
                }
        }
 
index 80bf250f1e2c7921c8ac23c9ac2fc1bb8f46deab..2b0c9926bf65034d9fc7898e8c63138eab7af25f 100644 (file)
@@ -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<config.nb_ports; ++i ) {
-               const LilvPort *lp = lilv_plugin_get_port_by_index(lilv, i);
-               if( !lp ) continue;
-               int port = config.ports[i];
-               if( !(port & PORTS_AUDIO) ) continue;
-               if( (port & PORTS_INPUT) ) {
-                       lilv_instance_connect_port(inst, i, &inp[ich++]);
-                       continue;
-               }
-               if( (port & PORTS_OUTPUT) ) {
-                       lilv_instance_connect_port(inst, i, &out[och++]);
-                       continue;
-               }
-       }
-       n = 1;
-#endif
+
        updates = 0;
        run_lilv(n);
        if( gui ) {
index a697492be44f9566ba7be05b5a32766dce787725..0ba35514ea67be66418571ae268d7cd3335493cf 100644 (file)
@@ -71,7 +71,9 @@ int main(int argc, char *argv[])
        char temp_path[1024];
        char out_path[1024];
        char *ptr;
-       char system_command[1024];
+// TODO 2100 to get rid of compiler warning, but better solution needed:
+// temp_path and out_path parsing have potential buffer overflow.
+       char system_command[2100];   
        int current_arg = 1;
        int binary_mode = 0;
        int string_mode = 0;
index 66f1dde5f9fc3f4766589f86392d6f942160b02c..ecd3f7c60d67b9280239e68668290b4dd4285af0 100644 (file)
@@ -1,4 +1,4 @@
-# last updated 2021/09/08 MatN/pys
+# last updated 2021/09/28 MatN/andrea/pys/gg
 http:*midi*
 http:*MIDI*
 
@@ -42,6 +42,8 @@ http://plugin.org.uk/swh-plugins/buttlow_iir
 http://plugin.org.uk/swh-plugins/bwxover_iir
 http://plugin.org.uk/swh-plugins/highpass_iir
 http://plugin.org.uk/swh-plugins/lowpass_iir
+http://plugin.org.uk/swh-plugins/mbeq
+http://plugin.org.uk/swh-plugins/pitchScaleHQ
 #
 # Problematic 9 tested by Olivier Humbert (https://librazik.tuxfamily.org/)
 #
@@ -74,11 +76,10 @@ http://rakarrack.sourceforge.net/effects.html#har_no_mid
 http://yoshimi.sourceforge.net/lv2_plugin
 http://yoshimi.sourceforge.net/lv2_plugin_multi
 urn:juced:DrumSynth
+
+# 20210928 MatN
+# This Calf plugin somewhere internally uses fluidsynth and
+# gives several "invalid argument" errors.
 #
-# Problematic 5 tested by MatN as a result of Ardour new LV2 plugins
-#
-urn:ardour:a-comp
-urn:ardour:a-comp#stereo
-urn:ardour:a-exp
-urn:ardour:a-exp#stereo
-urn:ardour:a-fluidsynth
+http://calf.sourceforge.net/plugins/Vinyl
+