add binfolder path relative filters, fix gbrp color model, vwdw timebar tweaks, title...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / pluginaclientlad.C
index 91c19275f7d47305762d2f4754ec94c3c6ca72cf..f1cbb45a317fa4dd82fa4fdb1cb655484878aa19 100644 (file)
 
 #include "clip.h"
 #include "bchash.h"
+#include "filesystem.h"
 #include "filexml.h"
 #include "language.h"
+#include "mwindow.h"
 #include "pluginaclientlad.h"
 #include "pluginserver.h"
 #include "samples.h"
@@ -69,8 +71,13 @@ int PluginAClientConfig::equivalent(PluginAClientConfig &that)
 // Need PluginServer to do this.
 void PluginAClientConfig::copy_from(PluginAClientConfig &that)
 {
-       int n = bmin(total_ports, that.total_ports);
-       for( int i=0; i<n; ++i ) {
+       if( total_ports != that.total_ports ) {
+               delete_objects();
+               total_ports = that.total_ports;
+               port_data = new LADSPA_Data[total_ports];
+               port_type = new int[total_ports];
+       }
+       for( int i=0; i<total_ports; ++i ) {
                port_type[i] = that.port_type[i];
                port_data[i] = that.port_data[i];
        }
@@ -348,6 +355,7 @@ PluginAClientLAD::PluginAClientLAD(PluginServer *server)
        total_outbuffers = 0;
        buffer_allocation = 0;
        lad_instance = 0;
+       snprintf(title, sizeof(title), "L_%s", server->lad_descriptor->Name);
 }
 
 PluginAClientLAD::~PluginAClientLAD()
@@ -400,7 +408,7 @@ int PluginAClientLAD::get_outchannels()
 
 const char* PluginAClientLAD::plugin_title()
 {
-       return (char*)server->lad_descriptor->Name;
+       return title;
 }
 
 int PluginAClientLAD::uses_gui()
@@ -499,12 +507,14 @@ void PluginAClientLAD::read_data(KeyFrame *keyframe)
 
 void PluginAClientLAD::delete_buffers()
 {
-       if(in_buffers)
-               for(int i = 0; i < total_inbuffers; i++) delete [] in_buffers[i];
-       if(out_buffers)
-               for(int i = 0; i < total_outbuffers; i++) delete [] out_buffers[i];
-       in_buffers = 0;
-       out_buffers = 0;
+       if( in_buffers ) {
+               for( int i=0; i<total_inbuffers; ++i ) delete [] in_buffers[i];
+               delete [] in_buffers;  in_buffers = 0;
+       }
+       if( out_buffers ) {
+               for( int i=0; i<total_outbuffers; ++i ) delete [] out_buffers[i];
+               delete [] out_buffers;  out_buffers = 0;
+       }
        total_inbuffers = 0;
        total_outbuffers = 0;
        buffer_allocation = 0;
@@ -644,5 +654,15 @@ int PluginAClientLAD::process_realtime(int64_t size,
        return size;
 }
 
-
+int MWindow::init_ladspa_index(MWindow *mwindow, Preferences *preferences,
+       FILE *fp, const char *plugin_dir)
+{
+       char plugin_path[BCTEXTLEN], *path = FileSystem::basepath(plugin_dir);
+       strcpy(plugin_path, path);  delete [] path;
+       printf("init ladspa index: %s\n", plugin_dir);
+       fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
+       fprintf(fp, "%s\n", plugin_dir);
+       init_plugin_index(mwindow, preferences, fp, plugin_path);
+       return 0;
+}