X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.0%2Fcinelerra%2Fpluginserver.C;h=609710276599b8cb0de1439e9db02ab810f670ff;hb=c0b71a7151437c681fe832d1e446924a49ab29aa;hp=66abd3bd87364c8ae9eb57755bcec0ce4a4dfc7c;hpb=a3a59f63fdfbcf94c561595f515951fdfd4bea30;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.0/cinelerra/pluginserver.C b/cinelerra-5.0/cinelerra/pluginserver.C index 66abd3bd..60971027 100644 --- a/cinelerra-5.0/cinelerra/pluginserver.C +++ b/cinelerra-5.0/cinelerra/pluginserver.C @@ -74,6 +74,7 @@ void PluginServer::init() { reset_parameters(); this->plugin_type = PLUGIN_TYPE_UNKNOWN; + plugin_obj = new PluginObj(); modules = new ArrayList; nodes = new ArrayList; } @@ -101,6 +102,8 @@ PluginServer::PluginServer(PluginServer &that) { reset_parameters(); plugin_type = that.plugin_type; + plugin_obj = that.plugin_obj; + plugin_obj->add_user(); title = !that.title ? 0 : cstrdup(that.title); path = !that.path ? 0 : cstrdup(that.path); ff_name = !that.ff_name ? 0 : cstrdup(that.ff_name); @@ -135,6 +138,7 @@ PluginServer::~PluginServer() delete modules; delete nodes; delete picon; + plugin_obj->remove_user(); } // Done only once at creation @@ -146,7 +150,6 @@ int PluginServer::reset_parameters() cleanup_plugin(); autos = 0; edl = 0; - dlobj = 0; preferences = 0; title = 0; path = 0; @@ -265,34 +268,36 @@ void PluginServer::generate_display_title(char *string) strcpy(string, ltitle); } -void *PluginServer::load_obj() +void *PluginObj::load(const char *plugin_dir, const char *path) { - if( !dlobj ) { - char dlpath[BCTEXTLEN], *dp = dlpath; - char *cp = path; - if( *cp != '/' ) { - char *bp = preferences->plugin_dir; - while( *bp ) *dp++ = *bp++; - *dp++ = '/'; - } - while( *cp ) *dp++ = *cp++; - *dp = 0; - dlobj = load(dlpath); + char dlpath[BCTEXTLEN], *dp = dlpath; + const char *cp = path; + if( *cp != '/' ) { + const char *bp = plugin_dir; + while( *bp ) *dp++ = *bp++; + *dp++ = '/'; } - return dlobj; + while( *cp ) *dp++ = *cp++; + *dp = 0; + return dlobj = load(dlpath); +} + +int PluginServer::load_obj() +{ + void *obj = plugin_obj->obj(); + if( !obj ) obj =plugin_obj->load(preferences->plugin_dir, path); + return obj ? 1 : 0; } -void PluginServer::unload_obj() +const char *PluginServer::load_error() { - if( !dlobj ) return; - unload(dlobj); dlobj = 0; + return plugin_obj->load_error(); } -void PluginServer::delete_this() +void *PluginServer::get_sym(const char *sym) { - void *obj = dlobj; - delete this; - if( obj ) unload(obj); + if( !plugin_obj->obj() ) return 0; + return plugin_obj->load_sym(sym); } // Open plugin for signal processing @@ -313,25 +318,22 @@ int PluginServer::open_plugin(int master, char string[BCTEXTLEN]; strcpy(string, load_error()); if( !strstr(string, "executable") ) { - eprintf("PluginServer::open_plugin: load_obj failure = %s\n", string); + eprintf("PluginServer::open_plugin: load_obj %s = %s\n", path, string); return PLUGINSERVER_NOT_RECOGNIZED; } plugin_type = PLUGIN_TYPE_EXECUTABLE; } if( plugin_type == PLUGIN_TYPE_UNKNOWN || plugin_type == PLUGIN_TYPE_BUILTIN ) { new_plugin = - (PluginClient* (*)(PluginServer*)) load_sym("new_plugin"); + (PluginClient* (*)(PluginServer*)) get_sym("new_plugin"); if( new_plugin ) plugin_type = PLUGIN_TYPE_BUILTIN; } if( plugin_type == PLUGIN_TYPE_UNKNOWN || plugin_type == PLUGIN_TYPE_LADSPA ) { lad_descriptor_function = - (LADSPA_Descriptor_Function) load_sym("ladspa_descriptor"); + (LADSPA_Descriptor_Function) get_sym("ladspa_descriptor"); if( lad_descriptor_function ) { - if( lad_index < 0 ) { - unload_obj(); - return PLUGINSERVER_IS_LAD; - } + if( lad_index < 0 ) return PLUGINSERVER_IS_LAD; lad_descriptor = lad_descriptor_function(lad_index); if( !lad_descriptor ) return PLUGINSERVER_NOT_RECOGNIZED; @@ -341,7 +343,6 @@ int PluginServer::open_plugin(int master, if( plugin_type == PLUGIN_TYPE_UNKNOWN ) { fprintf(stderr, "PluginServer::open_plugin " " %d: plugin undefined in %s\n", __LINE__, path); - unload_obj(); return PLUGINSERVER_NOT_RECOGNIZED; } switch( plugin_type ) { @@ -443,8 +444,8 @@ int PluginServer::read_table(char *text) &plugin_type, path, title, &dir_idx, &audio, &video, &theme, &realtime, &fileio, &uses_gui, &multichannel, &synthesis, &transition, &lad_index); if( n != 14 ) return 1; - this->path = cstrdup(path); - this->title = cstrdup(title); + set_path(path); + set_title(title); return 0; } @@ -530,14 +531,19 @@ void PluginServer::process_buffer(VFrame **frame, vclient->input[i] = frame[i]; vclient->output[i] = frame[i]; } - vclient->source_start = (int64_t)(plugin ? - plugin->startproject * - frame_rate / - vclient->project_frame_rate : - 0); + + if(plugin) + { + vclient->source_start = (int64_t)plugin->startproject * + frame_rate / + vclient->project_frame_rate; + } vclient->direction = direction; +//PRINT_TRACE +//printf("plugin=%p source_start=%ld\n", plugin, vclient->source_start); + vclient->begin_process_buffer(); if(multichannel) { @@ -660,6 +666,10 @@ int PluginServer::get_parameters(int64_t start, int64_t end, int channels) client->source_start = start; client->total_len = end - start; client->total_in_buffers = channels; + +//PRINT_TRACE +//printf(" source_start=%ld total_len=%ld\n", client->source_start, client->total_len); + return client->plugin_get_parameters(); } @@ -802,6 +812,7 @@ int PluginServer::read_frame(VFrame *buffer, // If we're a VirtualNode, read_data in the virtual plugin node handles // backward propogation and produces the data. // If we're a Module, render in the module produces the data. +//PRINT_TRACE int result = -1; if(!multichannel) channel = 0; @@ -1219,16 +1230,17 @@ VFrame *PluginServer::get_plugin_images() if( st.st_size == 0 ) return 0; unsigned len = st.st_size; int ret = 0, w = 0, h = 0; - uint8_t *bfr = 0; + unsigned char *bfr = 0; int fd = ::open(png_path, O_RDONLY); if( fd < 0 ) ret = 1; if( !ret ) { - bfr = (uint8_t*) ::mmap (NULL, len, PROT_READ, MAP_SHARED, fd, 0); + bfr = (unsigned char *) ::mmap (NULL, len, PROT_READ, MAP_SHARED, fd, 0); if( bfr == MAP_FAILED ) ret = 1; } VFrame *vframe = 0; if( !ret ) { - vframe = new VFrame(bfr, st.st_size); + double scale = BC_WindowBase::get_resources()->icon_scale; + vframe = new VFramePng(bfr, st.st_size, scale, scale); if( (w=vframe->get_w()) <= 0 || (h=vframe->get_h()) <= 0 || vframe->get_data() == 0 ) ret = 1; }