3 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "audioalsa.h"
24 #include "awindowgui.h"
26 #include "batchrender.h"
27 #include "bcdisplayinfo.h"
28 #include "bcsignals.h"
34 #include "channeldb.h"
35 #include "channelinfo.h"
37 #include "bccmodels.h"
38 #include "commercials.h"
39 #include "cplayback.h"
41 #include "cwindowgui.h"
43 #include "cwindowtool.h"
45 #include "devicedvbinput.inc"
46 #include "dvdcreate.h"
47 #include "editpanel.h"
49 #include "edlsession.h"
51 #include "fileformat.h"
53 #include "filesystem.h"
55 #include "framecache.h"
57 #include "gwindowgui.h"
58 #include "keyframegui.h"
59 #include "indexfile.h"
60 #include "interlacemodes.h"
62 #include "levelwindowgui.h"
63 #include "levelwindow.h"
64 #include "loadfile.inc"
65 #include "localsession.h"
66 #include "maincursor.h"
67 #include "mainerror.h"
68 #include "mainindexes.h"
70 #include "mainprogress.h"
71 #include "mainsession.h"
75 #include "mwindowgui.h"
77 #include "nestededls.h"
80 #include "playback3d.h"
81 #include "playbackengine.h"
83 #include "pluginserver.h"
84 #include "pluginset.h"
85 #include "preferences.h"
87 #include "recordmonitor.h"
88 #include "recordlabel.h"
89 #include "removefile.h"
91 #include "resourcethread.h"
92 #include "samplescroll.h"
94 #include "sighandler.h"
95 #include "splashgui.h"
96 #include "statusbar.h"
98 #include "threadloader.h"
100 #include "tipwindow.h"
101 #include "trackcanvas.h"
103 #include "tracking.h"
104 #include "trackscroll.h"
106 #include "transition.h"
107 #include "transportque.h"
109 #include "videodevice.inc"
110 #include "videowindow.h"
111 #include "vplayback.h"
112 #include "vwindowgui.h"
114 #include "wavecache.h"
117 #include "exportedl.h"
119 #include "defaultformats.h"
120 #include "ntsczones.h"
122 #include <sys/types.h>
123 #include <sys/stat.h>
126 #include <sys/stat.h>
135 // Hack for libdv to remove glib dependancy
138 // g_log (const char *log_domain,
140 // const char *format,
146 // g_logv (const char *log_domain,
148 // const char *format,
158 ArrayList<PluginServer*>* MWindow::plugindb = 0;
159 Commercials* MWindow::commercials = 0;
165 plugin_gui_lock = new Mutex("MWindow::plugin_gui_lock");
166 dead_plugin_lock = new Mutex("MWindow::dead_plugin_lock");
167 vwindows_lock = new Mutex("MWindow::vwindows_lock");
168 brender_lock = new Mutex("MWindow::brender_lock");
169 keyframe_gui_lock = new Mutex("MWindow::keyframe_gui_lock");
177 commercial_active = 0;
188 channeldb_buz = new ChannelDB;
189 channeldb_v4l2jpeg = new ChannelDB;
193 keyframe_threads = 0;
213 // Need to delete brender temporary here.
219 //printf("MWindow::~MWindow %d\n", __LINE__);
221 gui->remote_control->deactivate();
223 gui->channel_info->stop();
224 brender_lock->lock("MWindow::quit");
225 delete brender; brender = 0;
226 brender_lock->unlock();
227 delete create_bd; create_bd = 0;
228 delete create_dvd; create_dvd = 0;
229 delete batch_render; batch_render = 0;
231 if( commercials && !commercials->remove_user() ) commercials = 0;
233 // Save defaults for open plugins
234 plugin_gui_lock->lock("MWindow::~MWindow");
235 for(int i = 0; i < plugin_guis->size(); i++) {
236 plugin_guis->get(i)->hide_gui();
237 delete_plugin(plugin_guis->get(i));
239 plugin_gui_lock->unlock();
240 hide_keyframe_guis();
243 // Give up and go to a movie
244 // cant run valgrind if this is used
246 gui->del_keyboard_listener(
247 (int (BC_WindowBase::*)(BC_WindowBase *))
248 &MWindowGUI::keyboard_listener);
250 // release the hounds
251 if( awindow && awindow->gui ) awindow->gui->close(0);
252 if( cwindow && cwindow->gui ) cwindow->gui->close(0);
253 if( lwindow && lwindow->gui ) lwindow->gui->close(0);
254 if( gwindow && gwindow->gui ) gwindow->gui->close(0);
255 if( twindow && twindow->is_running() ) twindow->close_window();
256 if( wwindow && wwindow->is_running() ) wwindow->close_window();
257 vwindows.remove_all_objects();
259 if( awindow ) awindow->join();
260 if( cwindow ) cwindow->join();
261 if( lwindow ) lwindow->join();
262 if( twindow ) twindow->join();
263 if( wwindow ) wwindow->join();
264 if( gwindow ) gwindow->join();
267 // one at a time, or nouveau chokes
268 #define close_gui(win) if( win ) { \
269 if( win->gui ) win->gui->close(0); \
277 vwindows.remove_all_objects();
282 dead_plugins->remove_all_objects();
285 keyframe_threads->remove_all_objects();
286 colormodels.remove_all_objects();
288 delete render; render = 0;
289 delete awindow; awindow = 0;
290 delete lwindow; lwindow = 0;
291 delete twindow; twindow = 0;
292 delete wwindow; wwindow = 0;
293 delete gwindow; gwindow = 0;
294 // must be last or nouveau chokes
295 delete cwindow; cwindow = 0;
296 //delete file_server; file_server = 0; // reusable
297 delete mainindexes; mainindexes = 0;
298 delete mainprogress; mainprogress = 0;
299 delete audio_cache; audio_cache = 0; // delete the cache after the assets
300 delete video_cache; video_cache = 0; // delete the cache after the assets
301 delete frame_cache; frame_cache = 0;
302 delete wave_cache; wave_cache = 0;
303 delete plugin_guis; plugin_guis = 0;
304 delete dead_plugins; dead_plugins = 0;
305 delete keyframe_threads; keyframe_threads = 0;
306 delete undo; undo = 0;
307 delete preferences; preferences = 0;
308 delete exportedl; exportedl = 0;
309 delete session; session = 0;
310 delete defaults; defaults = 0;
311 delete assets; assets = 0;
312 delete splash_window; splash_window = 0;
313 // delete theme; theme = 0; // deleted by delete_plugins
314 if( !edl->Garbage::remove_user() ) edl = 0;
315 delete channeldb_buz;
316 delete channeldb_v4l2jpeg;
317 // This must be last thread to exit
318 delete playback_3d; playback_3d = 0;
319 delete dead_plugin_lock;
320 delete plugin_gui_lock;
321 delete vwindows_lock;
323 delete keyframe_gui_lock;
324 colormodels.remove_all_objects();
325 interlace_project_modes.remove_all_objects();
326 interlace_asset_modes.remove_all_objects();
327 interlace_asset_fixmethods.remove_all_objects();
328 sighandler->terminate();
333 void MWindow::quit(int unlock)
336 if(unlock) gui->unlock_window();
338 brender_lock->lock("MWindow::quit");
339 delete brender; brender = 0;
340 brender_lock->unlock();
346 if(unlock) gui->lock_window("MWindow::quit");
349 void MWindow::init_error()
351 MainError::init_error(this);
354 void MWindow::finit_error()
356 MainError::finit_error();
359 void MWindow::create_defaults_path(char *string, const char *config_file)
361 // set the .bcast path
364 sprintf(string, "%s", BCASTDIR);
365 fs.complete_path(string);
366 if(!fs.is_dir(string))
367 fs.create_dir(string);
370 strcat(string, config_file);
372 const char *MWindow::default_std()
378 if((fd = open(TIMEZONE_NAME, O_RDONLY)) >= 0)
380 l = read(fd, buf, BCTEXTLEN);
385 if(buf[l - 1] == '\n')
392 if((l = readlink(LOCALTIME_LINK, buf, BCTEXTLEN)) > 0)
395 if( (p=strstr(buf, ZONEINFO_STR)) != 0 )
397 p += strlen(ZONEINFO_STR);
406 for(i = 0; ntsc_zones[i]; i++)
407 if(strcmp(ntsc_zones[i], p) == 0)
413 void MWindow::fill_preset_defaults(const char *preset, EDLSession *session)
415 struct formatpresets *fpr;
417 for(fpr = &format_presets[0]; fpr->name; fpr++)
419 if(strcmp(fpr->name, preset) == 0)
421 session->audio_channels = fpr->audio_channels;
422 session->audio_tracks = fpr->audio_tracks;
423 session->sample_rate = fpr->sample_rate;
424 session->video_channels = fpr->video_channels;
425 session->video_tracks = fpr->video_tracks;
426 session->frame_rate = fpr->frame_rate;
427 session->output_w = fpr->output_w;
428 session->output_h = fpr->output_h;
429 session->aspect_w = fpr->aspect_w;
430 session->aspect_h = fpr->aspect_h;
431 session->interlace_mode = fpr->interlace_mode;
432 session->color_model = fpr->color_model;
438 const char *MWindow::get_preset_name(int index)
440 if(index < 0 || index >= (int)MAX_NUM_PRESETS)
442 return format_presets[index].name;
446 void MWindow::init_defaults(BC_Hash* &defaults, char *config_path)
448 char path[BCTEXTLEN];
449 // Use user supplied path
451 strcpy(path, config_path);
453 create_defaults_path(path, CONFIG_FILE);
455 defaults = new BC_Hash(path);
459 void MWindow::get_plugin_path(char *path, const char *plug_dir, const char *fs_path)
461 char *base_path = FileSystem::basepath(fs_path), *bp = base_path;
463 const char *dp = plug_dir;
464 while( *bp && *dp && *bp == *dp ) { ++bp; ++dp; }
465 bp = !*dp && *bp == '/' ? bp+1 : base_path;
471 int MWindow::load_plugin_index(MWindow *mwindow, const char *index_path, const char *plugin_dir)
474 FILE *fp = fopen(index_path, "r");
478 char index_line[BCTEXTLEN];
479 int index_version = -1, len = strlen(plugin_dir);
480 if( !fgets(index_line, BCTEXTLEN, fp) ||
481 sscanf(index_line, "%d", &index_version) != 1 ||
482 index_version != PLUGIN_FILE_VERSION ||
483 !fgets(index_line, BCTEXTLEN, fp) ||
484 (int)strlen(index_line)-1 != len || index_line[len] != '\n' ||
485 strncmp(index_line, plugin_dir, len) != 0 ) ret = 1;
487 ArrayList<PluginServer*> plugins;
488 while( !ret && !feof(fp) && fgets(index_line, BCTEXTLEN, fp) ) {
489 if( index_line[0] == ';' ) continue;
490 if( index_line[0] == '#' ) continue;
491 int type = PLUGIN_TYPE_UNKNOWN;
492 char path[BCTEXTLEN], title[BCTEXTLEN];
494 if( PluginServer::scan_table(index_line, type, path, title, mtime) ) {
497 PluginServer *server = 0;
499 case PLUGIN_TYPE_BUILTIN:
500 case PLUGIN_TYPE_EXECUTABLE:
501 case PLUGIN_TYPE_LADSPA: {
502 char plugin_path[BCTEXTLEN]; struct stat st;
503 sprintf(plugin_path, "%s/%s", plugin_dir, path);
504 if( stat(plugin_path, &st) || st.st_mtime != mtime ) {
507 server = new PluginServer(mwindow, plugin_path, type);
509 case PLUGIN_TYPE_FFMPEG: {
510 server = new_ffmpeg_server(mwindow, path);
513 if( !server ) continue;
514 plugins.append(server);
515 // Create plugin server from index entry
516 server->set_title(title);
517 if( server->read_table(index_line) ) {
524 ret = check_plugin_index(plugins, plugin_dir, ".");
527 add_plugins(plugins);
529 plugins.remove_all_objects();
534 int MWindow::check_plugin_index(ArrayList<PluginServer*> &plugins,
535 const char *plug_dir, const char *plug_path)
537 char plugin_path[BCTEXTLEN];
538 sprintf(plugin_path, "%s/%s", plug_dir, plug_path);
540 fs.set_filter( "[*.plugin][*.so]" );
541 if( fs.update(plugin_path) )
544 for( int i=0; i<fs.dir_list.total; ++i ) {
545 char fs_path[BCTEXTLEN];
546 get_plugin_path(fs_path, 0, fs.dir_list[i]->path);
547 if( fs.is_dir(fs_path) ) {
548 get_plugin_path(plugin_path, plug_dir, fs_path);
549 if( check_plugin_index(plugins, plug_dir, plugin_path) )
552 else if( !plugin_exists(fs_path, plugins) )
559 int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences)
562 plugindb = new ArrayList<PluginServer*>;
564 char index_path[BCTEXTLEN], plugin_path[BCTEXTLEN];
565 create_defaults_path(index_path, PLUGIN_FILE);
566 char *plugin_dir = FileSystem::basepath(preferences->plugin_dir);
567 strcpy(plugin_path, plugin_dir); delete [] plugin_dir;
568 if( !load_plugin_index(mwindow, index_path, plugin_path) ) return 1;
569 printf("init plugin index: %s\n", plugin_path);
570 FILE *fp = fopen(index_path,"w");
572 fprintf(stderr,_("MWindow::init_plugins: "
573 "can't create plugin index: %s\n"), index_path);
576 fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
577 fprintf(fp, "%s\n", plugin_path);
578 init_plugin_index(mwindow, preferences, fp, plugin_path);
579 init_ffmpeg_index(mwindow, preferences, fp);
581 return load_plugin_index(mwindow, index_path, plugin_path);
584 int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences)
586 char *path = getenv("LADSPA_PATH");
587 char ladspa_path[BCTEXTLEN];
589 get_exe_path(ladspa_path);
590 strcat(ladspa_path, "/ladspa");
593 for( int len=0; *path; path+=len ) {
594 char *cp = strchr(path,':');
595 len = !cp ? strlen(path) : cp-path;
596 char index_path[BCTEXTLEN], plugin_path[BCTEXTLEN];
597 memcpy(plugin_path, path, len); plugin_path[len] = 0;
598 char *plugin_dir = FileSystem::basepath(plugin_path);
599 strcpy(plugin_path, plugin_dir); delete [] plugin_dir;
600 create_defaults_path(index_path, LADSPA_FILE);
601 cp = index_path + strlen(index_path);
602 for( char *bp=plugin_path; *bp!=0; ++bp )
603 *cp++ = *bp=='/' ? '_' : *bp;
605 if( !load_plugin_index(mwindow, index_path, plugin_path) ) continue;
606 if( init_ladspa_index(mwindow, preferences, index_path, plugin_path) ) continue;
607 load_plugin_index(mwindow, index_path, plugin_path);
612 void MWindow::init_plugin_index(MWindow *mwindow, Preferences *preferences,
613 FILE *fp, const char *plugin_dir)
615 int idx = PLUGIN_IDS;
617 for( int i=0; i<plugindb->size(); ++i ) {
618 PluginServer *server = plugindb->get(i);
619 if( server->dir_idx >= idx )
620 idx = server->dir_idx+1;
623 scan_plugin_index(mwindow, preferences, fp, plugin_dir, ".", idx);
626 int MWindow::init_ladspa_index(MWindow *mwindow, Preferences *preferences,
627 const char *index_path, const char *plugin_dir)
629 char plugin_path[BCTEXTLEN], *path = FileSystem::basepath(plugin_dir);
630 strcpy(plugin_path, path); delete [] path;
631 printf("init ladspa index: %s\n", plugin_dir);
632 FILE *fp = fopen(index_path,"w");
634 fprintf(stderr,_("MWindow::init_ladspa_index: "
635 "can't create plugin index: %s\n"), index_path);
638 fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
639 fprintf(fp, "%s\n", plugin_dir);
640 init_plugin_index(mwindow, preferences, fp, plugin_path);
645 void MWindow::scan_plugin_index(MWindow *mwindow, Preferences *preferences, FILE *fp,
646 const char *plug_dir, const char *plug_path, int &idx)
648 char plugin_path[BCTEXTLEN];
649 sprintf(plugin_path, "%s/%s", plug_dir, plug_path);
651 fs.set_filter( "[*.plugin][*.so]" );
652 int result = fs.update(plugin_path);
653 if( result || !fs.dir_list.total ) return;
656 for( int i=0; i<fs.dir_list.total; ++i ) {
657 char fs_path[BCTEXTLEN], path[BCTEXTLEN];
658 get_plugin_path(fs_path, 0, fs.dir_list[i]->path);
659 get_plugin_path(path, plug_dir, fs_path);
660 if( fs.is_dir(fs_path) ) {
661 scan_plugin_index(mwindow, preferences, fp, plug_dir, path, idx);
664 if( plugin_exists(path) ) continue;
666 if( stat(fs_path, &st) ) continue;
667 int64_t mtime = st.st_mtime;
668 PluginServer server(mwindow, fs_path, PLUGIN_TYPE_UNKNOWN);
669 result = server.open_plugin(1, preferences, 0, 0);
671 server.write_table(fp, path, vis_id, mtime);
672 server.close_plugin();
674 else if( result == PLUGINSERVER_IS_LAD ) {
677 PluginServer ladspa(mwindow, fs_path, PLUGIN_TYPE_LADSPA);
678 ladspa.set_lad_index(lad_index++);
679 result = ladspa.open_plugin(1, preferences, 0, 0);
681 ladspa.write_table(fp, path, PLUGIN_LADSPA_ID, mtime);
682 ladspa.close_plugin();
688 void MWindow::add_plugins(ArrayList<PluginServer*> &plugins)
690 for( int i=0; i<plugins.size(); ++i )
691 plugindb->append(plugins[i]);
692 plugins.remove_all();
695 void MWindow::delete_plugins()
697 plugindb->remove_all_objects();
702 void MWindow::search_plugindb(int do_audio,
707 ArrayList<PluginServer*> &results)
710 for(int i = 0; i < MWindow::plugindb->total; i++)
712 PluginServer *current = MWindow::plugindb->get(i);
714 if(current->audio == do_audio &&
715 current->video == do_video &&
716 (current->realtime == is_realtime || is_realtime < 0) &&
717 current->transition == is_transition &&
718 current->theme == is_theme)
719 results.append(current);
722 // Alphabetize list by title
728 for(int i = 0; i < results.total - 1; i++)
730 PluginServer *value1 = results[i];
731 PluginServer *value2 = results[i + 1];
732 if(strcmp(_(value1->title), _(value2->title)) > 0)
736 results[i + 1] = value1;
742 PluginServer* MWindow::scan_plugindb(char *title,
747 // printf("MWindow::scan_plugindb data_type < 0\n");
751 for(int i = 0; i < plugindb->total; i++)
753 PluginServer *server = plugindb->get(i);
755 !strcasecmp(server->title, title) &&
757 (data_type == TRACK_AUDIO && server->audio) ||
758 (data_type == TRACK_VIDEO && server->video)))
759 return plugindb->get(i);
764 int MWindow::plugin_exists(const char *plugin_path, ArrayList<PluginServer*> &plugins)
766 for( int i=0; i<plugins.size(); ++i )
767 if( !strcmp(plugin_path, plugins[i]->get_path()) ) return 1;
771 int MWindow::plugin_exists(char *plugin_path)
773 return !plugindb ? 0 : plugin_exists(plugin_path, *plugindb);
776 void MWindow::init_preferences()
778 preferences = new Preferences;
779 preferences->load_defaults(defaults);
780 session = new MainSession(this);
781 session->load_defaults(defaults);
782 // set x11_host, screens, window_config
783 screens = session->set_default_x11_host();
784 BC_Signals::set_trap_path("/tmp/cinelerra_%d.dmp");
785 BC_Signals::set_trap_hook(trap_hook, this);
786 BC_Signals::set_catch_segv(preferences->trap_sigsegv);
787 BC_Signals::set_catch_intr(preferences->trap_sigintr);
790 void MWindow::clean_indexes()
795 int oldest_item = -1;
797 char string[BCTEXTLEN];
798 char string2[BCTEXTLEN];
800 // Delete extra indexes
801 fs.set_filter("*.idx");
802 fs.complete_path(preferences->index_directory);
803 fs.update(preferences->index_directory);
804 //printf("MWindow::clean_indexes 1 %d\n", fs.dir_list.total);
806 // Eliminate directories
811 for(int i = 0; i < fs.dir_list.total && !result; i++)
813 fs.join_names(string, preferences->index_directory, fs.dir_list[i]->name);
814 if(fs.is_dir(string))
816 delete fs.dir_list[i];
817 fs.dir_list.remove_number(i);
822 total_excess = fs.dir_list.total - preferences->index_count;
824 //printf("MWindow::clean_indexes 2 %d\n", fs.dir_list.total);
825 while(total_excess > 0)
828 for(int i = 0; i < fs.dir_list.total; i++)
830 fs.join_names(string, preferences->index_directory, fs.dir_list[i]->name);
832 if(i == 0 || fs.get_date(string) <= oldest)
834 oldest = fs.get_date(string);
842 fs.join_names(string,
843 preferences->index_directory,
844 fs.dir_list[oldest_item]->name);
845 //printf("MWindow::clean_indexes 1 %s\n", string);
847 perror("delete_indexes");
848 delete fs.dir_list[oldest_item];
849 fs.dir_list.remove_number(oldest_item);
851 // Remove table of contents if it exists
852 strcpy(string2, string);
853 char *ptr = strrchr(string2, '.');
856 //printf("MWindow::clean_indexes 2 %s\n", string2);
857 sprintf(ptr, ".toc");
859 sprintf(ptr, ".mkr");
868 void MWindow::init_awindow()
870 awindow = new AWindow(this);
871 awindow->create_objects();
874 void MWindow::init_gwindow()
876 gwindow = new GWindow(this);
877 gwindow->create_objects();
880 void MWindow::init_tipwindow()
883 twindow = new TipWindow(this);
887 void MWindow::show_warning(int *do_warning, const char *text)
889 if( do_warning && !*do_warning ) return;
891 wwindow = new WWindow(this);
892 wwindow->show_warning(do_warning, text);
895 void MWindow::init_theme()
900 PluginServer *theme_plugin = 0;
901 for(int i = 0; i < plugindb->total && !theme_plugin; i++) {
902 if( plugindb->get(i)->theme &&
903 !strcasecmp(preferences->theme, plugindb->get(i)->title) )
904 theme_plugin = plugindb->get(i);
908 fprintf(stderr, _("MWindow::init_theme: prefered theme %s not found.\n"),
911 if( !theme_plugin && strcasecmp(preferences->theme, DEFAULT_THEME) ) {
912 fprintf(stderr, _("MWindow::init_theme: trying default theme %s\n"),
914 for(int i = 0; i < plugindb->total && !theme_plugin; i++) {
915 if( plugindb->get(i)->theme &&
916 !strcasecmp(DEFAULT_THEME, plugindb->get(i)->title) )
917 theme_plugin = plugindb->get(i);
922 fprintf(stderr, _("MWindow::init_theme: theme_plugin not found.\n"));
926 PluginServer *plugin = new PluginServer(*theme_plugin);
927 if( plugin->open_plugin(0, preferences, 0, 0) ) {
928 fprintf(stderr, _("MWindow::init_theme: unable to load theme %s\n"),
929 theme_plugin->title);
933 theme = plugin->new_theme();
934 theme->mwindow = this;
935 strcpy(theme->path, plugin->path);
938 // Load default images & settings
939 theme->Theme::initialize();
940 // Load user images & settings
942 // Create menus with user colors
943 theme->build_menus();
948 //printf("MWindow::init_theme %d total_time=%d\n", __LINE__, (int)timer.get_difference());
951 void MWindow::init_3d()
953 playback_3d = new Playback3D(this);
954 playback_3d->create_objects();
957 void MWindow::init_edl()
960 edl->create_objects();
961 fill_preset_defaults(default_standard, edl->session);
962 edl->load_defaults(defaults);
963 edl->create_default_tracks();
964 edl->tracks->update_y_pixels(theme);
967 void MWindow::init_compositor()
969 cwindow = new CWindow(this);
970 cwindow->create_objects();
973 void MWindow::init_levelwindow()
975 lwindow = new LevelWindow(this);
976 lwindow->create_objects();
979 VWindow *MWindow::get_viewer(int start_it, int idx)
981 vwindows_lock->lock("MWindow::get_viewer");
982 VWindow *vwindow = idx >= 0 && idx < vwindows.size() ? vwindows[idx] : 0;
983 if( !vwindow ) idx = vwindows.size();
984 while( !vwindow && --idx >= 0 ) {
985 VWindow *vwin = vwindows[idx];
986 if( !vwin->is_running() || !vwin->get_edl() )
990 vwindow = new VWindow(this);
991 vwindow->load_defaults();
992 vwindow->create_objects();
993 vwindows.append(vwindow);
995 vwindows_lock->unlock();
996 if( start_it ) vwindow->start();
1000 void MWindow::init_cache()
1002 audio_cache = new CICache(preferences);
1003 video_cache = new CICache(preferences);
1004 frame_cache = new FrameCache;
1005 wave_cache = new WaveCache;
1008 void MWindow::init_channeldb()
1010 channeldb_buz->load("channeldb_buz");
1011 channeldb_v4l2jpeg->load("channeldb_v4l2jpeg");
1014 void MWindow::init_menus()
1016 char string[BCTEXTLEN];
1019 BC_CModels::to_text(string, BC_RGB888);
1020 colormodels.append(new ColormodelItem(string, BC_RGB888));
1021 BC_CModels::to_text(string, BC_RGBA8888);
1022 colormodels.append(new ColormodelItem(string, BC_RGBA8888));
1023 // BC_CModels::to_text(string, BC_RGB161616);
1024 // colormodels.append(new ColormodelItem(string, BC_RGB161616));
1025 // BC_CModels::to_text(string, BC_RGBA16161616);
1026 // colormodels.append(new ColormodelItem(string, BC_RGBA16161616));
1027 BC_CModels::to_text(string, BC_RGB_FLOAT);
1028 colormodels.append(new ColormodelItem(string, BC_RGB_FLOAT));
1029 BC_CModels::to_text(string, BC_RGBA_FLOAT);
1030 colormodels.append(new ColormodelItem(string, BC_RGBA_FLOAT));
1031 BC_CModels::to_text(string, BC_YUV888);
1032 colormodels.append(new ColormodelItem(string, BC_YUV888));
1033 BC_CModels::to_text(string, BC_YUVA8888);
1034 colormodels.append(new ColormodelItem(string, BC_YUVA8888));
1035 // BC_CModels::to_text(string, BC_YUV161616);
1036 // colormodels.append(new ColormodelItem(string, BC_YUV161616));
1037 // BC_CModels::to_text(string, BC_YUVA16161616);
1038 // colormodels.append(new ColormodelItem(string, BC_YUVA16161616));
1040 #define ILACEPROJECTMODELISTADD(x) ilacemode_to_text(string, x); \
1041 interlace_project_modes.append(new InterlacemodeItem(string, x));
1043 #define ILACEASSETMODELISTADD(x) ilacemode_to_text(string, x); \
1044 interlace_asset_modes.append(new InterlacemodeItem(string, x));
1046 #define ILACEFIXMETHODLISTADD(x) ilacefixmethod_to_text(string, x); \
1047 interlace_asset_fixmethods.append(new InterlacefixmethodItem(string, x));
1049 // Interlacing Modes
1050 ILACEASSETMODELISTADD(BC_ILACE_MODE_UNDETECTED); // Not included in the list for the project options.
1052 ILACEASSETMODELISTADD(BC_ILACE_MODE_TOP_FIRST);
1053 ILACEPROJECTMODELISTADD(BC_ILACE_MODE_TOP_FIRST);
1055 ILACEASSETMODELISTADD(BC_ILACE_MODE_BOTTOM_FIRST);
1056 ILACEPROJECTMODELISTADD(BC_ILACE_MODE_BOTTOM_FIRST);
1058 ILACEASSETMODELISTADD(BC_ILACE_MODE_NOTINTERLACED);
1059 ILACEPROJECTMODELISTADD(BC_ILACE_MODE_NOTINTERLACED);
1061 // Interlacing Fixing Methods
1062 ILACEFIXMETHODLISTADD(BC_ILACE_FIXMETHOD_NONE);
1063 ILACEFIXMETHODLISTADD(BC_ILACE_FIXMETHOD_UPONE);
1064 ILACEFIXMETHODLISTADD(BC_ILACE_FIXMETHOD_DOWNONE);
1067 void MWindow::init_indexes()
1069 mainindexes = new MainIndexes(this);
1070 mainindexes->start_loop();
1073 void MWindow::init_gui()
1075 gui = new MWindowGUI(this);
1076 gui->lock_window("MWindow::init_gui");
1077 gui->create_objects();
1078 gui->unlock_window();
1079 gui->load_defaults(defaults);
1082 void MWindow::init_signals()
1084 sighandler = new SigHandler;
1085 sighandler->initialize();
1089 void MWindow::init_render()
1091 render = new Render(this);
1092 create_bd = new CreateBD_Thread(this);
1093 create_dvd = new CreateDVD_Thread(this);
1094 batch_render = new BatchRenderThread(this);
1097 void MWindow::init_exportedl()
1099 exportedl = new ExportEDL(this);
1102 void MWindow::init_brender()
1104 if(preferences->use_brender && !brender)
1106 brender_lock->lock("MWindow::init_brender 1");
1107 brender = new BRender(this);
1108 brender->initialize();
1109 session->brender_end = 0;
1110 brender_lock->unlock();
1113 if(!preferences->use_brender && brender)
1115 brender_lock->lock("MWindow::init_brender 2");
1118 session->brender_end = 0;
1119 brender_lock->unlock();
1121 if(brender) brender->restart(edl);
1124 void MWindow::restart_brender()
1126 //printf("MWindow::restart_brender 1\n");
1127 if(brender) brender->restart(edl);
1130 void MWindow::stop_brender()
1132 if(brender) brender->stop();
1135 int MWindow::brender_available(int position)
1138 brender_lock->lock("MWindow::brender_available 1");
1141 if(brender->map_valid)
1143 brender->map_lock->lock("MWindow::brender_available 2");
1144 if(position < brender->map_size &&
1147 //printf("MWindow::brender_available 1 %d %d\n", position, brender->map[position]);
1148 if(brender->map[position] == BRender::RENDERED)
1151 brender->map_lock->unlock();
1154 brender_lock->unlock();
1158 void MWindow::set_brender_start()
1160 edl->session->brender_start = edl->local_session->get_selectionstart(1);
1162 gui->draw_overlays(1);
1166 int MWindow::has_commercials()
1168 return theme->use_commercials;
1171 void MWindow::init_commercials()
1173 if( !commercials ) {
1174 commercials = new Commercials(this);
1175 commercial_active = 0;
1178 commercials->add_user();
1181 void MWindow::commit_commercial()
1183 if( !commercial_active ) return;
1184 commercial_active = 0;
1185 if( !commercials ) return;
1186 commercials->commitDb();
1189 void MWindow::undo_commercial()
1191 if( !commercial_active ) return;
1192 commercial_active = 0;
1193 if( !commercials ) return;
1194 commercials->undoDb();
1197 int MWindow::put_commercial()
1199 double start = edl->local_session->get_selectionstart();
1200 double end = edl->local_session->get_selectionend();
1201 if( start >= end ) return 0;
1203 const char *errmsg = 0;
1205 Tracks *tracks = edl->tracks;
1208 for(Track *track=tracks->first; track && !errmsg; track=track->next) {
1209 if( track->data_type != TRACK_VIDEO ) continue;
1210 if( !track->record ) continue;
1211 if( count > 0 ) { errmsg = _("multiple video tracks"); break; }
1213 int64_t units_start = track->to_units(start,0);
1214 int64_t units_end = track->to_units(end,0);
1215 Edits *edits = track->edits;
1216 Edit *edit1 = edits->editof(units_start, PLAY_FORWARD, 0);
1217 Edit *edit2 = edits->editof(units_end, PLAY_FORWARD, 0);
1218 if(!edit1 && !edit2) continue; // nothing selected
1219 if(!edit2) { // edit2 beyond end of track
1220 edit2 = edits->last;
1221 units_end = edits->length();
1223 if(edit1 != edit2) { errmsg = _("crosses edits"); break; }
1224 Indexable *indexable = edit1->get_source();
1225 if( !indexable->is_asset ) { errmsg = _("not asset"); break; }
1228 for(Track *track=tracks->first; track && !errmsg; track=track->next) {
1229 if( track->data_type != TRACK_VIDEO ) continue;
1230 if( !track->record ) continue;
1231 int64_t units_start = track->to_units(start,0);
1232 int64_t units_end = track->to_units(end,0);
1233 Edits *edits = track->edits;
1234 Edit *edit1 = edits->editof(units_start, PLAY_FORWARD, 0);
1235 Edit *edit2 = edits->editof(units_end, PLAY_FORWARD, 0);
1236 if(!edit1 && !edit2) continue; // nothing selected
1237 if(!edit2) { // edit2 beyond end of track
1238 edit2 = edits->last;
1239 units_end = edits->length();
1241 Indexable *indexable = edit1->get_source();
1242 Asset *asset = (Asset *)indexable;
1243 File *file = video_cache->check_out(asset, edl);
1244 if( !file ) { errmsg = _("no file"); break; }
1245 int64_t edit_length = units_end - units_start;
1246 int64_t edit_start = units_start - edit1->startproject + edit1->startsource;
1247 result = commercials->put_clip(file, edit1->channel,
1248 track->from_units(edit_start), track->from_units(edit_length));
1249 video_cache->check_in(asset);
1250 if( result ) { errmsg = _("db failed"); break; }
1253 char string[BCTEXTLEN];
1254 sprintf(string, _("put_commercial: %s"), errmsg);
1255 MainError::show_error(string);
1262 void MWindow::stop_playback(int wait)
1264 int locked = gui->get_window_lock();
1265 if( locked ) gui->unlock_window();
1267 cwindow->playback_engine->que->send_command(STOP,
1271 cwindow->playback_engine->interrupt_playback(wait);
1273 for(int i = 0; i < vwindows.size(); i++) {
1274 VWindow *vwindow = vwindows[i];
1275 if( !vwindow->is_running() ) continue;
1276 vwindow->playback_engine->que->send_command(STOP, CHANGE_NONE, 0, 0);
1277 vwindow->playback_engine->interrupt_playback(wait);
1279 if( locked ) gui->lock_window("MWindow::stop_playback");
1282 int MWindow::load_filenames(ArrayList<char*> *filenames,
1284 int update_filename)
1286 ArrayList<EDL*> new_edls;
1287 ArrayList<Asset*> new_assets;
1288 ArrayList<File*> new_files;
1289 const int debug = 0;
1290 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1293 gui->start_hourglass();
1295 // Need to stop playback since tracking depends on the EDL not getting
1299 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1300 undo->update_undo_before();
1303 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1305 // Define new_edls and new_assets to load
1306 int result = 0, ftype = -1;
1307 for(int i = 0; i < filenames->size(); i++)
1310 File *new_file = new File;
1311 Asset *new_asset = new Asset(filenames->get(i));
1312 EDL *new_edl = new EDL;
1313 char string[BCTEXTLEN];
1315 new_edl->create_objects();
1316 new_edl->copy_session(edl);
1317 new_file->set_program(edl->session->program_no);
1319 sprintf(string, _("Loading %s"), new_asset->path);
1320 gui->show_message(string);
1321 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1323 ftype = new_file->open_file(preferences, new_asset, 1, 0);
1324 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1329 // Convert media file to EDL
1331 // Warn about odd image dimensions
1332 if(new_asset->video_data &&
1333 ((new_asset->width % 2) ||
1334 (new_asset->height % 2)))
1336 char string[BCTEXTLEN];
1337 sprintf(string, _("%s's resolution is %dx%d.\nImages with odd dimensions may not decode properly."),
1341 MainError::show_error(string);
1344 if(new_asset->program >= 0 &&
1345 edl->session->program_no != new_asset->program)
1347 char string[BCTEXTLEN];
1348 sprintf(string, _("%s's index was built for program number %d\n"
1349 "Playback preference is %d.\n Using program %d."),
1350 new_asset->path, new_asset->program,
1351 edl->session->program_no, new_asset->program);
1352 MainError::show_error(string);
1356 if(load_mode != LOADMODE_RESOURCESONLY)
1359 RecordLabels *labels = edl->session->label_cells ?
1360 new RecordLabels(new_file) : 0;
1362 asset_to_edl(new_edl, new_asset, labels);
1364 new_edls.append(new_edl);
1366 new_asset->Garbage::remove_user();
1372 new_assets.append(new_asset);
1376 // Set filename to nothing for assets since save EDL would overwrite them.
1377 if(load_mode == LOADMODE_REPLACE ||
1378 load_mode == LOADMODE_REPLACE_CONCATENATE)
1381 // Reset timeline position
1382 for(int i = 0; i < TOTAL_PANES; i++)
1384 new_edl->local_session->view_start[i] = 0;
1385 new_edl->local_session->track_start[i] = 0;
1393 case FILE_NOT_FOUND:
1394 sprintf(string, _("Failed to open %s"), new_asset->path);
1395 gui->show_message(string, theme->message_error);
1399 case FILE_UNRECOGNIZED_CODEC:
1402 IndexFile indexfile(this, new_asset);
1403 result = indexfile.open_index();
1406 indexfile.close_index();
1409 // Test existing EDLs
1410 for(int j = 0; result && j <= new_edls.total; j++) {
1411 Asset *old_asset = j < new_edls.total ?
1412 new_edls[j]->assets->get_asset(new_asset->path) :
1413 edl->assets->get_asset(new_asset->path);
1415 *new_asset = *old_asset;
1423 char string[BCTEXTLEN];
1425 fs.extract_name(string, new_asset->path);
1427 strcat(string, _("'s format couldn't be determined."));
1428 new_asset->audio_data = 1;
1429 new_asset->format = FILE_PCM;
1430 new_asset->channels = defaults->get("AUDIO_CHANNELS", 2);
1431 new_asset->sample_rate = defaults->get("SAMPLE_RATE", 44100);
1432 new_asset->bits = defaults->get("AUDIO_BITS", 16);
1433 new_asset->byte_order = defaults->get("BYTE_ORDER", 1);
1434 new_asset->signed_ = defaults->get("SIGNED_", 1);
1435 new_asset->header = defaults->get("HEADER", 0);
1437 FileFormat fwindow(this);
1438 fwindow.create_objects(new_asset, string);
1439 result = fwindow.run_window();
1442 defaults->update("AUDIO_CHANNELS", new_asset->channels);
1443 defaults->update("SAMPLE_RATE", new_asset->sample_rate);
1444 defaults->update("AUDIO_BITS", new_asset->bits);
1445 defaults->update("BYTE_ORDER", new_asset->byte_order);
1446 defaults->update("SIGNED_", new_asset->signed_);
1447 defaults->update("HEADER", new_asset->header);
1454 // Recalculate length
1456 new_file = new File;
1457 result = new_file->open_file(preferences, new_asset, 1, 0);
1459 if(load_mode != LOADMODE_RESOURCESONLY)
1461 RecordLabels *labels = edl->session->label_cells ?
1462 new RecordLabels(new_file) : 0;
1463 asset_to_edl(new_edl, new_asset, labels);
1464 new_edls.append(new_edl);
1465 new_asset->Garbage::remove_user();
1471 new_assets.append(new_asset);
1485 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1486 xml_file.read_from_file(filenames->get(i));
1487 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1489 if(load_mode == LOADMODE_NESTED)
1491 // Load temporary EDL for nesting.
1492 EDL *nested_edl = new EDL;
1493 nested_edl->create_objects();
1494 nested_edl->set_path(filenames->get(i));
1495 nested_edl->load_xml(&xml_file, LOAD_ALL);
1496 //printf("MWindow::load_filenames %p %s\n", nested_edl, nested_edl->project_path);
1497 edl_to_nested(new_edl, nested_edl);
1498 nested_edl->Garbage::remove_user();
1502 // Load EDL for pasting
1503 new_edl->load_xml(&xml_file, LOAD_ALL);
1504 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1505 test_plugins(new_edl, filenames->get(i));
1506 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1508 if(load_mode == LOADMODE_REPLACE ||
1509 load_mode == LOADMODE_REPLACE_CONCATENATE)
1511 strcpy(session->filename, filenames->get(i));
1512 strcpy(new_edl->local_session->clip_title,
1515 set_filename(new_edl->local_session->clip_title);
1519 new_edls.append(new_edl);
1525 // edls are in new_edls
1526 if( result && new_edl ) new_edl->Garbage::remove_user();
1527 // assets are copied
1528 if( new_asset ) new_asset->Garbage::remove_user();
1530 // Store for testing index
1531 new_files.append(new_file);
1534 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1537 if(!result) gui->statusbar->default_message();
1545 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1548 // Don't back up here.
1551 // For pasting, clear the active region
1552 if(load_mode == LOADMODE_PASTE ||
1553 load_mode == LOADMODE_NESTED)
1555 double start = edl->local_session->get_selectionstart();
1556 double end = edl->local_session->get_selectionend();
1557 if(!EQUIV(start, end))
1560 edl->session->labels_follow_edits,
1561 edl->session->plugins_follow_edits,
1562 edl->session->autos_follow_edits);
1565 paste_edls(&new_edls,
1569 edl->session->labels_follow_edits,
1570 edl->session->plugins_follow_edits,
1571 edl->session->autos_follow_edits,
1578 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1580 // Add new assets to EDL and schedule assets for index building.
1581 int got_indexes = 0;
1582 for(int i = 0; i < new_edls.size(); i++)
1584 EDL *new_edl = new_edls[i];
1585 for(int j = 0; j < new_edl->nested_edls->size(); j++)
1587 mainindexes->add_next_asset(0,
1588 new_edl->nested_edls->get(j));
1590 edl->nested_edls->update_index(new_edl->nested_edls->get(j));
1595 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1596 if(new_assets.size())
1598 for(int i = 0; i < new_assets.size(); i++)
1600 Asset *new_asset = new_assets[i];
1604 for(int j = 0; j < new_files.size(); j++)
1606 new_file = new_files[j];
1607 if(!strcmp(new_file->asset->path,
1615 mainindexes->add_next_asset(got_it ? new_file : 0, new_asset);
1617 edl->assets->update(new_asset);
1623 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1625 // Start examining next batch of index files
1626 if(got_indexes) mainindexes->start_build();
1627 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1630 Track *track = edl->tracks->first;
1633 for(int j = 0; j < track->plugin_set.size(); j++)
1635 PluginSet *plugins = track->plugin_set[j];
1636 Plugin *plugin = plugins->get_first_plugin();
1640 if(load_mode == LOADMODE_REPLACE ||
1641 load_mode == LOADMODE_REPLACE_CONCATENATE)
1643 if(plugin->plugin_type == PLUGIN_STANDALONE &&
1646 show_plugin(plugin);
1654 plugin = (Plugin*)plugin->next;
1658 track = track->next;
1661 // if just opening one new resource in replace mode
1662 if( load_mode == LOADMODE_REPLACE && new_edls.size() == 1 &&
1663 ftype != FILE_IS_XML )
1666 edl->local_session->preview_start = 0;
1667 edl->local_session->preview_end = edl->tracks->total_playable_length();
1668 edl->local_session->loop_playback = 0;
1669 edl->local_session->set_selectionstart(0);
1670 edl->local_session->set_selectionend(0);
1675 // need to update undo before project, since mwindow is unlocked & a new load
1676 // can begin here. Should really prevent loading until we're done.
1677 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1678 undo->update_undo_after(_("load"), LOAD_ALL);
1680 for(int i = 0; i < new_edls.size(); i++)
1682 new_edls[i]->remove_user();
1684 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1686 new_edls.remove_all();
1688 for(int i = 0; i < new_assets.size(); i++)
1690 new_assets[i]->Garbage::remove_user();
1693 new_assets.remove_all();
1694 new_files.remove_all_objects();
1697 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1698 if(load_mode == LOADMODE_REPLACE ||
1699 load_mode == LOADMODE_REPLACE_CONCATENATE)
1701 session->changes_made = 0;
1705 session->changes_made = 1;
1708 gui->stop_hourglass();
1711 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1712 update_project(load_mode);
1714 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1722 void MWindow::test_plugins(EDL *new_edl, char *path)
1724 char string[BCTEXTLEN];
1726 // Do a check weather plugins exist
1727 for(Track *track = new_edl->tracks->first; track; track = track->next)
1729 for(int k = 0; k < track->plugin_set.total; k++)
1731 PluginSet *plugin_set = track->plugin_set[k];
1732 for(Plugin *plugin = (Plugin*)plugin_set->first;
1734 plugin = (Plugin*)plugin->next)
1736 if(plugin->plugin_type == PLUGIN_STANDALONE)
1738 // ok we need to find it in plugindb
1739 int plugin_found = 0;
1741 for(int j = 0; j < plugindb->size(); j++)
1743 PluginServer *server = plugindb->get(j);
1745 !strcasecmp(server->title, plugin->title) &&
1746 ((track->data_type == TRACK_AUDIO && server->audio) ||
1747 (track->data_type == TRACK_VIDEO && server->video)) &&
1748 (!server->transition))
1755 _("The %s '%s' in file '%s' is not part of your installation of Cinelerra.\n"
1756 "The project won't be rendered as it was meant and Cinelerra might crash.\n"),
1757 "effect", plugin->title,
1759 MainError::show_error(string);
1765 for(Edit *edit = (Edit*)track->edits->first;
1767 edit = (Edit*)edit->next)
1769 if (edit->transition)
1771 // ok we need to find transition in plugindb
1773 int transition_found = 0;
1774 for(int j = 0; j < plugindb->size(); j++)
1776 PluginServer *server = plugindb->get(j);
1778 !strcasecmp(server->title, edit->transition->title) &&
1779 ((track->data_type == TRACK_AUDIO && server->audio) ||
1780 (track->data_type == TRACK_VIDEO && server->video)) &&
1781 (server->transition))
1782 transition_found = 1;
1785 if (!transition_found)
1788 _("The %s '%s' in file '%s' is not part of your installation of Cinelerra.\n"
1789 "The project won't be rendered as it was meant and Cinelerra might crash.\n"),
1790 "transition", edit->transition->title,
1792 MainError::show_error(string);
1800 void MWindow::init_shm()
1802 // Fix shared memory
1803 FILE *fd = fopen("/proc/sys/kernel/shmmax", "w");
1805 fprintf(fd, "0x7fffffff");
1810 fd = fopen("/proc/sys/kernel/shmmax", "r");
1812 MainError::show_error("MWindow::init_shm: couldn't open /proc/sys/kernel/shmmax for reading.\n");
1817 fscanf(fd, _LD, &result);
1820 if(result < 0x7fffffff) {
1821 eprintf(_("MWindow::init_shm: /proc/sys/kernel/shmmax is %p.\n"
1822 "you probably need to be root, or:\n"
1823 "as root, run: echo 0x7fffffff > /proc/sys/kernel/shmmax\n"
1824 "before trying to start cinelerra.\n"
1825 "It should be at least 0x7fffffff for Cinelerra.\n"), (void *)result);
1829 void MWindow::create_objects(int want_gui,
1834 const int debug = 0;
1835 if(debug) PRINT_TRACE
1837 // For some reason, init_signals must come after show_splash or the signals won't
1840 if(debug) PRINT_TRACE
1843 if(debug) PRINT_TRACE
1846 if(debug) PRINT_TRACE
1847 default_standard = default_std();
1848 init_defaults(defaults, config_path);
1851 splash_window->operation->update(_("Initializing Plugins"));
1852 init_plugins(this, preferences);
1853 if(debug) PRINT_TRACE
1854 init_ladspa_plugins(this, preferences);
1855 if(debug) PRINT_TRACE
1857 splash_window->operation->update(_("Initializing GUI"));
1858 if(debug) PRINT_TRACE
1861 if(debug) PRINT_TRACE
1865 splash_window->operation->update(_("Initializing Fonts"));
1866 char string[BCTEXTLEN];
1867 strcpy(string, preferences->plugin_dir);
1868 strcat(string, "/" FONT_SEARCHPATH);
1869 BC_Resources::init_fontconfig(string);
1870 if(debug) PRINT_TRACE
1872 // Initialize before too much else is running
1873 // Preferences & theme are required for building MPEG table of contents
1875 // Default project created here
1877 if(debug) PRINT_TRACE
1880 if(debug) PRINT_TRACE
1885 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1887 //printf("MWindow::create_objects %d session->show_vwindow=%d\n", __LINE__, session->show_vwindow);
1888 if(session->show_vwindow)
1889 get_viewer(1, DEFAULT_VWINDOW);
1890 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1893 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1896 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1899 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1901 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1904 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1908 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1910 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1912 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1916 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1917 mainprogress = new MainProgress(this, gui);
1918 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1919 undo = new MainUndo(this);
1921 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1923 plugin_guis = new ArrayList<PluginServer*>;
1924 dead_plugins = new ArrayList<PluginServer*>;
1925 keyframe_threads = new ArrayList<KeyFrameThread*>;
1927 if(debug) printf("MWindow::create_objects %d vwindows=%d show_vwindow=%d\n",
1930 session->show_vwindow);
1932 // Show all vwindows
1933 // if(session->show_vwindow) {
1934 // for(int j = 0; j < vwindows.size(); j++) {
1935 // VWindow *vwindow = vwindows[j];
1936 // if( !vwindow->is_running() ) continue;
1937 // if(debug) printf("MWindow::create_objects %d vwindow=%p\n",
1940 // if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1941 // vwindow->gui->lock_window("MWindow::create_objects 1");
1942 // if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1943 // vwindow->gui->show_window();
1944 // if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1945 // vwindow->gui->unlock_window();
1950 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1952 if(session->show_cwindow)
1954 cwindow->gui->lock_window("MWindow::create_objects 1");
1955 cwindow->gui->show_window();
1956 cwindow->gui->unlock_window();
1959 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1960 if(session->show_awindow)
1962 awindow->gui->lock_window("MWindow::create_objects 1");
1963 awindow->gui->show_window();
1964 awindow->gui->unlock_window();
1967 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1968 if(session->show_lwindow)
1970 lwindow->gui->lock_window("MWindow::create_objects 1");
1971 lwindow->gui->show_window();
1972 lwindow->gui->unlock_window();
1975 if(debug) printf("MWindow::create_objects %d total_time=%d gwindow=%p\n",
1977 (int)timer.get_difference(),
1979 if(session->show_gwindow)
1981 gwindow->gui->lock_window("MWindow::create_objects 1");
1982 gwindow->gui->show_window();
1983 gwindow->gui->unlock_window();
1986 if(debug) PRINT_TRACE
1988 gui->lock_window("MWindow::create_objects 1");
1989 gui->mainmenu->load_defaults(defaults);
1990 gui->mainmenu->update_toggles(0);
1991 gui->update_patchbay();
1992 gui->draw_canvas(0, 0);
1993 gui->draw_cursor(1);
1995 gui->raise_window();
1996 gui->unlock_window();
1998 if(debug) PRINT_TRACE
2000 if(preferences->use_tipwindow)
2002 if(debug) PRINT_TRACE
2004 gui->add_keyboard_listener(
2005 (int (BC_WindowBase::*)(BC_WindowBase *))
2006 &MWindowGUI::keyboard_listener);
2010 if(debug) PRINT_TRACE
2012 BC_WindowBase::get_resources()->vframe_shm = 1;
2016 void MWindow::show_splash()
2018 #include "data/heroine_logo9_png.h"
2019 VFrame *frame = new VFramePng(heroine_logo9_png);
2020 BC_DisplayInfo dpyi;
2021 int rw = dpyi.get_root_w(), rh = dpyi.get_root_h();
2022 int rr = (rw < rh ? rw : rh) / 4;
2023 splash_window = new SplashGUI(frame, rr, rr);
2024 splash_window->create_objects();
2027 void MWindow::hide_splash()
2030 delete splash_window;
2035 void MWindow::start()
2039 // vwindows[DEFAULT_VWINDOW]->start();
2050 playback_3d->start();
2059 void MWindow::show_vwindow()
2061 int total_running = 0;
2062 session->show_vwindow = 1;
2064 //printf("MWindow::show_vwindow %d %d\n", __LINE__, vwindows.size());
2065 // Raise all windows which are visible
2066 for(int j = 0; j < vwindows.size(); j++) {
2067 VWindow *vwindow = vwindows[j];
2068 if( !vwindow->is_running() ) continue;
2069 vwindow->gui->lock_window("MWindow::show_vwindow");
2070 vwindow->gui->show_window(0);
2071 vwindow->gui->raise_window();
2072 vwindow->gui->flush();
2073 vwindow->gui->unlock_window();
2077 // If no windows visible
2080 get_viewer(1, DEFAULT_VWINDOW);
2083 gui->mainmenu->show_vwindow->set_checked(1);
2086 void MWindow::show_awindow()
2088 session->show_awindow = 1;
2089 awindow->gui->lock_window("MWindow::show_awindow");
2090 awindow->gui->show_window();
2091 awindow->gui->raise_window();
2092 awindow->gui->flush();
2093 awindow->gui->unlock_window();
2094 gui->mainmenu->show_awindow->set_checked(1);
2097 char *MWindow::get_cwindow_display()
2099 char *x11_host = screens < 2 || session->window_config == 0 ?
2100 session->a_x11_host : session->b_x11_host;
2101 return *x11_host ? x11_host : 0;
2104 void MWindow::show_cwindow()
2106 session->show_cwindow = 1;
2107 cwindow->show_window();
2108 gui->mainmenu->show_cwindow->set_checked(1);
2111 void MWindow::show_gwindow()
2113 session->show_gwindow = 1;
2115 gwindow->gui->lock_window("MWindow::show_gwindow");
2116 gwindow->gui->show_window();
2117 gwindow->gui->raise_window();
2118 gwindow->gui->flush();
2119 gwindow->gui->unlock_window();
2121 gui->mainmenu->show_gwindow->set_checked(1);
2124 void MWindow::show_lwindow()
2126 session->show_lwindow = 1;
2127 lwindow->gui->lock_window("MWindow::show_lwindow");
2128 lwindow->gui->show_window();
2129 lwindow->gui->raise_window();
2130 lwindow->gui->flush();
2131 lwindow->gui->unlock_window();
2132 gui->mainmenu->show_lwindow->set_checked(1);
2135 int MWindow::tile_windows(int window_config)
2137 int need_reload = 0;
2138 int play_config = window_config==0 ? 0 : 1;
2139 edl->session->playback_config->load_defaults(defaults, play_config);
2140 session->default_window_positions(window_config);
2141 if( screens == 1 ) {
2142 gui->default_positions();
2143 sync_parameters(CHANGE_ALL);
2150 void MWindow::toggle_loop_playback()
2152 edl->local_session->loop_playback = !edl->local_session->loop_playback;
2153 set_loop_boundaries();
2156 gui->draw_overlays(1);
2157 sync_parameters(CHANGE_PARAMS);
2160 //void MWindow::set_titles(int value)
2162 // edl->session->show_titles = value;
2163 // trackmovement(edl->local_session->track_start);
2166 void MWindow::set_screens(int value)
2171 void MWindow::set_auto_keyframes(int value, int lock_mwindow, int lock_cwindow)
2173 if(lock_mwindow) gui->lock_window("MWindow::set_auto_keyframes");
2174 edl->session->auto_keyframes = value;
2175 gui->mbuttons->edit_panel->keyframe->update(value);
2177 if(lock_mwindow) gui->unlock_window();
2179 if(lock_cwindow) cwindow->gui->lock_window("MWindow::set_auto_keyframes");
2180 cwindow->gui->edit_panel->keyframe->update(value);
2181 cwindow->gui->flush();
2182 if(lock_cwindow) cwindow->gui->unlock_window();
2185 void MWindow::set_keyframe_type(int mode)
2187 gui->lock_window("MWindow::set_keyframe_type");
2188 edl->local_session->floatauto_type = mode;
2189 gui->mainmenu->update_toggles(0);
2190 gui->unlock_window();
2193 int MWindow::set_editing_mode(int new_editing_mode, int lock_mwindow, int lock_cwindow)
2195 if(lock_mwindow) gui->lock_window("MWindow::set_editing_mode");
2196 edl->session->editing_mode = new_editing_mode;
2197 gui->mbuttons->edit_panel->editing_mode = edl->session->editing_mode;
2198 gui->mbuttons->edit_panel->update();
2199 gui->set_editing_mode(1);
2200 if(lock_mwindow) gui->unlock_window();
2203 if(lock_cwindow) cwindow->gui->lock_window("MWindow::set_editing_mode");
2204 cwindow->gui->edit_panel->update();
2205 cwindow->gui->edit_panel->editing_mode = edl->session->editing_mode;
2206 if(lock_cwindow) cwindow->gui->unlock_window();
2210 void MWindow::toggle_editing_mode()
2212 int mode = edl->session->editing_mode;
2213 if( mode == EDITING_ARROW )
2214 set_editing_mode(EDITING_IBEAM, 0, 1);
2216 set_editing_mode(EDITING_ARROW, 0, 1);
2220 void MWindow::set_labels_follow_edits(int value)
2222 gui->lock_window("MWindow::set_labels_follow_edits");
2223 edl->session->labels_follow_edits = value;
2224 gui->mbuttons->edit_panel->locklabels->update(value);
2225 gui->mainmenu->labels_follow_edits->set_checked(value);
2227 gui->unlock_window();
2230 void MWindow::sync_parameters(int change_type)
2232 if( in_destructor ) return;
2234 // Sync engines which are playing back
2235 if(cwindow->playback_engine->is_playing_back)
2237 if(change_type == CHANGE_PARAMS)
2239 // TODO: block keyframes until synchronization is done
2240 cwindow->playback_engine->sync_parameters(edl);
2245 int command = cwindow->playback_engine->command->command;
2246 cwindow->playback_engine->que->send_command(STOP,
2250 // Waiting for tracking to finish would make the restart position more
2251 // accurate but it can't lock the window to stop tracking for some reason.
2252 // Not waiting for tracking gives a faster response but restart position is
2253 // only as accurate as the last tracking update.
2254 cwindow->playback_engine->interrupt_playback(0);
2255 cwindow->playback_engine->que->send_command(command,
2264 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2271 void MWindow::age_caches()
2273 // printf("MWindow::age_caches %d %lld %lld %lld %lld\n",
2275 // preferences->cache_size,
2276 // audio_cache->get_memory_usage(1),
2277 // video_cache->get_memory_usage(1),
2278 // frame_cache->get_memory_usage(),
2279 // wave_cache->get_memory_usage(),
2281 frame_cache->age_cache(512);
2282 wave_cache->age_cache(8192);
2284 int64_t memory_usage;
2285 int64_t prev_memory_usage = 0;
2287 int64_t video_size = (int64_t)(preferences->cache_size * 0.80);
2288 while( !result && prev_memory_usage !=
2289 (memory_usage=video_cache->get_memory_usage(1)) &&
2290 memory_usage > video_size ) {
2291 video_cache->delete_oldest();
2292 prev_memory_usage = memory_usage;
2295 prev_memory_usage = 0;
2297 int64_t audio_size = (int64_t)(preferences->cache_size * 0.20);
2298 while( !result && prev_memory_usage !=
2299 (memory_usage=audio_cache->get_memory_usage(1)) &&
2300 memory_usage > audio_size ) {
2301 audio_cache->delete_oldest();
2302 prev_memory_usage = memory_usage;
2306 void MWindow::reset_android_remote()
2308 gui->use_android_remote(preferences->android_remote);
2312 void MWindow::show_keyframe_gui(Plugin *plugin)
2314 keyframe_gui_lock->lock("MWindow::show_keyframe_gui");
2315 // Find existing thread
2316 for(int i = 0; i < keyframe_threads->size(); i++)
2318 if(keyframe_threads->get(i)->plugin == plugin)
2320 keyframe_threads->get(i)->start_window(plugin, 0);
2321 keyframe_gui_lock->unlock();
2326 // Find unused thread
2327 for(int i = 0; i < keyframe_threads->size(); i++)
2329 if(!keyframe_threads->get(i)->plugin)
2331 keyframe_threads->get(i)->start_window(plugin, 0);
2332 keyframe_gui_lock->unlock();
2337 // Create new thread
2338 KeyFrameThread *thread = new KeyFrameThread(this);
2339 keyframe_threads->append(thread);
2340 thread->start_window(plugin, 0);
2342 keyframe_gui_lock->unlock();
2349 void MWindow::show_plugin(Plugin *plugin)
2354 // Remove previously deleted plugin GUIs
2355 dead_plugin_lock->lock("MWindow::show_plugin");
2356 dead_plugins->remove_all_objects();
2357 dead_plugin_lock->unlock();
2359 //printf("MWindow::show_plugin %d\n", __LINE__);
2363 plugin_gui_lock->lock("MWindow::show_plugin");
2364 for(int i = 0; i < plugin_guis->total; i++)
2366 // Pointer comparison
2367 if(plugin_guis->get(i)->plugin == plugin)
2369 plugin_guis->get(i)->raise_window();
2376 //printf("MWindow::show_plugin 1\n");
2381 printf("MWindow::show_plugin track not defined.\n");
2383 PluginServer *server = scan_plugindb(plugin->title,
2384 plugin->track->data_type);
2386 //printf("MWindow::show_plugin %p %d\n", server, server->uses_gui);
2387 if(server && server->uses_gui)
2389 PluginServer *gui = new PluginServer(*server);
2390 plugin_guis->append(gui);
2391 // Needs mwindow to do GUI
2392 gui->set_mwindow(this);
2393 gui->open_plugin(0, preferences, edl, plugin);
2398 plugin_gui_lock->unlock();
2399 //printf("MWindow::show_plugin %d\n", __LINE__);
2402 //printf("MWindow::show_plugin 2\n");
2405 void MWindow::hide_plugin(Plugin *plugin, int lock)
2408 // Update the toggle
2409 gui->lock_window("MWindow::hide_plugin");
2410 gui->update(0, 1, 0, 0, 0, 0, 0);
2411 gui->unlock_window();
2413 if(lock) plugin_gui_lock->lock("MWindow::hide_plugin");
2414 for(int i = 0; i < plugin_guis->total; i++)
2416 if(plugin_guis->get(i)->plugin == plugin)
2418 PluginServer *ptr = plugin_guis->get(i);
2419 plugin_guis->remove(ptr);
2420 if(lock) plugin_gui_lock->unlock();
2421 // Last command executed in client side close
2422 // Schedule for deletion
2429 if(lock) plugin_gui_lock->unlock();
2432 void MWindow::delete_plugin(PluginServer *plugin)
2434 dead_plugin_lock->lock("MWindow::delete_plugin");
2435 dead_plugins->append(plugin);
2436 dead_plugin_lock->unlock();
2439 void MWindow::hide_plugins()
2441 plugin_gui_lock->lock("MWindow::hide_plugins 1");
2442 while(plugin_guis->size())
2444 PluginServer *ptr = plugin_guis->get(0);
2445 plugin_guis->remove(ptr);
2446 plugin_gui_lock->unlock();
2447 // Last command executed in client side close
2448 // Schedule for deletion
2451 plugin_gui_lock->lock("MWindow::hide_plugins 2");
2453 plugin_gui_lock->unlock();
2455 hide_keyframe_guis();
2458 void MWindow::hide_keyframe_guis()
2460 keyframe_gui_lock->lock("MWindow::hide_keyframe_guis");
2461 for(int i = 0; i < keyframe_threads->size(); i++)
2463 keyframe_threads->get(i)->close_window();
2465 keyframe_gui_lock->unlock();
2468 void MWindow::hide_keyframe_gui(Plugin *plugin)
2470 keyframe_gui_lock->lock("MWindow::hide_keyframe_gui");
2471 for(int i = 0; i < keyframe_threads->size(); i++)
2473 if(keyframe_threads->get(i)->plugin == plugin)
2475 keyframe_threads->get(i)->close_window();
2479 keyframe_gui_lock->unlock();
2482 void MWindow::update_keyframe_guis()
2484 // Send new configuration to keyframe GUI's
2485 keyframe_gui_lock->lock("MWindow::update_keyframe_guis");
2486 for(int i = 0; i < keyframe_threads->size(); i++)
2488 KeyFrameThread *ptr = keyframe_threads->get(i);
2489 if(edl->tracks->plugin_exists(ptr->plugin))
2493 ptr->close_window();
2496 keyframe_gui_lock->unlock();
2499 void MWindow::update_plugin_guis(int do_keyframe_guis)
2501 // Send new configuration to plugin GUI's
2502 plugin_gui_lock->lock("MWindow::update_plugin_guis");
2504 for(int i = 0; i < plugin_guis->size(); i++)
2506 PluginServer *ptr = plugin_guis->get(i);
2507 if(edl->tracks->plugin_exists(ptr->plugin))
2511 // Schedule for deletion if no plugin
2512 plugin_guis->remove_number(i);
2521 // Change plugin variable if not visible
2522 Track *track = edl->tracks->first;
2525 for(int i = 0; i < track->plugin_set.size(); i++)
2527 Plugin *plugin = (Plugin*)track->plugin_set[i]->first;
2531 for(int i = 0; i < plugin_guis->size(); i++)
2533 PluginServer *server = plugin_guis->get(i);
2534 if(server->plugin == plugin)
2541 if(!got_it) plugin->show = 0;
2543 plugin = (Plugin*)plugin->next;
2547 track = track->next;
2550 plugin_gui_lock->unlock();
2553 if(do_keyframe_guis) update_keyframe_guis();
2556 int MWindow::plugin_gui_open(Plugin *plugin)
2559 plugin_gui_lock->lock("MWindow::plugin_gui_open");
2560 for(int i = 0; i < plugin_guis->total; i++)
2562 if(plugin_guis->get(i)->plugin->identical_location(plugin))
2568 plugin_gui_lock->unlock();
2572 void MWindow::render_plugin_gui(void *data, Plugin *plugin)
2574 plugin_gui_lock->lock("MWindow::render_plugin_gui");
2575 for(int i = 0; i < plugin_guis->total; i++)
2577 if(plugin_guis->get(i)->plugin->identical_location(plugin))
2579 plugin_guis->get(i)->render_gui(data);
2583 plugin_gui_lock->unlock();
2586 void MWindow::render_plugin_gui(void *data, int size, Plugin *plugin)
2588 plugin_gui_lock->lock("MWindow::render_plugin_gui");
2589 for(int i = 0; i < plugin_guis->total; i++)
2591 if(plugin_guis->get(i)->plugin->identical_location(plugin))
2593 plugin_guis->get(i)->render_gui(data, size);
2597 plugin_gui_lock->unlock();
2601 void MWindow::update_plugin_states()
2603 plugin_gui_lock->lock("MWindow::update_plugin_states");
2604 for(int i = 0; i < plugin_guis->total; i++)
2608 Plugin *src_plugin = plugin_guis->get(i)->plugin;
2609 PluginServer *src_plugingui = plugin_guis->get(i);
2611 // Search for plugin in EDL. Only the master EDL shows plugin GUIs.
2612 for(Track *track = edl->tracks->first;
2614 track = track->next)
2617 j < track->plugin_set.total && !result;
2620 PluginSet *plugin_set = track->plugin_set[j];
2621 for(Plugin *plugin = (Plugin*)plugin_set->first;
2623 plugin = (Plugin*)plugin->next)
2625 if(plugin == src_plugin &&
2626 !strcmp(plugin->title, src_plugingui->title)) result = 1;
2632 // Doesn't exist anymore
2635 hide_plugin(src_plugin, 0);
2639 plugin_gui_lock->unlock();
2643 void MWindow::update_plugin_titles()
2645 for(int i = 0; i < plugin_guis->total; i++)
2647 plugin_guis->get(i)->update_title();
2651 int MWindow::asset_to_edl(EDL *new_edl,
2653 RecordLabels *labels)
2655 const int debug = 0;
2656 if(debug) printf("MWindow::asset_to_edl %d new_asset->layers=%d\n",
2659 // Keep frame rate, sample rate, and output size unchanged.
2660 // These parameters would revert the project if VWindow displayed an asset
2661 // of different size than the project.
2662 if(new_asset->video_data)
2664 new_edl->session->video_tracks = new_asset->layers;
2667 new_edl->session->video_tracks = 0;
2669 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2675 if(new_asset->audio_data)
2677 new_edl->session->audio_tracks = new_asset->channels;
2680 new_edl->session->audio_tracks = 0;
2681 //printf("MWindow::asset_to_edl 2 %d %d\n", new_edl->session->video_tracks, new_edl->session->audio_tracks);
2683 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2684 new_edl->create_default_tracks();
2685 //printf("MWindow::asset_to_edl 2 %d %d\n", new_edl->session->video_tracks, new_edl->session->audio_tracks);
2686 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2690 //printf("MWindow::asset_to_edl 3\n");
2691 new_edl->insert_asset(new_asset,
2696 //printf("MWindow::asset_to_edl 3\n");
2697 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2699 // Align cursor on frames:: clip the new_edl to the minimum of the last joint frame.
2700 if(edl->session->cursor_on_frames)
2702 double length = new_edl->tracks->total_length();
2703 double edl_length = new_edl->tracks->total_length_framealigned(edl->session->frame_rate);
2704 new_edl->tracks->clear(length, edl_length, 1, 1);
2710 char string[BCTEXTLEN];
2712 fs.extract_name(string, new_asset->path);
2713 //printf("MWindow::asset_to_edl 3\n");
2715 strcpy(new_edl->local_session->clip_title, string);
2716 //printf("MWindow::asset_to_edl 4 %s\n", string);
2717 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2722 int MWindow::edl_to_nested(EDL *new_edl,
2726 // Keep frame rate, sample rate, and output size unchanged.
2727 // These parameters would revert the project if VWindow displayed an asset
2728 // of different size than the project.
2732 // Nest all video & audio outputs
2733 new_edl->session->video_tracks = 1;
2734 new_edl->session->audio_tracks = nested_edl->session->audio_channels;
2735 new_edl->create_default_tracks();
2739 new_edl->insert_asset(0,
2745 char string[BCTEXTLEN];
2747 fs.extract_name(string, nested_edl->path);
2748 //printf("MWindow::edl_to_nested %p %s\n", nested_edl, nested_edl->path);
2750 strcpy(new_edl->local_session->clip_title, string);
2755 // Reset everything after a load.
2756 void MWindow::update_project(int load_mode)
2758 const int debug = 0;
2760 if(debug) PRINT_TRACE
2762 edl->tracks->update_y_pixels(theme);
2764 if(debug) PRINT_TRACE
2766 if(load_mode == LOADMODE_REPLACE ||
2767 load_mode == LOADMODE_REPLACE_CONCATENATE)
2772 gui->update(1, 1, 1, 1, 1, 1, 1);
2773 if(debug) PRINT_TRACE
2774 gui->unlock_window();
2776 cwindow->gui->lock_window("MWindow::update_project 1");
2777 cwindow->update(0, 0, 1, 1, 1);
2778 cwindow->gui->unlock_window();
2780 if(debug) PRINT_TRACE
2782 // Close all the vwindows
2783 if(load_mode == LOADMODE_REPLACE ||
2784 load_mode == LOADMODE_REPLACE_CONCATENATE) {
2785 if(debug) PRINT_TRACE
2786 int first_vwindow = 0;
2787 if(session->show_vwindow) first_vwindow = 1;
2788 // Change visible windows to no source
2789 for(int i = 0; i < first_vwindow && i < vwindows.size(); i++) {
2790 VWindow *vwindow = vwindows[i];
2791 if( !vwindow->is_running() ) continue;
2792 vwindow->change_source(-1);
2795 // Close remaining windows
2796 for(int i = first_vwindow; i < vwindows.size(); i++) {
2797 VWindow *vwindow = vwindows[i];
2798 if( !vwindow->is_running() ) continue;
2799 vwindow->close_window();
2801 if(debug) PRINT_TRACE
2803 else if(vwindows.size()) {
2804 VWindow *vwindow = vwindows[DEFAULT_VWINDOW];
2805 if( vwindow->is_running() ) {
2806 vwindow->gui->lock_window("MWindow::update_project");
2808 vwindow->gui->unlock_window();
2812 if(debug) PRINT_TRACE
2813 cwindow->gui->lock_window("MWindow::update_project 2");
2814 cwindow->gui->timebar->update(0);
2815 cwindow->gui->unlock_window();
2817 if(debug) PRINT_TRACE
2818 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2823 awindow->gui->async_update_assets();
2824 if(debug) PRINT_TRACE
2826 gui->lock_window("MWindow::update_project");
2828 if(debug) PRINT_TRACE
2831 void MWindow::remove_indexfile(Indexable *indexable)
2833 if( !indexable->is_asset ) return;
2834 Asset *asset = (Asset *)indexable;
2836 IndexFile::delete_index(preferences, asset, ".toc");
2837 IndexFile::delete_index(preferences, asset, ".idx");
2838 IndexFile::delete_index(preferences, asset, ".mkr");
2841 void MWindow::rebuild_indices()
2843 for(int i = 0; i < session->drag_assets->total; i++)
2845 Indexable *indexable = session->drag_assets->get(i);
2846 //printf("MWindow::rebuild_indices 1 %s\n", indexable->path);
2847 remove_indexfile(indexable);
2848 // Schedule index build
2849 IndexState *index_state = indexable->index_state;
2850 index_state->index_status = INDEX_NOTTESTED;
2851 if( indexable->is_asset ) {
2852 Asset *asset = (Asset *)indexable;
2853 if( asset->format != FILE_PCM )
2854 asset->reset_audio();
2855 asset->reset_video();
2857 mainindexes->add_next_asset(0, indexable);
2859 mainindexes->start_build();
2863 void MWindow::save_backup()
2866 edl->set_path(session->filename);
2867 edl->save_xml(&file,
2871 file.terminate_string();
2872 char path[BCTEXTLEN];
2874 strcpy(path, BACKUP_PATH);
2875 fs.complete_path(path);
2877 if(file.write_to_file(path))
2880 sprintf(string2, _("Couldn't open %s for writing."), BACKUP_PATH);
2881 gui->show_message(string2);
2885 void MWindow::load_backup()
2887 ArrayList<char*> path_list;
2888 path_list.set_array_delete();
2890 char string[BCTEXTLEN];
2891 strcpy(string, BACKUP_PATH);
2893 fs.complete_path(string);
2895 path_list.append(out_path = new char[strlen(string) + 1]);
2896 strcpy(out_path, string);
2898 load_filenames(&path_list, LOADMODE_REPLACE, 0);
2899 edl->local_session->clip_title[0] = 0;
2900 // This is unique to backups since the path of the backup is different than the
2901 // path of the project.
2902 set_filename(edl->path);
2903 path_list.remove_all_objects();
2907 static inline int gcd(int m, int n)
2910 if( m < n ) { r = m; m = n; n = r; }
2911 while( (r = m % n) != 0 ) { m = n; n = r; }
2915 int MWindow::create_aspect_ratio(float &w, float &h, int width, int height)
2918 if(!width || !height) return 1;
2919 double ar = (double)width / height;
2920 // square-ish pixels
2921 if( EQUIV(ar, 1.0000) ) return 0;
2922 if( EQUIV(ar, 1.3333) ) { w = 4; h = 3; return 0; }
2923 if( EQUIV(ar, 1.7777) ) { w = 16; h = 9; return 0; }
2924 if( EQUIV(ar, 2.1111) ) { w = 19; h = 9; return 0; }
2925 if( EQUIV(ar, 2.2222) ) { w = 20; h = 9; return 0; }
2926 if( EQUIV(ar, 2.3333) ) { w = 21; h = 9; return 0; }
2927 int ww = width, hh = height;
2928 // numerator, denominator must be under mx
2929 int mx = 255, n = gcd(ww, hh);
2930 if( n > 1 ) { ww /= n; hh /= n; }
2931 // search near height in case extra/missing lines
2932 if( ww >= mx || hh >= mx ) {
2933 double err = height; // +/- 2 percent height
2934 for( int m=2*height/100, i=1; m>0; i=i>0 ? -i : (--m, -i+1) ) {
2935 int iw = width, ih = height+i;
2936 if( (n=gcd(iw, ih)) > 1 ) {
2937 int u = iw/n; if( u >= mx ) continue;
2938 int v = ih/n; if( v >= mx ) continue;
2939 double r = (double) u/v, er = fabs(ar-r);
2940 if( er >= err ) continue;
2941 err = er; ww = u; hh = v;
2950 void MWindow::reset_caches()
2952 frame_cache->remove_all();
2953 wave_cache->remove_all();
2954 audio_cache->remove_all();
2955 video_cache->remove_all();
2956 if( cwindow->playback_engine && cwindow->playback_engine->audio_cache )
2957 cwindow->playback_engine->audio_cache->remove_all();
2958 if( cwindow->playback_engine && cwindow->playback_engine->video_cache )
2959 cwindow->playback_engine->video_cache->remove_all();
2961 for(int i = 0; i < vwindows.size(); i++) {
2962 VWindow *vwindow = vwindows[i];
2963 if( !vwindow->is_running() ) continue;
2964 if(vwindow->playback_engine && vwindow->playback_engine->audio_cache)
2965 vwindow->playback_engine->audio_cache->remove_all();
2966 if(vwindow->playback_engine && vwindow->playback_engine->video_cache)
2967 vwindow->playback_engine->video_cache->remove_all();
2971 void MWindow::remove_asset_from_caches(Asset *asset)
2973 gui->resource_thread->get_video_source(0);
2974 gui->resource_thread->get_audio_source(0);
2975 frame_cache->remove_asset(asset);
2976 wave_cache->remove_asset(asset);
2977 audio_cache->delete_entry(asset);
2978 video_cache->delete_entry(asset);
2979 if( cwindow->playback_engine && cwindow->playback_engine->audio_cache )
2980 cwindow->playback_engine->audio_cache->delete_entry(asset);
2981 if( cwindow->playback_engine && cwindow->playback_engine->video_cache )
2982 cwindow->playback_engine->video_cache->delete_entry(asset);
2983 for(int i = 0; i < vwindows.size(); i++) {
2984 VWindow *vwindow = vwindows[i];
2985 if( !vwindow->is_running() ) continue;
2986 if(vwindow->playback_engine && vwindow->playback_engine->audio_cache)
2987 vwindow->playback_engine->audio_cache->delete_entry(asset);
2988 if(vwindow->playback_engine && vwindow->playback_engine->video_cache)
2989 vwindow->playback_engine->video_cache->delete_entry(asset);
2994 void MWindow::remove_assets_from_project(int push_undo, int redraw,
2995 ArrayList<Indexable*> *drag_assets, ArrayList<EDL*> *drag_clips)
2997 for(int i = 0; i < session->drag_assets->total; i++) {
2998 Indexable *indexable = session->drag_assets->get(i);
2999 if(indexable->is_asset) remove_asset_from_caches((Asset*)indexable);
3002 // Remove from VWindow.
3003 for(int i = 0; i < session->drag_clips->total; i++) {
3004 for(int j = 0; j < vwindows.size(); j++) {
3005 VWindow *vwindow = vwindows[j];
3006 if( !vwindow->is_running() ) continue;
3007 if(session->drag_clips->get(i) == vwindow->get_edl()) {
3008 vwindow->gui->lock_window("MWindow::remove_assets_from_project 1");
3009 vwindow->delete_source(1, 1);
3010 vwindow->gui->unlock_window();
3015 for(int i = 0; i < session->drag_assets->size(); i++) {
3016 for(int j = 0; j < vwindows.size(); j++) {
3017 VWindow *vwindow = vwindows[j];
3018 if( !vwindow->is_running() ) continue;
3019 if(session->drag_assets->get(i) == vwindow->get_source()) {
3020 vwindow->gui->lock_window("MWindow::remove_assets_from_project 2");
3021 vwindow->delete_source(1, 1);
3022 vwindow->gui->unlock_window();
3027 for(int i = 0; i < session->drag_assets->size(); i++) {
3028 Indexable *indexable = session->drag_assets->get(i);
3029 remove_indexfile(indexable);
3032 //printf("MWindow::rebuild_indices 1 %s\n", indexable->path);
3033 if(push_undo) undo->update_undo_before();
3034 if(drag_assets) edl->remove_from_project(drag_assets);
3035 if(drag_clips) edl->remove_from_project(session->drag_clips);
3036 if(redraw) save_backup();
3037 if(push_undo) undo->update_undo_after(_("remove assets"), LOAD_ALL);
3042 gui->lock_window("MWindow::remove_assets_from_project 3");
3050 gui->unlock_window();
3052 // Removes from playback here
3053 sync_parameters(CHANGE_ALL);
3056 awindow->gui->async_update_assets();
3059 void MWindow::remove_assets_from_disk()
3062 for(int i = 0; i < session->drag_assets->total; i++)
3064 remove(session->drag_assets->get(i)->path);
3067 remove_assets_from_project(1,
3069 session->drag_assets,
3070 session->drag_clips);
3073 void MWindow::dump_plugins(FILE *fp)
3075 if( !plugindb ) return;
3076 for(int i = 0; i < plugindb->total; i++)
3078 fprintf(fp, "type=%d audio=%d video=%d rt=%d multi=%d"
3079 " synth=%d transition=%d theme=%d %s\n",
3080 plugindb->get(i)->plugin_type,
3081 plugindb->get(i)->audio,
3082 plugindb->get(i)->video,
3083 plugindb->get(i)->realtime,
3084 plugindb->get(i)->multichannel,
3085 plugindb->get(i)->get_synthesis(),
3086 plugindb->get(i)->transition,
3087 plugindb->get(i)->theme,
3088 plugindb->get(i)->title);
3092 void MWindow::dump_edl(FILE *fp)
3098 void MWindow::dump_undo(FILE *fp)
3104 void MWindow::dump_exe(FILE *fp)
3106 char proc_path[BCTEXTLEN], exe_path[BCTEXTLEN];
3107 sprintf(proc_path, "/proc/%d/exe", (int)getpid());
3108 int len = readlink(proc_path, exe_path, sizeof(exe_path));
3109 if( len < 0 ) { fprintf(fp,"readlink: %m\n"); return; }
3112 if( stat(exe_path,&st) ) { fprintf(fp,"stat: %m\n"); return; }
3113 fprintf(fp, "path: %s = %9jd bytes\n",exe_path,st.st_size);
3114 int fd = open(exe_path,O_RDONLY);
3115 if( fd < 0 ) { fprintf(fp,"open: %m\n"); return; }
3116 uint8_t buf[65536]; SHA1 sha1;
3117 while( (len=read(fd,buf,sizeof(buf))) > 0 ) {
3118 sha1.addBytes(buf, len);
3121 fprintf(fp, "SHA1: ");
3122 uint8_t digest[20]; sha1.computeHash(digest);
3123 for( int i=0; i<20; ++i ) fprintf(fp, "%02x", digest[i]);
3128 void MWindow::trap_hook(FILE *fp, void *vp)
3130 MWindow *mwindow = (MWindow *)vp;
3131 fprintf(fp, "\nEXE:\n");
3132 mwindow->dump_exe(fp);
3133 fprintf(fp, "\nPLUGINS:\n");
3134 mwindow->dump_plugins(fp);
3135 fprintf(fp, "\nEDL:\n");
3136 mwindow->dump_edl(fp);
3137 fprintf(fp, "\nUNDO:\n");
3138 mwindow->dump_undo(fp);
3146 int MWindow::save_defaults()
3148 gui->save_defaults(defaults);
3149 edl->save_defaults(defaults);
3150 session->save_defaults(defaults);
3151 preferences->save_defaults(defaults);
3153 for(int i = 0; i < plugin_guis->total; i++)
3155 // Pointer comparison
3156 plugin_guis->get(i)->save_defaults();
3158 awindow->save_defaults(defaults);
3164 int MWindow::run_script(FileXML *script)
3166 int result = 0, result2 = 0;
3167 while(!result && !result2)
3169 result = script->read_tag();
3172 if(script->tag.title_is("new_project"))
3174 // Run new in immediate mode.
3175 // gui->mainmenu->new_project->run_script(script);
3178 if(script->tag.title_is("record"))
3180 // Run record as a thread. It is a terminal command.
3182 // Will read the complete scipt file without letting record read it if not
3188 printf("MWindow::run_script: Unrecognized command: %s\n",script->tag.get_title() );
3195 // ================================= synchronization
3198 int MWindow::interrupt_indexes()
3200 mainprogress->cancelled = 1;
3201 mainindexes->interrupt_build();
3207 void MWindow::next_time_format()
3209 switch(edl->session->time_format)
3211 case TIME_HMS: edl->session->time_format = TIME_HMSF; break;
3212 case TIME_HMSF: edl->session->time_format = TIME_SAMPLES; break;
3213 case TIME_SAMPLES: edl->session->time_format = TIME_SAMPLES_HEX; break;
3214 case TIME_SAMPLES_HEX: edl->session->time_format = TIME_FRAMES; break;
3215 case TIME_FRAMES: edl->session->time_format = TIME_FEET_FRAMES; break;
3216 case TIME_FEET_FRAMES: edl->session->time_format = TIME_SECONDS; break;
3217 case TIME_SECONDS: edl->session->time_format = TIME_HMS; break;
3220 time_format_common();
3223 void MWindow::prev_time_format()
3225 switch(edl->session->time_format)
3227 case TIME_HMS: edl->session->time_format = TIME_SECONDS; break;
3228 case TIME_SECONDS: edl->session->time_format = TIME_FEET_FRAMES; break;
3229 case TIME_FEET_FRAMES: edl->session->time_format = TIME_FRAMES; break;
3230 case TIME_FRAMES: edl->session->time_format = TIME_SAMPLES_HEX; break;
3231 case TIME_SAMPLES_HEX: edl->session->time_format = TIME_SAMPLES; break;
3232 case TIME_SAMPLES: edl->session->time_format = TIME_HMSF; break;
3233 case TIME_HMSF: edl->session->time_format = TIME_HMS; break;
3236 time_format_common();
3239 void MWindow::time_format_common()
3241 gui->lock_window("MWindow::next_time_format");
3242 gui->redraw_time_dependancies();
3245 char string[BCTEXTLEN], string2[BCTEXTLEN];
3246 sprintf(string, _("Using %s"), Units::print_time_format(edl->session->time_format, string2));
3247 gui->show_message(string);
3249 gui->unlock_window();
3253 int MWindow::set_filename(const char *filename)
3255 if( filename != session->filename )
3256 strcpy(session->filename, filename);
3257 if( filename != edl->path )
3258 strcpy(edl->path, filename);
3262 if(filename[0] == 0)
3264 gui->set_title(PROGRAM_NAME);
3269 char string[BCTEXTLEN], string2[BCTEXTLEN];
3270 dir.extract_name(string, filename);
3271 sprintf(string2, PROGRAM_NAME ": %s", string);
3272 gui->set_title(string2);
3285 int MWindow::set_loop_boundaries()
3287 double start = edl->local_session->get_selectionstart();
3288 double end = edl->local_session->get_selectionend();
3296 if(edl->tracks->total_length())
3299 end = edl->tracks->total_length();
3306 if(edl->local_session->loop_playback && start != end)
3308 edl->local_session->loop_start = start;
3309 edl->local_session->loop_end = end;
3320 int MWindow::reset_meters()
3322 cwindow->gui->lock_window("MWindow::reset_meters 1");
3323 cwindow->gui->meters->reset_meters();
3324 cwindow->gui->unlock_window();
3326 for(int j = 0; j < vwindows.size(); j++) {
3327 VWindow *vwindow = vwindows[j];
3328 if( !vwindow->is_running() ) continue;
3329 vwindow->gui->lock_window("MWindow::reset_meters 2");
3330 vwindow->gui->meters->reset_meters();
3331 vwindow->gui->unlock_window();
3334 lwindow->gui->lock_window("MWindow::reset_meters 3");
3335 lwindow->gui->panel->reset_meters();
3336 lwindow->gui->unlock_window();
3338 gui->lock_window("MWindow::reset_meters 4");
3339 gui->reset_meters();
3340 gui->unlock_window();
3345 void MWindow::resync_guis()
3349 gui->lock_window("MWindow::resync_guis");
3350 gui->update(1, 1, 1, 1, 1, 1, 0);
3351 gui->unlock_window();
3353 cwindow->gui->lock_window("MWindow::resync_guis");
3354 cwindow->gui->resize_event(cwindow->gui->get_w(),
3355 cwindow->gui->get_h());
3356 int channels = edl->session->audio_channels;
3357 cwindow->gui->meters->set_meters(channels, 1);
3358 cwindow->gui->flush();
3359 cwindow->gui->unlock_window();
3361 for(int i = 0; i < vwindows.size(); i++) {
3362 VWindow *vwindow = vwindows[i];
3363 if( !vwindow->is_running() ) continue;
3364 vwindow->gui->lock_window("MWindow::resync_guis");
3365 vwindow->gui->resize_event(vwindow->gui->get_w(),
3366 vwindow->gui->get_h());
3367 vwindow->gui->meters->set_meters(channels, 1);
3368 vwindow->gui->flush();
3369 vwindow->gui->unlock_window();
3372 lwindow->gui->lock_window("MWindow::resync_guis");
3373 lwindow->gui->panel->set_meters(channels, 1);
3374 lwindow->gui->flush();
3375 lwindow->gui->unlock_window();
3378 if(((edl->session->output_w % 4) ||
3379 (edl->session->output_h % 4)) &&
3380 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
3382 MainError::show_error(
3383 _("This project's dimensions are not multiples of 4 so\n"
3384 "it can't be rendered by OpenGL."));
3389 sync_parameters(CHANGE_ALL);
3392 int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tracks)
3394 File *file = new File;
3395 EDLSession *session = edl->session;
3396 double old_framerate = session->frame_rate;
3397 double old_samplerate = session->sample_rate;
3398 int result = file->open_file(preferences, asset, 1, 0);
3399 if( !result && delete_tracks > 0 )
3400 undo->update_undo_before();
3401 if( !result && asset->get_video_layers() > 0 ) {
3402 // try to get asset up to date, may fail
3403 file->select_video_stream(asset, vstream);
3404 // either way use what was/is there.
3405 double framerate = asset->get_frame_rate();
3406 int width = asset->get_w();
3407 int height = asset->get_h();
3408 // must be multiple of 4 for opengl
3409 width = (width+3) & ~3; height = (height+3) & ~3;
3410 int driver = session->playback_config->vconfig->driver;
3411 int color_model = file->get_best_colormodel(asset, driver);
3412 // color_model = BC_CModels::is_yuv(color_model) ?
3413 // BC_CModels::has_alpha(color_model) ? BC_YUVA8888 : BC_YUV888 :
3414 // BC_CModels::is_float(color_model) ?
3415 // BC_CModels::has_alpha(color_model) ? BC_RGBA_FLOAT : BC_RGB_FLOAT :
3416 // BC_CModels::has_alpha(color_model) ? BC_RGBA8888 : BC_RGB888;
3417 // have alpha for now
3418 color_model = BC_CModels::is_yuv(color_model) ? BC_YUVA8888 :
3419 BC_CModels::is_float(color_model) ? BC_RGBA_FLOAT : BC_RGBA8888;
3420 session->color_model = color_model;
3421 session->output_w = width;
3422 session->output_h = height;
3423 session->frame_rate = framerate;
3424 // not, asset->actual_width/actual_height
3425 asset->width = session->output_w;
3426 asset->height = session->output_h;
3427 asset->frame_rate = session->frame_rate;
3428 create_aspect_ratio(session->aspect_w, session->aspect_h,
3429 session->output_w, session->output_h);
3430 Track *track = edl->tracks->first;
3431 for( Track *next_track=0; track; track=next_track ) {
3432 next_track = track->next;
3433 if( track->data_type != TRACK_VIDEO ) continue;
3434 if( delete_tracks ) {
3435 Edit *edit = track->edits->first;
3436 for( Edit *next_edit=0; edit; edit=next_edit ) {
3437 next_edit = edit->next;
3438 if( edit->channel != vstream ||
3439 !edit->asset || !edit->asset->is_asset ||
3440 *asset != *edit->asset )
3444 if( track->edits->first ) {
3445 track->track_w = edl->session->output_w;
3446 track->track_h = edl->session->output_h;
3448 else if( delete_tracks )
3449 edl->tracks->delete_track(track);
3451 edl->resample(old_framerate, session->frame_rate, TRACK_VIDEO);
3453 if( !result && asset->channels > 0 ) {
3454 session->sample_rate = asset->get_sample_rate();
3455 int64_t channel_mask = 0;
3456 int astrm = file->get_audio_for_video(vstream, astream, channel_mask);
3457 if( astrm >= 0 ) file->select_audio_stream(asset, astrm);
3458 if( astrm < 0 || !channel_mask ) channel_mask = (1<<asset->channels)-1;
3460 for( uint64_t mask=channel_mask; mask!=0; mask>>=1 ) channels += mask & 1;
3461 if( channels > 6 ) channels = 6;
3462 session->audio_tracks = session->audio_channels = channels;
3463 switch( channels ) {
3465 session->achannel_positions[0] = 90;
3466 session->achannel_positions[1] = 150;
3467 session->achannel_positions[2] = 30;
3468 session->achannel_positions[3] = 210;
3469 session->achannel_positions[4] = 330;
3470 session->achannel_positions[5] = 270;
3473 session->achannel_positions[0] = 180;
3474 session->achannel_positions[1] = 0;
3477 remap_audio(MWindow::AUDIO_1_TO_1);
3479 if( delete_tracks ) {
3480 Track *track = edl->tracks->first;
3481 for( Track *next_track=0; track; track=next_track ) {
3482 next_track = track->next;
3483 if( track->data_type != TRACK_AUDIO ) continue;
3484 Edit *edit = track->edits->first;
3485 for( Edit *next_edit=0; edit; edit=next_edit ) {
3486 next_edit = edit->next;
3487 if( !((1<<edit->channel) & channel_mask) ||
3488 !edit->asset || !edit->asset->is_asset ||
3489 *asset != *edit->asset )
3492 if( !track->edits->first )
3493 edl->tracks->delete_track(track);
3497 edl->resample(old_samplerate, session->sample_rate, TRACK_AUDIO);
3500 if( !result && delete_tracks > 0 ) {
3502 undo->update_undo_after(_("select asset"), LOAD_ALL);
3508 int MWindow::select_asset(int vtrack, int delete_tracks)
3510 Track *track = edl->tracks->get(vtrack, TRACK_VIDEO);
3511 if( !track ) return 1;
3512 Edit *edit = track->edits->first;
3513 if( !edit ) return 1;
3514 Asset *asset = edit->asset;
3515 if( !asset || !asset->is_asset ) return 1;
3516 return select_asset(asset, edit->channel, 0, delete_tracks);
3519 void MWindow::dump_plugindb(FILE *fp)
3521 if( !plugindb ) return;
3522 for(int i = 0; i < plugindb->total; i++)
3523 plugindb->get(i)->dump(fp);