X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmwindow.C;h=9de65dba075855f78b5c4aa1234f471cbb4350d1;hp=56059c677d499b4414b576dda027a793b7e0953f;hb=cb73d14fe59acbe8eba0a62f4af26a23072201fa;hpb=f007a674187f11ab58a5aebfe1eec27a90398bcb diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 56059c67..9de65dba 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -210,7 +210,6 @@ MWindow::MWindow() strcpy(cin_lang,"en"); channeldb_buz = new ChannelDB; channeldb_v4l2jpeg = new ChannelDB; - //file_server = 0; plugin_guis = 0; dead_plugins = 0; keyframe_threads = 0; @@ -230,6 +229,7 @@ MWindow::MWindow() restart_status = 0; screens = 1; in_destructor = 0; + speed_edl = 0; } @@ -251,7 +251,7 @@ MWindow::~MWindow() commit_commercial(); if( commercials && !commercials->remove_user() ) commercials = 0; close_mixers(); - + if( speed_edl ) { speed_edl->remove_user(); speed_edl = 0; } // Save defaults for open plugins plugin_gui_lock->lock("MWindow::~MWindow"); for(int i = 0; i < plugin_guis->size(); i++) { @@ -318,7 +318,6 @@ MWindow::~MWindow() delete gwindow; gwindow = 0; delete cwindow; cwindow = 0; delete gui; gui = 0; - //delete file_server; file_server = 0; // reusable delete mainindexes; mainindexes = 0; delete mainprogress; mainprogress = 0; delete audio_cache; audio_cache = 0; // delete the cache after the assets @@ -470,6 +469,7 @@ void MWindow::init_defaults(BC_Hash* &defaults, char *config_path) else create_defaults_path(path, CONFIG_FILE); + delete defaults; defaults = new BC_Hash(path); defaults->load(); } @@ -560,6 +560,9 @@ int MWindow::load_plugin_index(MWindow *mwindow, const char *index_path, const c case PLUGIN_TYPE_FFMPEG: { server = new_ffmpeg_server(mwindow, path); break; } + case PLUGIN_TYPE_LV2: { + server = new_lv2_server(mwindow, path); + break; } } if( !server ) continue; plugins.append(server); @@ -628,6 +631,7 @@ int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences) fprintf(fp, "%s\n", plugin_path); init_plugin_index(mwindow, preferences, fp, plugin_path); init_ffmpeg_index(mwindow, preferences, fp); + init_lv2_index(mwindow, preferences, fp); fclose(fp); return load_plugin_index(mwindow, index_path, plugin_path); } @@ -674,25 +678,6 @@ void MWindow::init_plugin_index(MWindow *mwindow, Preferences *preferences, scan_plugin_index(mwindow, preferences, fp, plugin_dir, ".", idx); } -int MWindow::init_ladspa_index(MWindow *mwindow, Preferences *preferences, - const char *index_path, 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); - FILE *fp = fopen(index_path,"w"); - if( !fp ) { - fprintf(stderr,_("MWindow::init_ladspa_index: " - "can't create plugin index: %s\n"), index_path); - return 1; - } - fprintf(fp, "%d\n", PLUGIN_FILE_VERSION); - fprintf(fp, "%s\n", plugin_dir); - init_plugin_index(mwindow, preferences, fp, plugin_path); - fclose(fp); - return 0; -} - void MWindow::scan_plugin_index(MWindow *mwindow, Preferences *preferences, FILE *fp, const char *plug_dir, const char *plug_path, int &idx) { @@ -745,18 +730,17 @@ void MWindow::add_plugins(ArrayList &plugins) void MWindow::init_plugin_tips(ArrayList &plugins, const char *lang) { - const char *cfg_path = File::get_cindat_path(); - char msg_path[BCTEXTLEN]; int txt = 0; + const char *dat_path = File::get_cindat_path(); + char msg_path[BCTEXTLEN]; FILE *fp = 0; if( BC_Resources::language[0] ) { snprintf(msg_path, sizeof(msg_path), "%s/info/plugins.%s", - cfg_path, lang); + dat_path, lang); fp = fopen(msg_path, "r"); } if( !fp ) { - txt = 1; snprintf(msg_path, sizeof(msg_path), "%s/info/plugins.txt", - cfg_path); + dat_path); fp = fopen(msg_path, "r"); } if( !fp ) return; @@ -775,9 +759,8 @@ void MWindow::init_plugin_tips(ArrayList &plugins, const char *la if( done ) { if( tp > text && *--tp == '\n' ) *tp = 0; if( title[0] ) { - tp = !txt ? title : _(title); int idx = plugins.size(); - while( --idx>=0 && strcmp(plugins[idx]->title, tp) ); + while( --idx>=0 && strcmp(plugins[idx]->title, title) ); if( idx >= 0 ) { delete [] plugins[idx]->tip; plugins[idx]->tip = cstrdup(text); @@ -898,10 +881,25 @@ int MWindow::plugin_exists(char *plugin_path) return !plugindb ? 0 : plugin_exists(plugin_path, *plugindb); } +void MWindow::remove_plugin_index() +{ + char index_path[BCTEXTLEN]; + MWindow::create_defaults_path(index_path, PLUGIN_FILE); + ::remove(index_path); +} + void MWindow::init_preferences() { preferences = new Preferences; preferences->load_defaults(defaults); + const char *lv2_path = getenv("LV2_PATH"); + if( lv2_path && strcmp(lv2_path, preferences->lv2_path) ) { + strncpy(preferences->lv2_path, lv2_path, sizeof(preferences->lv2_path)); + remove_plugin_index(); + } + else if( !lv2_path && preferences->lv2_path[0] ) { + File::setenv_path("LV2_PATH",preferences->lv2_path, 0); + } session = new MainSession(this); session->load_defaults(defaults); // set x11_host, screens, window_config @@ -1961,7 +1959,8 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); nested_edl->create_objects(); nested_edl->load_xml(&xml_file, LOAD_ALL); //printf("MWindow::load_filenames %p %s\n", nested_edl, nested_edl->project_path); - new_edl->create_nested(nested_edl, filenames->get(i)); + new_edl->create_nested(nested_edl); + new_edl->set_path(filenames->get(i)); nested_edl->Garbage::remove_user(); } else { @@ -2263,32 +2262,37 @@ void MWindow::test_plugins(EDL *new_edl, char *path) } -void MWindow::init_shm() +void MWindow::init_shm(const char *pfn, int64_t min) { + int64_t result = 0; // Fix shared memory - FILE *fd = fopen("/proc/sys/kernel/shmmax", "w"); - if(fd) { - fprintf(fd, "0x7fffffff"); + FILE *fd = fopen(pfn, "r"); + if( fd ) { + fscanf(fd, "%jd", &result); fclose(fd); + if( result >= min ) return; } - fd = 0; - fd = fopen("/proc/sys/kernel/shmmax", "r"); - if(!fd) { - MainError::show_error("MWindow::init_shm: couldn't open /proc/sys/kernel/shmmax for reading.\n"); + fd = fopen(pfn, "w"); + if( !fd ) return; + fprintf(fd, "0x%jx", min); + fclose(fd); + + fd = fopen(pfn, "r"); + if( !fd ) { + eprintf(_("MWindow::init_shm: couldn't open %s for reading.\n"), pfn); return; } - int64_t result = 0; fscanf(fd, "%jd", &result); fclose(fd); - fd = 0; - if(result < 0x7fffffff) { - eprintf(_("MWindow::init_shm: /proc/sys/kernel/shmmax is %p.\n" + if( result < min ) { + eprintf(_("MWindow::init_shm: %s is %p.\n" "you probably need to be root, or:\n" - "as root, run: echo 0x7fffffff > /proc/sys/kernel/shmmax\n" + "as root, run: echo 0x%jx > %s\n" "before trying to start cinelerra.\n" - "It should be at least 0x7fffffff for Cinelerra.\n"), (void *)result); + "It should be at least 0x%jx for Cinelerra.\n"), + pfn, (void *)result, min, pfn, min); } } @@ -2336,9 +2340,6 @@ void MWindow::create_objects(int want_gui, BC_Resources::init_fontconfig(string); if(debug) PRINT_TRACE -// Initialize before too much else is running -// Preferences & theme are required for building MPEG table of contents - // Default project created here init_edl(); if(debug) PRINT_TRACE @@ -2473,7 +2474,8 @@ void MWindow::create_objects(int want_gui, &MWindowGUI::keyboard_listener); hide_splash(); - init_shm(); + init_shm("/proc/sys/kernel/shmmax", 0x7fffffff); + init_shm("/proc/sys/kernel/shmmni", 0x4000); if(debug) PRINT_TRACE BC_WindowBase::get_resources()->vframe_shm = 1; @@ -3349,9 +3351,12 @@ void MWindow::save_backup() FileXML file; edl->optimize(); edl->set_path(session->filename); - char backup_path[BCTEXTLEN]; + char backup_path[BCTEXTLEN], backup_path1[BCTEXTLEN]; snprintf(backup_path, sizeof(backup_path), "%s/%s", File::get_config_path(), BACKUP_FILE); + snprintf(backup_path1, sizeof(backup_path1), "%s/%s", + File::get_config_path(), BACKUP_FILE1); + rename(backup_path, backup_path1); edl->save_xml(&file, backup_path); file.terminate_string(); FileSystem fs; @@ -3388,6 +3393,29 @@ void MWindow::load_backup() save_backup(); } + +void MWindow::save_undo_data() +{ + char perpetual_path[BCTEXTLEN]; + snprintf(perpetual_path, sizeof(perpetual_path), "%s/%s", + File::get_config_path(), PERPETUAL_FILE); + FILE *fp = fopen(perpetual_path,"w"); + if( !fp ) return; + undo->save(fp); + fclose(fp); +} + +void MWindow::load_undo_data() +{ + char perpetual_path[BCTEXTLEN]; + snprintf(perpetual_path, sizeof(perpetual_path), "%s/%s", + File::get_config_path(), PERPETUAL_FILE); + FILE *fp = fopen(perpetual_path,"r"); + if( !fp ) return; + undo->load(fp); + fclose(fp); +} + static inline int gcd(int m, int n) { int r;