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.
217 //printf("MWindow::~MWindow %d\n", __LINE__);
219 gui->remote_control->deactivate();
221 gui->channel_info->stop();
222 brender_lock->lock("MWindow::quit");
223 delete brender; brender = 0;
224 brender_lock->unlock();
225 delete create_bd; create_bd = 0;
226 delete create_dvd; create_dvd = 0;
227 delete batch_render; batch_render = 0;
229 if( commercials && !commercials->remove_user() ) commercials = 0;
231 // Save defaults for open plugins
232 plugin_gui_lock->lock("MWindow::~MWindow");
233 for(int i = 0; i < plugin_guis->size(); i++)
235 plugin_guis->get(i)->hide_gui();
237 plugin_gui_lock->unlock();
238 hide_keyframe_guis();
241 // Give up and go to a movie
242 // cant run valgrind if this is used
244 gui->del_keyboard_listener(
245 (int (BC_WindowBase::*)(BC_WindowBase *))
246 &MWindowGUI::keyboard_listener);
248 // release the hounds
249 if( awindow && awindow->gui ) awindow->gui->close(0);
250 if( cwindow && cwindow->gui ) cwindow->gui->close(0);
251 if( lwindow && lwindow->gui ) lwindow->gui->close(0);
252 if( gwindow && gwindow->gui ) gwindow->gui->close(0);
253 if( twindow && twindow->is_running() ) twindow->close_window();
254 if( wwindow && wwindow->is_running() ) wwindow->close_window();
255 vwindows.remove_all_objects();
257 if( awindow ) awindow->join();
258 if( cwindow ) cwindow->join();
259 if( lwindow ) lwindow->join();
260 if( twindow ) twindow->join();
261 if( wwindow ) wwindow->join();
262 if( gwindow ) gwindow->join();
265 // one at a time, or nouveau chokes
266 #define close_gui(win) if( win ) { \
267 if( win->gui ) win->gui->close(0); \
275 vwindows.remove_all_objects();
280 dead_plugins->remove_all();
282 keyframe_threads->remove_all_objects();
283 if( !edl->Garbage::remove_user() ) edl = 0;
284 colormodels.remove_all_objects();
286 delete render; render = 0;
287 delete awindow; awindow = 0;
288 delete lwindow; lwindow = 0;
289 delete twindow; twindow = 0;
290 delete wwindow; wwindow = 0;
291 delete gwindow; gwindow = 0;
292 // must be last or nouveau chokes
293 delete cwindow; cwindow = 0;
294 //delete file_server; file_server = 0; // reusable
295 delete mainindexes; mainindexes = 0;
296 delete mainprogress; mainprogress = 0;
297 delete audio_cache; audio_cache = 0; // delete the cache after the assets
298 delete video_cache; video_cache = 0; // delete the cache after the assets
299 delete frame_cache; frame_cache = 0;
300 delete wave_cache; wave_cache = 0;
301 delete plugin_guis; plugin_guis = 0;
302 delete dead_plugins; dead_plugins = 0;
303 delete keyframe_threads; keyframe_threads = 0;
304 delete undo; undo = 0;
305 delete preferences; preferences = 0;
306 delete session; session = 0;
307 delete defaults; defaults = 0;
308 delete assets; assets = 0;
309 delete splash_window; splash_window = 0;
310 delete theme; theme = 0;
312 delete channeldb_buz;
313 delete channeldb_v4l2jpeg;
314 // This must be last thread to exit
315 delete playback_3d; playback_3d = 0;
316 delete dead_plugin_lock;
317 delete plugin_gui_lock;
318 delete vwindows_lock;
320 delete keyframe_gui_lock;
321 sighandler->terminate();
326 void MWindow::quit(int unlock)
329 if(unlock) gui->unlock_window();
331 brender_lock->lock("MWindow::quit");
332 delete brender; brender = 0;
333 brender_lock->unlock();
339 if(unlock) gui->lock_window("MWindow::quit");
342 void MWindow::init_error()
344 MainError::init_error(this);
347 void MWindow::finit_error()
349 MainError::finit_error();
352 void MWindow::create_defaults_path(char *string, const char *config_file)
354 // set the .bcast path
357 sprintf(string, "%s", BCASTDIR);
358 fs.complete_path(string);
359 if(!fs.is_dir(string))
360 fs.create_dir(string);
363 strcat(string, config_file);
365 const char *MWindow::default_std()
371 if((fd = open(TIMEZONE_NAME, O_RDONLY)) >= 0)
373 l = read(fd, buf, BCTEXTLEN);
378 if(buf[l - 1] == '\n')
385 if((l = readlink(LOCALTIME_LINK, buf, BCTEXTLEN)) > 0)
388 if( (p=strstr(buf, ZONEINFO_STR)) != 0 )
390 p += strlen(ZONEINFO_STR);
399 for(i = 0; ntsc_zones[i]; i++)
400 if(strcmp(ntsc_zones[i], p) == 0)
406 void MWindow::fill_preset_defaults(const char *preset, EDLSession *session)
408 struct formatpresets *fpr;
410 for(fpr = &format_presets[0]; fpr->name; fpr++)
412 if(strcmp(fpr->name, preset) == 0)
414 session->audio_channels = fpr->audio_channels;
415 session->audio_tracks = fpr->audio_tracks;
416 session->sample_rate = fpr->sample_rate;
417 session->video_channels = fpr->video_channels;
418 session->video_tracks = fpr->video_tracks;
419 session->frame_rate = fpr->frame_rate;
420 session->output_w = fpr->output_w;
421 session->output_h = fpr->output_h;
422 session->aspect_w = fpr->aspect_w;
423 session->aspect_h = fpr->aspect_h;
424 session->interlace_mode = fpr->interlace_mode;
425 session->color_model = fpr->color_model;
431 const char *MWindow::get_preset_name(int index)
433 if(index < 0 || index >= (int)MAX_NUM_PRESETS)
435 return format_presets[index].name;
439 void MWindow::init_defaults(BC_Hash* &defaults, char *config_path)
441 char path[BCTEXTLEN];
442 // Use user supplied path
444 strcpy(path, config_path);
446 create_defaults_path(path, CONFIG_FILE);
448 defaults = new BC_Hash(path);
452 void MWindow::get_plugin_path(char *path, const char *plug_dir, const char *fs_path)
454 char *base_path = FileSystem::basepath(fs_path), *bp = base_path;
456 const char *dp = plug_dir;
457 while( *bp && *dp && *bp == *dp ) { ++bp; ++dp; }
458 bp = !*dp && *bp == '/' ? bp+1 : base_path;
464 int MWindow::load_plugin_index(MWindow *mwindow, const char *index_path, const char *plugin_dir)
467 FILE *fp = fopen(index_path, "r");
471 char index_line[BCTEXTLEN];
472 int index_version = -1, len = strlen(plugin_dir);
473 if( !fgets(index_line, BCTEXTLEN, fp) ||
474 sscanf(index_line, "%d", &index_version) != 1 ||
475 index_version != PLUGIN_FILE_VERSION ||
476 !fgets(index_line, BCTEXTLEN, fp) ||
477 (int)strlen(index_line)-1 != len || index_line[len] != '\n' ||
478 strncmp(index_line, plugin_dir, len) != 0 ) ret = 1;
480 ArrayList<PluginServer*> plugins;
481 while( !ret && !feof(fp) && fgets(index_line, BCTEXTLEN, fp) ) {
482 if( index_line[0] == ';' ) continue;
483 if( index_line[0] == '#' ) continue;
484 int type = PLUGIN_TYPE_UNKNOWN;
485 char path[BCTEXTLEN], title[BCTEXTLEN];
487 if( PluginServer::scan_table(index_line, type, path, title, mtime) ) {
490 PluginServer *server = 0;
492 case PLUGIN_TYPE_BUILTIN:
493 case PLUGIN_TYPE_EXECUTABLE:
494 case PLUGIN_TYPE_LADSPA: {
495 char plugin_path[BCTEXTLEN]; struct stat st;
496 sprintf(plugin_path, "%s/%s", plugin_dir, path);
497 if( stat(plugin_path, &st) || st.st_mtime != mtime ) {
500 server = new PluginServer(mwindow, plugin_path, type);
502 case PLUGIN_TYPE_FFMPEG: {
503 server = new_ffmpeg_server(mwindow, path);
506 if( !server ) continue;
507 plugins.append(server);
508 // Create plugin server from index entry
509 server->set_title(title);
510 if( server->read_table(index_line) ) {
517 ret = check_plugin_index(plugins, plugin_dir, ".");
520 add_plugins(plugins);
522 plugins.remove_all_objects();
527 int MWindow::check_plugin_index(ArrayList<PluginServer*> &plugins,
528 const char *plug_dir, const char *plug_path)
530 char plugin_path[BCTEXTLEN];
531 sprintf(plugin_path, "%s/%s", plug_dir, plug_path);
533 fs.set_filter( "[*.plugin][*.so]" );
534 if( fs.update(plugin_path) )
537 for( int i=0; i<fs.dir_list.total; ++i ) {
538 char fs_path[BCTEXTLEN];
539 get_plugin_path(fs_path, 0, fs.dir_list[i]->path);
540 if( fs.is_dir(fs_path) ) {
541 get_plugin_path(plugin_path, plug_dir, fs_path);
542 if( check_plugin_index(plugins, plug_dir, plugin_path) )
545 else if( !plugin_exists(fs_path, plugins) )
552 int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences)
555 plugindb = new ArrayList<PluginServer*>;
557 char index_path[BCTEXTLEN], plugin_path[BCTEXTLEN];
558 create_defaults_path(index_path, PLUGIN_FILE);
559 char *plugin_dir = FileSystem::basepath(preferences->plugin_dir);
560 strcpy(plugin_path, plugin_dir); delete [] plugin_dir;
561 if( !load_plugin_index(mwindow, index_path, plugin_path) ) return 1;
562 printf("init plugin index: %s\n", plugin_path);
563 FILE *fp = fopen(index_path,"w");
565 fprintf(stderr,_("MWindow::init_plugins: "
566 "can't create plugin index: %s\n"), index_path);
569 fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
570 fprintf(fp, "%s\n", plugin_path);
571 init_plugin_index(mwindow, preferences, fp, plugin_path);
572 init_ffmpeg_index(mwindow, preferences, fp);
574 return load_plugin_index(mwindow, index_path, plugin_path);
577 int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences)
579 char *path = getenv("LADSPA_PATH");
580 char ladspa_path[BCTEXTLEN];
582 get_exe_path(ladspa_path);
583 strcat(ladspa_path, "/ladspa");
586 for( int len=0; *path; path+=len ) {
587 char *cp = strchr(path,':');
588 len = !cp ? strlen(path) : cp-path;
589 char index_path[BCTEXTLEN], plugin_path[BCTEXTLEN];
590 memcpy(plugin_path, path, len); plugin_path[len] = 0;
591 char *plugin_dir = FileSystem::basepath(plugin_path);
592 strcpy(plugin_path, plugin_dir); delete [] plugin_dir;
593 create_defaults_path(index_path, LADSPA_FILE);
594 cp = index_path + strlen(index_path);
595 for( char *bp=plugin_path; *bp!=0; ++bp )
596 *cp++ = *bp=='/' ? '_' : *bp;
598 if( !load_plugin_index(mwindow, index_path, plugin_path) ) continue;
599 if( init_ladspa_index(mwindow, preferences, index_path, plugin_path) ) continue;
600 load_plugin_index(mwindow, index_path, plugin_path);
605 void MWindow::init_plugin_index(MWindow *mwindow, Preferences *preferences,
606 FILE *fp, const char *plugin_dir)
608 int idx = PLUGIN_IDS;
610 for( int i=0; i<plugindb->size(); ++i ) {
611 PluginServer *server = plugindb->get(i);
612 if( server->dir_idx >= idx )
613 idx = server->dir_idx+1;
616 scan_plugin_index(mwindow, preferences, fp, plugin_dir, ".", idx);
619 int MWindow::init_ladspa_index(MWindow *mwindow, Preferences *preferences,
620 const char *index_path, const char *plugin_dir)
622 char plugin_path[BCTEXTLEN], *path = FileSystem::basepath(plugin_dir);
623 strcpy(plugin_path, path); delete [] path;
624 printf("init ladspa index: %s\n", plugin_dir);
625 FILE *fp = fopen(index_path,"w");
627 fprintf(stderr,_("MWindow::init_ladspa_index: "
628 "can't create plugin index: %s\n"), index_path);
631 fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
632 fprintf(fp, "%s\n", plugin_dir);
633 init_plugin_index(mwindow, preferences, fp, plugin_path);
638 void MWindow::scan_plugin_index(MWindow *mwindow, Preferences *preferences, FILE *fp,
639 const char *plug_dir, const char *plug_path, int &idx)
641 char plugin_path[BCTEXTLEN];
642 sprintf(plugin_path, "%s/%s", plug_dir, plug_path);
644 fs.set_filter( "[*.plugin][*.so]" );
645 int result = fs.update(plugin_path);
646 if( result || !fs.dir_list.total ) return;
649 for( int i=0; i<fs.dir_list.total; ++i ) {
650 char fs_path[BCTEXTLEN], path[BCTEXTLEN];
651 get_plugin_path(fs_path, 0, fs.dir_list[i]->path);
652 get_plugin_path(path, plug_dir, fs_path);
653 if( fs.is_dir(fs_path) ) {
654 scan_plugin_index(mwindow, preferences, fp, plug_dir, path, idx);
657 if( plugin_exists(path) ) continue;
659 if( stat(fs_path, &st) ) continue;
660 int64_t mtime = st.st_mtime;
661 PluginServer server(mwindow, fs_path, PLUGIN_TYPE_UNKNOWN);
662 result = server.open_plugin(1, preferences, 0, 0);
664 server.write_table(fp, path, vis_id, mtime);
665 server.close_plugin();
667 else if( result == PLUGINSERVER_IS_LAD ) {
670 PluginServer ladspa(mwindow, fs_path, PLUGIN_TYPE_LADSPA);
671 ladspa.set_lad_index(lad_index++);
672 result = ladspa.open_plugin(1, preferences, 0, 0);
674 ladspa.write_table(fp, path, PLUGIN_LADSPA_ID, mtime);
675 ladspa.close_plugin();
681 void MWindow::add_plugins(ArrayList<PluginServer*> &plugins)
683 for( int i=0; i<plugins.size(); ++i )
684 plugindb->append(plugins[i]);
685 plugins.remove_all();
688 void MWindow::delete_plugins()
690 plugindb->remove_all_objects();
695 void MWindow::search_plugindb(int do_audio,
700 ArrayList<PluginServer*> &results)
703 for(int i = 0; i < MWindow::plugindb->total; i++)
705 PluginServer *current = MWindow::plugindb->get(i);
707 if(current->audio == do_audio &&
708 current->video == do_video &&
709 (current->realtime == is_realtime || is_realtime < 0) &&
710 current->transition == is_transition &&
711 current->theme == is_theme)
712 results.append(current);
715 // Alphabetize list by title
721 for(int i = 0; i < results.total - 1; i++)
723 PluginServer *value1 = results[i];
724 PluginServer *value2 = results[i + 1];
725 if(strcmp(_(value1->title), _(value2->title)) > 0)
729 results[i + 1] = value1;
735 PluginServer* MWindow::scan_plugindb(char *title,
740 // printf("MWindow::scan_plugindb data_type < 0\n");
744 for(int i = 0; i < plugindb->total; i++)
746 PluginServer *server = plugindb->get(i);
748 !strcasecmp(server->title, title) &&
750 (data_type == TRACK_AUDIO && server->audio) ||
751 (data_type == TRACK_VIDEO && server->video)))
752 return plugindb->get(i);
757 int MWindow::plugin_exists(const char *plugin_path, ArrayList<PluginServer*> &plugins)
759 for( int i=0; i<plugins.size(); ++i )
760 if( !strcmp(plugin_path, plugins[i]->get_path()) ) return 1;
764 int MWindow::plugin_exists(char *plugin_path)
766 return !plugindb ? 0 : plugin_exists(plugin_path, *plugindb);
769 void MWindow::init_preferences()
771 preferences = new Preferences;
772 preferences->load_defaults(defaults);
773 session = new MainSession(this);
774 session->load_defaults(defaults);
775 // set x11_host, screens, window_config
776 screens = session->set_default_x11_host();
777 BC_Signals::set_trap_path("/tmp/cinelerra_%d.dmp");
778 BC_Signals::set_trap_hook(trap_hook, this);
779 BC_Signals::set_catch_segv(preferences->trap_sigsegv);
780 BC_Signals::set_catch_intr(preferences->trap_sigintr);
783 void MWindow::clean_indexes()
788 int oldest_item = -1;
790 char string[BCTEXTLEN];
791 char string2[BCTEXTLEN];
793 // Delete extra indexes
794 fs.set_filter("*.idx");
795 fs.complete_path(preferences->index_directory);
796 fs.update(preferences->index_directory);
797 //printf("MWindow::clean_indexes 1 %d\n", fs.dir_list.total);
799 // Eliminate directories
804 for(int i = 0; i < fs.dir_list.total && !result; i++)
806 fs.join_names(string, preferences->index_directory, fs.dir_list[i]->name);
807 if(fs.is_dir(string))
809 delete fs.dir_list[i];
810 fs.dir_list.remove_number(i);
815 total_excess = fs.dir_list.total - preferences->index_count;
817 //printf("MWindow::clean_indexes 2 %d\n", fs.dir_list.total);
818 while(total_excess > 0)
821 for(int i = 0; i < fs.dir_list.total; i++)
823 fs.join_names(string, preferences->index_directory, fs.dir_list[i]->name);
825 if(i == 0 || fs.get_date(string) <= oldest)
827 oldest = fs.get_date(string);
835 fs.join_names(string,
836 preferences->index_directory,
837 fs.dir_list[oldest_item]->name);
838 //printf("MWindow::clean_indexes 1 %s\n", string);
840 perror("delete_indexes");
841 delete fs.dir_list[oldest_item];
842 fs.dir_list.remove_number(oldest_item);
844 // Remove table of contents if it exists
845 strcpy(string2, string);
846 char *ptr = strrchr(string2, '.');
849 //printf("MWindow::clean_indexes 2 %s\n", string2);
850 sprintf(ptr, ".toc");
852 sprintf(ptr, ".mkr");
861 void MWindow::init_awindow()
863 awindow = new AWindow(this);
864 awindow->create_objects();
867 void MWindow::init_gwindow()
869 gwindow = new GWindow(this);
870 gwindow->create_objects();
873 void MWindow::init_tipwindow()
876 twindow = new TipWindow(this);
880 void MWindow::show_warning(int *do_warning, const char *text)
882 if( do_warning && !*do_warning ) return;
884 wwindow = new WWindow(this);
885 wwindow->show_warning(do_warning, text);
888 void MWindow::init_theme()
893 PluginServer *theme_plugin = 0;
894 for(int i = 0; i < plugindb->total && !theme_plugin; i++) {
895 if( plugindb->get(i)->theme &&
896 !strcasecmp(preferences->theme, plugindb->get(i)->title) )
897 theme_plugin = plugindb->get(i);
901 fprintf(stderr, _("MWindow::init_theme: prefered theme %s not found.\n"),
904 if( !theme_plugin && strcasecmp(preferences->theme, DEFAULT_THEME) ) {
905 fprintf(stderr, _("MWindow::init_theme: trying default theme %s\n"),
907 for(int i = 0; i < plugindb->total && !theme_plugin; i++) {
908 if( plugindb->get(i)->theme &&
909 !strcasecmp(DEFAULT_THEME, plugindb->get(i)->title) )
910 theme_plugin = plugindb->get(i);
915 fprintf(stderr, _("MWindow::init_theme: theme_plugin not found.\n"));
919 PluginServer *plugin = new PluginServer(*theme_plugin);
920 if( plugin->open_plugin(0, preferences, 0, 0) ) {
921 fprintf(stderr, _("MWindow::init_theme: unable to load theme %s\n"),
922 theme_plugin->title);
926 theme = plugin->new_theme();
927 theme->mwindow = this;
928 strcpy(theme->path, plugin->path);
931 // Load default images & settings
932 theme->Theme::initialize();
933 // Load user images & settings
935 // Create menus with user colors
936 theme->build_menus();
941 //printf("MWindow::init_theme %d total_time=%d\n", __LINE__, (int)timer.get_difference());
944 void MWindow::init_3d()
946 playback_3d = new Playback3D(this);
947 playback_3d->create_objects();
950 void MWindow::init_edl()
953 edl->create_objects();
954 fill_preset_defaults(default_standard, edl->session);
955 edl->load_defaults(defaults);
956 edl->create_default_tracks();
957 edl->tracks->update_y_pixels(theme);
960 void MWindow::init_compositor()
962 cwindow = new CWindow(this);
963 cwindow->create_objects();
966 void MWindow::init_levelwindow()
968 lwindow = new LevelWindow(this);
969 lwindow->create_objects();
972 VWindow *MWindow::get_viewer(int start_it, int idx)
974 vwindows_lock->lock("MWindow::get_viewer");
975 VWindow *vwindow = idx >= 0 && idx < vwindows.size() ? vwindows[idx] : 0;
976 if( !vwindow ) idx = vwindows.size();
977 while( !vwindow && --idx >= 0 ) {
978 VWindow *vwin = vwindows[idx];
979 if( !vwin->is_running() || !vwin->get_edl() )
983 vwindow = new VWindow(this);
984 vwindow->load_defaults();
985 vwindow->create_objects();
986 vwindows.append(vwindow);
988 vwindows_lock->unlock();
989 if( start_it ) vwindow->start();
993 void MWindow::init_cache()
995 audio_cache = new CICache(preferences);
996 video_cache = new CICache(preferences);
997 frame_cache = new FrameCache;
998 wave_cache = new WaveCache;
1001 void MWindow::init_channeldb()
1003 channeldb_buz->load("channeldb_buz");
1004 channeldb_v4l2jpeg->load("channeldb_v4l2jpeg");
1007 void MWindow::init_menus()
1009 char string[BCTEXTLEN];
1012 BC_CModels::to_text(string, BC_RGB888);
1013 colormodels.append(new ColormodelItem(string, BC_RGB888));
1014 BC_CModels::to_text(string, BC_RGBA8888);
1015 colormodels.append(new ColormodelItem(string, BC_RGBA8888));
1016 // BC_CModels::to_text(string, BC_RGB161616);
1017 // colormodels.append(new ColormodelItem(string, BC_RGB161616));
1018 // BC_CModels::to_text(string, BC_RGBA16161616);
1019 // colormodels.append(new ColormodelItem(string, BC_RGBA16161616));
1020 BC_CModels::to_text(string, BC_RGB_FLOAT);
1021 colormodels.append(new ColormodelItem(string, BC_RGB_FLOAT));
1022 BC_CModels::to_text(string, BC_RGBA_FLOAT);
1023 colormodels.append(new ColormodelItem(string, BC_RGBA_FLOAT));
1024 BC_CModels::to_text(string, BC_YUV888);
1025 colormodels.append(new ColormodelItem(string, BC_YUV888));
1026 BC_CModels::to_text(string, BC_YUVA8888);
1027 colormodels.append(new ColormodelItem(string, BC_YUVA8888));
1028 // BC_CModels::to_text(string, BC_YUV161616);
1029 // colormodels.append(new ColormodelItem(string, BC_YUV161616));
1030 // BC_CModels::to_text(string, BC_YUVA16161616);
1031 // colormodels.append(new ColormodelItem(string, BC_YUVA16161616));
1033 #define ILACEPROJECTMODELISTADD(x) ilacemode_to_text(string, x); \
1034 interlace_project_modes.append(new InterlacemodeItem(string, x));
1036 #define ILACEASSETMODELISTADD(x) ilacemode_to_text(string, x); \
1037 interlace_asset_modes.append(new InterlacemodeItem(string, x));
1039 #define ILACEFIXMETHODLISTADD(x) ilacefixmethod_to_text(string, x); \
1040 interlace_asset_fixmethods.append(new InterlacefixmethodItem(string, x));
1042 // Interlacing Modes
1043 ILACEASSETMODELISTADD(BC_ILACE_MODE_UNDETECTED); // Not included in the list for the project options.
1045 ILACEASSETMODELISTADD(BC_ILACE_MODE_TOP_FIRST);
1046 ILACEPROJECTMODELISTADD(BC_ILACE_MODE_TOP_FIRST);
1048 ILACEASSETMODELISTADD(BC_ILACE_MODE_BOTTOM_FIRST);
1049 ILACEPROJECTMODELISTADD(BC_ILACE_MODE_BOTTOM_FIRST);
1051 ILACEASSETMODELISTADD(BC_ILACE_MODE_NOTINTERLACED);
1052 ILACEPROJECTMODELISTADD(BC_ILACE_MODE_NOTINTERLACED);
1054 // Interlacing Fixing Methods
1055 ILACEFIXMETHODLISTADD(BC_ILACE_FIXMETHOD_NONE);
1056 ILACEFIXMETHODLISTADD(BC_ILACE_FIXMETHOD_UPONE);
1057 ILACEFIXMETHODLISTADD(BC_ILACE_FIXMETHOD_DOWNONE);
1060 void MWindow::init_indexes()
1062 mainindexes = new MainIndexes(this);
1063 mainindexes->start_loop();
1066 void MWindow::init_gui()
1068 gui = new MWindowGUI(this);
1069 gui->lock_window("MWindow::init_gui");
1070 gui->create_objects();
1071 gui->unlock_window();
1072 gui->load_defaults(defaults);
1075 void MWindow::init_signals()
1077 sighandler = new SigHandler;
1078 sighandler->initialize();
1082 void MWindow::init_render()
1084 render = new Render(this);
1085 create_bd = new CreateBD_Thread(this);
1086 create_dvd = new CreateDVD_Thread(this);
1087 batch_render = new BatchRenderThread(this);
1090 void MWindow::init_exportedl()
1092 exportedl = new ExportEDL(this);
1095 void MWindow::init_brender()
1097 if(preferences->use_brender && !brender)
1099 brender_lock->lock("MWindow::init_brender 1");
1100 brender = new BRender(this);
1101 brender->initialize();
1102 session->brender_end = 0;
1103 brender_lock->unlock();
1106 if(!preferences->use_brender && brender)
1108 brender_lock->lock("MWindow::init_brender 2");
1111 session->brender_end = 0;
1112 brender_lock->unlock();
1114 if(brender) brender->restart(edl);
1117 void MWindow::restart_brender()
1119 //printf("MWindow::restart_brender 1\n");
1120 if(brender) brender->restart(edl);
1123 void MWindow::stop_brender()
1125 if(brender) brender->stop();
1128 int MWindow::brender_available(int position)
1131 brender_lock->lock("MWindow::brender_available 1");
1134 if(brender->map_valid)
1136 brender->map_lock->lock("MWindow::brender_available 2");
1137 if(position < brender->map_size &&
1140 //printf("MWindow::brender_available 1 %d %d\n", position, brender->map[position]);
1141 if(brender->map[position] == BRender::RENDERED)
1144 brender->map_lock->unlock();
1147 brender_lock->unlock();
1151 void MWindow::set_brender_start()
1153 edl->session->brender_start = edl->local_session->get_selectionstart(1);
1155 gui->draw_overlays(1);
1159 int MWindow::has_commercials()
1161 return theme->use_commercials;
1164 void MWindow::init_commercials()
1166 if( !commercials ) {
1167 commercials = new Commercials(this);
1168 commercial_active = 0;
1171 commercials->add_user();
1174 void MWindow::commit_commercial()
1176 if( !commercial_active ) return;
1177 commercial_active = 0;
1178 if( !commercials ) return;
1179 commercials->commitDb();
1182 void MWindow::undo_commercial()
1184 if( !commercial_active ) return;
1185 commercial_active = 0;
1186 if( !commercials ) return;
1187 commercials->undoDb();
1190 int MWindow::put_commercial()
1192 double start = edl->local_session->get_selectionstart();
1193 double end = edl->local_session->get_selectionend();
1194 if( start >= end ) return 0;
1196 const char *errmsg = 0;
1198 Tracks *tracks = edl->tracks;
1201 for(Track *track=tracks->first; track && !errmsg; track=track->next) {
1202 if( track->data_type != TRACK_VIDEO ) continue;
1203 if( !track->record ) continue;
1204 if( count > 0 ) { errmsg = _("multiple video tracks"); break; }
1206 int64_t units_start = track->to_units(start,0);
1207 int64_t units_end = track->to_units(end,0);
1208 Edits *edits = track->edits;
1209 Edit *edit1 = edits->editof(units_start, PLAY_FORWARD, 0);
1210 Edit *edit2 = edits->editof(units_end, PLAY_FORWARD, 0);
1211 if(!edit1 && !edit2) continue; // nothing selected
1212 if(!edit2) { // edit2 beyond end of track
1213 edit2 = edits->last;
1214 units_end = edits->length();
1216 if(edit1 != edit2) { errmsg = _("crosses edits"); break; }
1217 Indexable *indexable = edit1->get_source();
1218 if( !indexable->is_asset ) { errmsg = _("not asset"); break; }
1221 for(Track *track=tracks->first; track && !errmsg; track=track->next) {
1222 if( track->data_type != TRACK_VIDEO ) continue;
1223 if( !track->record ) continue;
1224 int64_t units_start = track->to_units(start,0);
1225 int64_t units_end = track->to_units(end,0);
1226 Edits *edits = track->edits;
1227 Edit *edit1 = edits->editof(units_start, PLAY_FORWARD, 0);
1228 Edit *edit2 = edits->editof(units_end, PLAY_FORWARD, 0);
1229 if(!edit1 && !edit2) continue; // nothing selected
1230 if(!edit2) { // edit2 beyond end of track
1231 edit2 = edits->last;
1232 units_end = edits->length();
1234 Indexable *indexable = edit1->get_source();
1235 Asset *asset = (Asset *)indexable;
1236 File *file = video_cache->check_out(asset, edl);
1237 if( !file ) { errmsg = _("no file"); break; }
1238 int64_t edit_length = units_end - units_start;
1239 int64_t edit_start = units_start - edit1->startproject + edit1->startsource;
1240 result = commercials->put_clip(file, edit1->channel,
1241 track->from_units(edit_start), track->from_units(edit_length));
1242 video_cache->check_in(asset);
1243 if( result ) { errmsg = _("db failed"); break; }
1246 char string[BCTEXTLEN];
1247 sprintf(string, _("put_commercial: %s"), errmsg);
1248 MainError::show_error(string);
1255 void MWindow::stop_playback(int wait)
1257 int locked = gui->get_window_lock();
1258 if( locked ) gui->unlock_window();
1260 cwindow->playback_engine->que->send_command(STOP,
1264 cwindow->playback_engine->interrupt_playback(wait);
1266 for(int i = 0; i < vwindows.size(); i++) {
1267 VWindow *vwindow = vwindows[i];
1268 if( !vwindow->is_running() ) continue;
1269 vwindow->playback_engine->que->send_command(STOP, CHANGE_NONE, 0, 0);
1270 vwindow->playback_engine->interrupt_playback(wait);
1272 if( locked ) gui->lock_window("MWindow::stop_playback");
1275 int MWindow::load_filenames(ArrayList<char*> *filenames,
1277 int update_filename)
1279 ArrayList<EDL*> new_edls;
1280 ArrayList<Asset*> new_assets;
1281 ArrayList<File*> new_files;
1282 const int debug = 0;
1283 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1286 gui->start_hourglass();
1288 // Need to stop playback since tracking depends on the EDL not getting
1292 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1293 undo->update_undo_before();
1296 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1298 // Define new_edls and new_assets to load
1299 int result = 0, ftype = -1;
1300 for(int i = 0; i < filenames->size(); i++)
1303 File *new_file = new File;
1304 Asset *new_asset = new Asset(filenames->get(i));
1305 EDL *new_edl = new EDL;
1306 char string[BCTEXTLEN];
1308 new_edl->create_objects();
1309 new_edl->copy_session(edl);
1310 new_file->set_program(edl->session->program_no);
1312 sprintf(string, _("Loading %s"), new_asset->path);
1313 gui->show_message(string);
1314 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1316 ftype = new_file->open_file(preferences, new_asset, 1, 0);
1317 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1322 // Convert media file to EDL
1324 // Warn about odd image dimensions
1325 if(new_asset->video_data &&
1326 ((new_asset->width % 2) ||
1327 (new_asset->height % 2)))
1329 char string[BCTEXTLEN];
1330 sprintf(string, _("%s's resolution is %dx%d.\nImages with odd dimensions may not decode properly."),
1334 MainError::show_error(string);
1337 if(new_asset->program >= 0 &&
1338 edl->session->program_no != new_asset->program)
1340 char string[BCTEXTLEN];
1341 sprintf(string, _("%s's index was built for program number %d\n"
1342 "Playback preference is %d.\n Using program %d."),
1343 new_asset->path, new_asset->program,
1344 edl->session->program_no, new_asset->program);
1345 MainError::show_error(string);
1349 if(load_mode != LOADMODE_RESOURCESONLY)
1352 RecordLabels *labels = edl->session->label_cells ?
1353 new RecordLabels(new_file) : 0;
1355 asset_to_edl(new_edl, new_asset, labels);
1357 new_edls.append(new_edl);
1359 new_asset->Garbage::remove_user();
1365 new_assets.append(new_asset);
1369 // Set filename to nothing for assets since save EDL would overwrite them.
1370 if(load_mode == LOADMODE_REPLACE ||
1371 load_mode == LOADMODE_REPLACE_CONCATENATE)
1374 // Reset timeline position
1375 for(int i = 0; i < TOTAL_PANES; i++)
1377 new_edl->local_session->view_start[i] = 0;
1378 new_edl->local_session->track_start[i] = 0;
1386 case FILE_NOT_FOUND:
1387 sprintf(string, _("Failed to open %s"), new_asset->path);
1388 gui->show_message(string, theme->message_error);
1392 case FILE_UNRECOGNIZED_CODEC:
1395 IndexFile indexfile(this, new_asset);
1396 result = indexfile.open_index();
1399 indexfile.close_index();
1402 // Test existing EDLs
1405 for(int j = 0; j < new_edls.total + 1; j++)
1408 if(j == new_edls.total)
1410 old_asset = edl->assets->get_asset(new_asset->path);
1413 *new_asset = *old_asset;
1419 old_asset = new_edls[j]->assets->get_asset(new_asset->path);
1422 *new_asset = *old_asset;
1432 char string[BCTEXTLEN];
1434 fs.extract_name(string, new_asset->path);
1436 strcat(string, _("'s format couldn't be determined."));
1437 new_asset->audio_data = 1;
1438 new_asset->format = FILE_PCM;
1439 new_asset->channels = defaults->get("AUDIO_CHANNELS", 2);
1440 new_asset->sample_rate = defaults->get("SAMPLE_RATE", 44100);
1441 new_asset->bits = defaults->get("AUDIO_BITS", 16);
1442 new_asset->byte_order = defaults->get("BYTE_ORDER", 1);
1443 new_asset->signed_ = defaults->get("SIGNED_", 1);
1444 new_asset->header = defaults->get("HEADER", 0);
1446 FileFormat fwindow(this);
1447 fwindow.create_objects(new_asset, string);
1448 result = fwindow.run_window();
1451 defaults->update("AUDIO_CHANNELS", new_asset->channels);
1452 defaults->update("SAMPLE_RATE", new_asset->sample_rate);
1453 defaults->update("AUDIO_BITS", new_asset->bits);
1454 defaults->update("BYTE_ORDER", new_asset->byte_order);
1455 defaults->update("SIGNED_", new_asset->signed_);
1456 defaults->update("HEADER", new_asset->header);
1463 // Recalculate length
1465 new_file = new File;
1466 result = new_file->open_file(preferences, new_asset, 1, 0);
1468 if(load_mode != LOADMODE_RESOURCESONLY)
1470 RecordLabels *labels = edl->session->label_cells ?
1471 new RecordLabels(new_file) : 0;
1472 asset_to_edl(new_edl, new_asset, labels);
1473 new_edls.append(new_edl);
1474 new_asset->Garbage::remove_user();
1480 new_assets.append(new_asset);
1494 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1495 xml_file.read_from_file(filenames->get(i));
1496 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1498 if(load_mode == LOADMODE_NESTED)
1500 // Load temporary EDL for nesting.
1501 EDL *nested_edl = new EDL;
1502 nested_edl->create_objects();
1503 nested_edl->set_path(filenames->get(i));
1504 nested_edl->load_xml(&xml_file, LOAD_ALL);
1505 //printf("MWindow::load_filenames %p %s\n", nested_edl, nested_edl->project_path);
1506 edl_to_nested(new_edl, nested_edl);
1507 nested_edl->Garbage::remove_user();
1511 // Load EDL for pasting
1512 new_edl->load_xml(&xml_file, LOAD_ALL);
1513 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1514 test_plugins(new_edl, filenames->get(i));
1515 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1517 if(load_mode == LOADMODE_REPLACE ||
1518 load_mode == LOADMODE_REPLACE_CONCATENATE)
1520 strcpy(session->filename, filenames->get(i));
1521 strcpy(new_edl->local_session->clip_title,
1524 set_filename(new_edl->local_session->clip_title);
1528 new_edls.append(new_edl);
1534 // edls are in new_edls
1535 if( result && new_edl ) new_edl->Garbage::remove_user();
1536 // assets are copied
1537 if( new_asset ) new_asset->Garbage::remove_user();
1539 // Store for testing index
1540 new_files.append(new_file);
1543 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1546 if(!result) gui->statusbar->default_message();
1554 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1557 // Don't back up here.
1560 // For pasting, clear the active region
1561 if(load_mode == LOADMODE_PASTE ||
1562 load_mode == LOADMODE_NESTED)
1564 double start = edl->local_session->get_selectionstart();
1565 double end = edl->local_session->get_selectionend();
1566 if(!EQUIV(start, end))
1569 edl->session->labels_follow_edits,
1570 edl->session->plugins_follow_edits,
1571 edl->session->autos_follow_edits);
1574 paste_edls(&new_edls,
1578 edl->session->labels_follow_edits,
1579 edl->session->plugins_follow_edits,
1580 edl->session->autos_follow_edits,
1587 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1589 // Add new assets to EDL and schedule assets for index building.
1590 int got_indexes = 0;
1591 for(int i = 0; i < new_edls.size(); i++)
1593 EDL *new_edl = new_edls[i];
1594 for(int j = 0; j < new_edl->nested_edls->size(); j++)
1596 mainindexes->add_next_asset(0,
1597 new_edl->nested_edls->get(j));
1599 edl->nested_edls->update_index(new_edl->nested_edls->get(j));
1604 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1605 if(new_assets.size())
1607 for(int i = 0; i < new_assets.size(); i++)
1609 Asset *new_asset = new_assets[i];
1613 for(int j = 0; j < new_files.size(); j++)
1615 new_file = new_files[j];
1616 if(!strcmp(new_file->asset->path,
1624 mainindexes->add_next_asset(got_it ? new_file : 0, new_asset);
1626 edl->assets->update(new_asset);
1632 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1634 // Start examining next batch of index files
1635 if(got_indexes) mainindexes->start_build();
1636 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1639 Track *track = edl->tracks->first;
1642 for(int j = 0; j < track->plugin_set.size(); j++)
1644 PluginSet *plugins = track->plugin_set[j];
1645 Plugin *plugin = plugins->get_first_plugin();
1649 if(load_mode == LOADMODE_REPLACE ||
1650 load_mode == LOADMODE_REPLACE_CONCATENATE)
1652 if(plugin->plugin_type == PLUGIN_STANDALONE &&
1655 show_plugin(plugin);
1663 plugin = (Plugin*)plugin->next;
1667 track = track->next;
1670 // if just opening one new resource in replace mode
1671 if( load_mode == LOADMODE_REPLACE && new_edls.size() == 1 &&
1672 ftype != FILE_IS_XML )
1675 edl->local_session->preview_start = 0;
1676 edl->local_session->preview_end = edl->tracks->total_playable_length();
1677 edl->local_session->loop_playback = 0;
1678 edl->local_session->set_selectionstart(0);
1679 edl->local_session->set_selectionend(0);
1684 // need to update undo before project, since mwindow is unlocked & a new load
1685 // can begin here. Should really prevent loading until we're done.
1686 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1687 undo->update_undo_after(_("load"), LOAD_ALL);
1689 for(int i = 0; i < new_edls.size(); i++)
1691 new_edls[i]->remove_user();
1693 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1695 new_edls.remove_all();
1697 for(int i = 0; i < new_assets.size(); i++)
1699 new_assets[i]->Garbage::remove_user();
1702 new_assets.remove_all();
1703 new_files.remove_all_objects();
1706 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1707 if(load_mode == LOADMODE_REPLACE ||
1708 load_mode == LOADMODE_REPLACE_CONCATENATE)
1710 session->changes_made = 0;
1714 session->changes_made = 1;
1717 gui->stop_hourglass();
1720 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1721 update_project(load_mode);
1723 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1731 void MWindow::test_plugins(EDL *new_edl, char *path)
1733 char string[BCTEXTLEN];
1735 // Do a check weather plugins exist
1736 for(Track *track = new_edl->tracks->first; track; track = track->next)
1738 for(int k = 0; k < track->plugin_set.total; k++)
1740 PluginSet *plugin_set = track->plugin_set[k];
1741 for(Plugin *plugin = (Plugin*)plugin_set->first;
1743 plugin = (Plugin*)plugin->next)
1745 if(plugin->plugin_type == PLUGIN_STANDALONE)
1747 // ok we need to find it in plugindb
1748 int plugin_found = 0;
1750 for(int j = 0; j < plugindb->size(); j++)
1752 PluginServer *server = plugindb->get(j);
1754 !strcasecmp(server->title, plugin->title) &&
1755 ((track->data_type == TRACK_AUDIO && server->audio) ||
1756 (track->data_type == TRACK_VIDEO && server->video)) &&
1757 (!server->transition))
1764 _("The %s '%s' in file '%s' is not part of your installation of Cinelerra.\n"
1765 "The project won't be rendered as it was meant and Cinelerra might crash.\n"),
1766 "effect", plugin->title,
1768 MainError::show_error(string);
1774 for(Edit *edit = (Edit*)track->edits->first;
1776 edit = (Edit*)edit->next)
1778 if (edit->transition)
1780 // ok we need to find transition in plugindb
1782 int transition_found = 0;
1783 for(int j = 0; j < plugindb->size(); j++)
1785 PluginServer *server = plugindb->get(j);
1787 !strcasecmp(server->title, edit->transition->title) &&
1788 ((track->data_type == TRACK_AUDIO && server->audio) ||
1789 (track->data_type == TRACK_VIDEO && server->video)) &&
1790 (server->transition))
1791 transition_found = 1;
1794 if (!transition_found)
1797 _("The %s '%s' in file '%s' is not part of your installation of Cinelerra.\n"
1798 "The project won't be rendered as it was meant and Cinelerra might crash.\n"),
1799 "transition", edit->transition->title,
1801 MainError::show_error(string);
1809 void MWindow::init_shm()
1811 // Fix shared memory
1812 FILE *fd = fopen("/proc/sys/kernel/shmmax", "w");
1814 fprintf(fd, "0x7fffffff");
1819 fd = fopen("/proc/sys/kernel/shmmax", "r");
1821 MainError::show_error("MWindow::init_shm: couldn't open /proc/sys/kernel/shmmax for reading.\n");
1826 fscanf(fd, _LD, &result);
1829 if(result < 0x7fffffff) {
1830 eprintf(_("MWindow::init_shm: /proc/sys/kernel/shmmax is %p.\n"
1831 "you probably need to be root, or:\n"
1832 "as root, run: echo 0x7fffffff > /proc/sys/kernel/shmmax\n"
1833 "before trying to start cinelerra.\n"
1834 "It should be at least 0x7fffffff for Cinelerra.\n"), (void *)result);
1838 void MWindow::create_objects(int want_gui,
1843 const int debug = 0;
1844 if(debug) PRINT_TRACE
1846 // For some reason, init_signals must come after show_splash or the signals won't
1849 if(debug) PRINT_TRACE
1852 if(debug) PRINT_TRACE
1855 if(debug) PRINT_TRACE
1856 default_standard = default_std();
1857 init_defaults(defaults, config_path);
1860 splash_window->operation->update(_("Initializing Plugins"));
1861 init_plugins(this, preferences);
1862 if(debug) PRINT_TRACE
1863 init_ladspa_plugins(this, preferences);
1864 if(debug) PRINT_TRACE
1866 splash_window->operation->update(_("Initializing GUI"));
1867 if(debug) PRINT_TRACE
1870 if(debug) PRINT_TRACE
1874 splash_window->operation->update(_("Initializing Fonts"));
1875 char string[BCTEXTLEN];
1876 strcpy(string, preferences->plugin_dir);
1877 strcat(string, "/" FONT_SEARCHPATH);
1878 BC_Resources::init_fontconfig(string);
1879 if(debug) PRINT_TRACE
1881 // Initialize before too much else is running
1882 // Preferences & theme are required for building MPEG table of contents
1884 // Default project created here
1886 if(debug) PRINT_TRACE
1889 if(debug) PRINT_TRACE
1894 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1896 //printf("MWindow::create_objects %d session->show_vwindow=%d\n", __LINE__, session->show_vwindow);
1897 if(session->show_vwindow)
1898 get_viewer(1, DEFAULT_VWINDOW);
1899 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1902 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1905 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());
1913 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1917 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1919 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1921 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1925 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1926 mainprogress = new MainProgress(this, gui);
1927 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1928 undo = new MainUndo(this);
1930 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1932 plugin_guis = new ArrayList<PluginServer*>;
1933 dead_plugins = new ArrayList<PluginServer*>;
1934 keyframe_threads = new ArrayList<KeyFrameThread*>;
1936 if(debug) printf("MWindow::create_objects %d vwindows=%d show_vwindow=%d\n",
1939 session->show_vwindow);
1941 // Show all vwindows
1942 // if(session->show_vwindow) {
1943 // for(int j = 0; j < vwindows.size(); j++) {
1944 // VWindow *vwindow = vwindows[j];
1945 // if( !vwindow->is_running() ) continue;
1946 // if(debug) printf("MWindow::create_objects %d vwindow=%p\n",
1949 // if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1950 // vwindow->gui->lock_window("MWindow::create_objects 1");
1951 // if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1952 // vwindow->gui->show_window();
1953 // if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1954 // vwindow->gui->unlock_window();
1959 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1961 if(session->show_cwindow)
1963 cwindow->gui->lock_window("MWindow::create_objects 1");
1964 cwindow->gui->show_window();
1965 cwindow->gui->unlock_window();
1968 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1969 if(session->show_awindow)
1971 awindow->gui->lock_window("MWindow::create_objects 1");
1972 awindow->gui->show_window();
1973 awindow->gui->unlock_window();
1976 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1977 if(session->show_lwindow)
1979 lwindow->gui->lock_window("MWindow::create_objects 1");
1980 lwindow->gui->show_window();
1981 lwindow->gui->unlock_window();
1984 if(debug) printf("MWindow::create_objects %d total_time=%d gwindow=%p\n",
1986 (int)timer.get_difference(),
1988 if(session->show_gwindow)
1990 gwindow->gui->lock_window("MWindow::create_objects 1");
1991 gwindow->gui->show_window();
1992 gwindow->gui->unlock_window();
1995 if(debug) PRINT_TRACE
1997 gui->lock_window("MWindow::create_objects 1");
1998 gui->mainmenu->load_defaults(defaults);
1999 gui->mainmenu->update_toggles(0);
2000 gui->update_patchbay();
2001 gui->draw_canvas(0, 0);
2002 gui->draw_cursor(1);
2004 gui->raise_window();
2005 gui->unlock_window();
2007 if(debug) PRINT_TRACE
2009 if(preferences->use_tipwindow)
2011 if(debug) PRINT_TRACE
2013 gui->add_keyboard_listener(
2014 (int (BC_WindowBase::*)(BC_WindowBase *))
2015 &MWindowGUI::keyboard_listener);
2019 if(debug) PRINT_TRACE
2021 BC_WindowBase::get_resources()->vframe_shm = 1;
2025 void MWindow::show_splash()
2027 #include "data/heroine_logo9_png.h"
2028 VFrame *frame = new VFramePng(heroine_logo9_png);
2029 BC_DisplayInfo dpyi;
2030 int rw = dpyi.get_root_w(), rh = dpyi.get_root_h();
2031 int rr = (rw < rh ? rw : rh) / 4;
2032 splash_window = new SplashGUI(frame, rr, rr);
2033 splash_window->create_objects();
2036 void MWindow::hide_splash()
2039 delete splash_window;
2044 void MWindow::start()
2048 // vwindows[DEFAULT_VWINDOW]->start();
2059 playback_3d->start();
2068 void MWindow::show_vwindow()
2070 int total_running = 0;
2071 session->show_vwindow = 1;
2073 //printf("MWindow::show_vwindow %d %d\n", __LINE__, vwindows.size());
2074 // Raise all windows which are visible
2075 for(int j = 0; j < vwindows.size(); j++) {
2076 VWindow *vwindow = vwindows[j];
2077 if( !vwindow->is_running() ) continue;
2078 vwindow->gui->lock_window("MWindow::show_vwindow");
2079 vwindow->gui->show_window(0);
2080 vwindow->gui->raise_window();
2081 vwindow->gui->flush();
2082 vwindow->gui->unlock_window();
2086 // If no windows visible
2089 get_viewer(1, DEFAULT_VWINDOW);
2092 gui->mainmenu->show_vwindow->set_checked(1);
2095 void MWindow::show_awindow()
2097 session->show_awindow = 1;
2098 awindow->gui->lock_window("MWindow::show_awindow");
2099 awindow->gui->show_window();
2100 awindow->gui->raise_window();
2101 awindow->gui->flush();
2102 awindow->gui->unlock_window();
2103 gui->mainmenu->show_awindow->set_checked(1);
2106 char *MWindow::get_cwindow_display()
2108 char *x11_host = screens < 2 || session->window_config == 0 ?
2109 session->a_x11_host : session->b_x11_host;
2110 return *x11_host ? x11_host : 0;
2113 void MWindow::show_cwindow()
2115 session->show_cwindow = 1;
2116 cwindow->show_window();
2117 gui->mainmenu->show_cwindow->set_checked(1);
2120 void MWindow::show_gwindow()
2122 session->show_gwindow = 1;
2124 gwindow->gui->lock_window("MWindow::show_gwindow");
2125 gwindow->gui->show_window();
2126 gwindow->gui->raise_window();
2127 gwindow->gui->flush();
2128 gwindow->gui->unlock_window();
2130 gui->mainmenu->show_gwindow->set_checked(1);
2133 void MWindow::show_lwindow()
2135 session->show_lwindow = 1;
2136 lwindow->gui->lock_window("MWindow::show_lwindow");
2137 lwindow->gui->show_window();
2138 lwindow->gui->raise_window();
2139 lwindow->gui->flush();
2140 lwindow->gui->unlock_window();
2141 gui->mainmenu->show_lwindow->set_checked(1);
2144 int MWindow::tile_windows(int window_config)
2146 int need_reload = 0;
2147 int play_config = window_config==0 ? 0 : 1;
2148 edl->session->playback_config->load_defaults(defaults, play_config);
2149 session->default_window_positions(window_config);
2150 if( screens == 1 ) {
2151 gui->default_positions();
2152 sync_parameters(CHANGE_ALL);
2159 void MWindow::toggle_loop_playback()
2161 edl->local_session->loop_playback = !edl->local_session->loop_playback;
2162 set_loop_boundaries();
2165 gui->draw_overlays(1);
2166 sync_parameters(CHANGE_PARAMS);
2169 //void MWindow::set_titles(int value)
2171 // edl->session->show_titles = value;
2172 // trackmovement(edl->local_session->track_start);
2175 void MWindow::set_screens(int value)
2180 void MWindow::set_auto_keyframes(int value, int lock_mwindow, int lock_cwindow)
2182 if(lock_mwindow) gui->lock_window("MWindow::set_auto_keyframes");
2183 edl->session->auto_keyframes = value;
2184 gui->mbuttons->edit_panel->keyframe->update(value);
2186 if(lock_mwindow) gui->unlock_window();
2188 if(lock_cwindow) cwindow->gui->lock_window("MWindow::set_auto_keyframes");
2189 cwindow->gui->edit_panel->keyframe->update(value);
2190 cwindow->gui->flush();
2191 if(lock_cwindow) cwindow->gui->unlock_window();
2194 void MWindow::set_keyframe_type(int mode)
2196 gui->lock_window("MWindow::set_keyframe_type");
2197 edl->local_session->floatauto_type = mode;
2198 gui->mainmenu->update_toggles(0);
2199 gui->unlock_window();
2202 int MWindow::set_editing_mode(int new_editing_mode, int lock_mwindow, int lock_cwindow)
2204 if(lock_mwindow) gui->lock_window("MWindow::set_editing_mode");
2205 edl->session->editing_mode = new_editing_mode;
2206 gui->mbuttons->edit_panel->editing_mode = edl->session->editing_mode;
2207 gui->mbuttons->edit_panel->update();
2208 gui->set_editing_mode(1);
2209 if(lock_mwindow) gui->unlock_window();
2212 if(lock_cwindow) cwindow->gui->lock_window("MWindow::set_editing_mode");
2213 cwindow->gui->edit_panel->update();
2214 cwindow->gui->edit_panel->editing_mode = edl->session->editing_mode;
2215 if(lock_cwindow) cwindow->gui->unlock_window();
2219 void MWindow::toggle_editing_mode()
2221 int mode = edl->session->editing_mode;
2222 if( mode == EDITING_ARROW )
2223 set_editing_mode(EDITING_IBEAM, 0, 1);
2225 set_editing_mode(EDITING_ARROW, 0, 1);
2229 void MWindow::set_labels_follow_edits(int value)
2231 gui->lock_window("MWindow::set_labels_follow_edits");
2232 edl->session->labels_follow_edits = value;
2233 gui->mbuttons->edit_panel->locklabels->update(value);
2234 gui->mainmenu->labels_follow_edits->set_checked(value);
2236 gui->unlock_window();
2239 void MWindow::sync_parameters(int change_type)
2241 if( in_destructor ) return;
2243 // Sync engines which are playing back
2244 if(cwindow->playback_engine->is_playing_back)
2246 if(change_type == CHANGE_PARAMS)
2248 // TODO: block keyframes until synchronization is done
2249 cwindow->playback_engine->sync_parameters(edl);
2254 int command = cwindow->playback_engine->command->command;
2255 cwindow->playback_engine->que->send_command(STOP,
2259 // Waiting for tracking to finish would make the restart position more
2260 // accurate but it can't lock the window to stop tracking for some reason.
2261 // Not waiting for tracking gives a faster response but restart position is
2262 // only as accurate as the last tracking update.
2263 cwindow->playback_engine->interrupt_playback(0);
2264 cwindow->playback_engine->que->send_command(command,
2273 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2280 void MWindow::age_caches()
2282 // printf("MWindow::age_caches %d %lld %lld %lld %lld\n",
2284 // preferences->cache_size,
2285 // audio_cache->get_memory_usage(1),
2286 // video_cache->get_memory_usage(1),
2287 // frame_cache->get_memory_usage(),
2288 // wave_cache->get_memory_usage(),
2290 frame_cache->age_cache(512);
2291 wave_cache->age_cache(8192);
2293 int64_t memory_usage;
2294 int64_t prev_memory_usage = 0;
2296 int64_t video_size = (int64_t)(preferences->cache_size * 0.80);
2297 while( !result && prev_memory_usage !=
2298 (memory_usage=video_cache->get_memory_usage(1)) &&
2299 memory_usage > video_size ) {
2300 video_cache->delete_oldest();
2301 prev_memory_usage = memory_usage;
2304 prev_memory_usage = 0;
2306 int64_t audio_size = (int64_t)(preferences->cache_size * 0.20);
2307 while( !result && prev_memory_usage !=
2308 (memory_usage=audio_cache->get_memory_usage(1)) &&
2309 memory_usage > audio_size ) {
2310 audio_cache->delete_oldest();
2311 prev_memory_usage = memory_usage;
2315 void MWindow::reset_android_remote()
2317 gui->use_android_remote(preferences->android_remote);
2321 void MWindow::show_keyframe_gui(Plugin *plugin)
2323 keyframe_gui_lock->lock("MWindow::show_keyframe_gui");
2324 // Find existing thread
2325 for(int i = 0; i < keyframe_threads->size(); i++)
2327 if(keyframe_threads->get(i)->plugin == plugin)
2329 keyframe_threads->get(i)->start_window(plugin, 0);
2330 keyframe_gui_lock->unlock();
2335 // Find unused thread
2336 for(int i = 0; i < keyframe_threads->size(); i++)
2338 if(!keyframe_threads->get(i)->plugin)
2340 keyframe_threads->get(i)->start_window(plugin, 0);
2341 keyframe_gui_lock->unlock();
2346 // Create new thread
2347 KeyFrameThread *thread = new KeyFrameThread(this);
2348 keyframe_threads->append(thread);
2349 thread->start_window(plugin, 0);
2351 keyframe_gui_lock->unlock();
2358 void MWindow::show_plugin(Plugin *plugin)
2363 // Remove previously deleted plugin GUIs
2364 dead_plugin_lock->lock("MWindow::delete_plugin");
2365 for(int i = 0; i < dead_plugins->size(); i++)
2367 delete dead_plugins->get(i);
2369 dead_plugins->remove_all();
2370 dead_plugin_lock->unlock();
2372 //printf("MWindow::show_plugin %d\n", __LINE__);
2376 plugin_gui_lock->lock("MWindow::show_plugin");
2377 for(int i = 0; i < plugin_guis->total; i++)
2379 // Pointer comparison
2380 if(plugin_guis->get(i)->plugin == plugin)
2382 plugin_guis->get(i)->raise_window();
2389 //printf("MWindow::show_plugin 1\n");
2394 printf("MWindow::show_plugin track not defined.\n");
2396 PluginServer *server = scan_plugindb(plugin->title,
2397 plugin->track->data_type);
2399 //printf("MWindow::show_plugin %p %d\n", server, server->uses_gui);
2400 if(server && server->uses_gui)
2402 PluginServer *gui = plugin_guis->append(new PluginServer(*server));
2403 // Needs mwindow to do GUI
2404 gui->set_mwindow(this);
2405 gui->open_plugin(0, preferences, edl, plugin);
2410 plugin_gui_lock->unlock();
2411 //printf("MWindow::show_plugin %d\n", __LINE__);
2414 //printf("MWindow::show_plugin 2\n");
2417 void MWindow::hide_plugin(Plugin *plugin, int lock)
2420 // Update the toggle
2421 gui->lock_window("MWindow::hide_plugin");
2422 gui->update(0, 1, 0, 0, 0, 0, 0);
2423 gui->unlock_window();
2425 if(lock) plugin_gui_lock->lock("MWindow::hide_plugin");
2426 for(int i = 0; i < plugin_guis->total; i++)
2428 if(plugin_guis->get(i)->plugin == plugin)
2430 PluginServer *ptr = plugin_guis->get(i);
2431 plugin_guis->remove(ptr);
2432 if(lock) plugin_gui_lock->unlock();
2433 // Last command executed in client side close
2434 // Schedule for deletion
2441 if(lock) plugin_gui_lock->unlock();
2444 void MWindow::delete_plugin(PluginServer *plugin)
2446 dead_plugin_lock->lock("MWindow::delete_plugin");
2447 dead_plugins->append(plugin);
2448 dead_plugin_lock->unlock();
2451 void MWindow::hide_plugins()
2453 plugin_gui_lock->lock("MWindow::hide_plugins 1");
2454 while(plugin_guis->size())
2456 PluginServer *ptr = plugin_guis->get(0);
2457 plugin_guis->remove(ptr);
2458 plugin_gui_lock->unlock();
2459 // Last command executed in client side close
2460 // Schedule for deletion
2463 plugin_gui_lock->lock("MWindow::hide_plugins 2");
2465 plugin_gui_lock->unlock();
2467 hide_keyframe_guis();
2470 void MWindow::hide_keyframe_guis()
2472 keyframe_gui_lock->lock("MWindow::hide_keyframe_guis");
2473 for(int i = 0; i < keyframe_threads->size(); i++)
2475 keyframe_threads->get(i)->close_window();
2477 keyframe_gui_lock->unlock();
2480 void MWindow::hide_keyframe_gui(Plugin *plugin)
2482 keyframe_gui_lock->lock("MWindow::hide_keyframe_gui");
2483 for(int i = 0; i < keyframe_threads->size(); i++)
2485 if(keyframe_threads->get(i)->plugin == plugin)
2487 keyframe_threads->get(i)->close_window();
2491 keyframe_gui_lock->unlock();
2494 void MWindow::update_keyframe_guis()
2496 // Send new configuration to keyframe GUI's
2497 keyframe_gui_lock->lock("MWindow::update_keyframe_guis");
2498 for(int i = 0; i < keyframe_threads->size(); i++)
2500 KeyFrameThread *ptr = keyframe_threads->get(i);
2501 if(edl->tracks->plugin_exists(ptr->plugin))
2505 ptr->close_window();
2508 keyframe_gui_lock->unlock();
2511 void MWindow::update_plugin_guis(int do_keyframe_guis)
2513 // Send new configuration to plugin GUI's
2514 plugin_gui_lock->lock("MWindow::update_plugin_guis");
2516 for(int i = 0; i < plugin_guis->size(); i++)
2518 PluginServer *ptr = plugin_guis->get(i);
2519 if(edl->tracks->plugin_exists(ptr->plugin))
2523 // Schedule for deletion if no plugin
2524 plugin_guis->remove_number(i);
2533 // Change plugin variable if not visible
2534 Track *track = edl->tracks->first;
2537 for(int i = 0; i < track->plugin_set.size(); i++)
2539 Plugin *plugin = (Plugin*)track->plugin_set[i]->first;
2543 for(int i = 0; i < plugin_guis->size(); i++)
2545 PluginServer *server = plugin_guis->get(i);
2546 if(server->plugin == plugin)
2553 if(!got_it) plugin->show = 0;
2555 plugin = (Plugin*)plugin->next;
2559 track = track->next;
2562 plugin_gui_lock->unlock();
2565 if(do_keyframe_guis) update_keyframe_guis();
2568 int MWindow::plugin_gui_open(Plugin *plugin)
2571 plugin_gui_lock->lock("MWindow::plugin_gui_open");
2572 for(int i = 0; i < plugin_guis->total; i++)
2574 if(plugin_guis->get(i)->plugin->identical_location(plugin))
2580 plugin_gui_lock->unlock();
2584 void MWindow::render_plugin_gui(void *data, Plugin *plugin)
2586 plugin_gui_lock->lock("MWindow::render_plugin_gui");
2587 for(int i = 0; i < plugin_guis->total; i++)
2589 if(plugin_guis->get(i)->plugin->identical_location(plugin))
2591 plugin_guis->get(i)->render_gui(data);
2595 plugin_gui_lock->unlock();
2598 void MWindow::render_plugin_gui(void *data, int size, Plugin *plugin)
2600 plugin_gui_lock->lock("MWindow::render_plugin_gui");
2601 for(int i = 0; i < plugin_guis->total; i++)
2603 if(plugin_guis->get(i)->plugin->identical_location(plugin))
2605 plugin_guis->get(i)->render_gui(data, size);
2609 plugin_gui_lock->unlock();
2613 void MWindow::update_plugin_states()
2615 plugin_gui_lock->lock("MWindow::update_plugin_states");
2616 for(int i = 0; i < plugin_guis->total; i++)
2620 Plugin *src_plugin = plugin_guis->get(i)->plugin;
2621 PluginServer *src_plugingui = plugin_guis->get(i);
2623 // Search for plugin in EDL. Only the master EDL shows plugin GUIs.
2624 for(Track *track = edl->tracks->first;
2626 track = track->next)
2629 j < track->plugin_set.total && !result;
2632 PluginSet *plugin_set = track->plugin_set[j];
2633 for(Plugin *plugin = (Plugin*)plugin_set->first;
2635 plugin = (Plugin*)plugin->next)
2637 if(plugin == src_plugin &&
2638 !strcmp(plugin->title, src_plugingui->title)) result = 1;
2644 // Doesn't exist anymore
2647 hide_plugin(src_plugin, 0);
2651 plugin_gui_lock->unlock();
2655 void MWindow::update_plugin_titles()
2657 for(int i = 0; i < plugin_guis->total; i++)
2659 plugin_guis->get(i)->update_title();
2663 int MWindow::asset_to_edl(EDL *new_edl,
2665 RecordLabels *labels)
2667 const int debug = 0;
2668 if(debug) printf("MWindow::asset_to_edl %d new_asset->layers=%d\n",
2671 // Keep frame rate, sample rate, and output size unchanged.
2672 // These parameters would revert the project if VWindow displayed an asset
2673 // of different size than the project.
2674 if(new_asset->video_data)
2676 new_edl->session->video_tracks = new_asset->layers;
2679 new_edl->session->video_tracks = 0;
2681 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2687 if(new_asset->audio_data)
2689 new_edl->session->audio_tracks = new_asset->channels;
2692 new_edl->session->audio_tracks = 0;
2693 //printf("MWindow::asset_to_edl 2 %d %d\n", new_edl->session->video_tracks, new_edl->session->audio_tracks);
2695 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2696 new_edl->create_default_tracks();
2697 //printf("MWindow::asset_to_edl 2 %d %d\n", new_edl->session->video_tracks, new_edl->session->audio_tracks);
2698 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2702 //printf("MWindow::asset_to_edl 3\n");
2703 new_edl->insert_asset(new_asset,
2708 //printf("MWindow::asset_to_edl 3\n");
2709 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2711 // Align cursor on frames:: clip the new_edl to the minimum of the last joint frame.
2712 if(edl->session->cursor_on_frames)
2714 double length = new_edl->tracks->total_length();
2715 double edl_length = new_edl->tracks->total_length_framealigned(edl->session->frame_rate);
2716 new_edl->tracks->clear(length, edl_length, 1, 1);
2722 char string[BCTEXTLEN];
2724 fs.extract_name(string, new_asset->path);
2725 //printf("MWindow::asset_to_edl 3\n");
2727 strcpy(new_edl->local_session->clip_title, string);
2728 //printf("MWindow::asset_to_edl 4 %s\n", string);
2729 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2734 int MWindow::edl_to_nested(EDL *new_edl,
2738 // Keep frame rate, sample rate, and output size unchanged.
2739 // These parameters would revert the project if VWindow displayed an asset
2740 // of different size than the project.
2744 // Nest all video & audio outputs
2745 new_edl->session->video_tracks = 1;
2746 new_edl->session->audio_tracks = nested_edl->session->audio_channels;
2747 new_edl->create_default_tracks();
2751 new_edl->insert_asset(0,
2757 char string[BCTEXTLEN];
2759 fs.extract_name(string, nested_edl->path);
2760 //printf("MWindow::edl_to_nested %p %s\n", nested_edl, nested_edl->path);
2762 strcpy(new_edl->local_session->clip_title, string);
2767 // Reset everything after a load.
2768 void MWindow::update_project(int load_mode)
2770 const int debug = 0;
2772 if(debug) PRINT_TRACE
2774 edl->tracks->update_y_pixels(theme);
2776 if(debug) PRINT_TRACE
2778 if(load_mode == LOADMODE_REPLACE ||
2779 load_mode == LOADMODE_REPLACE_CONCATENATE)
2784 gui->update(1, 1, 1, 1, 1, 1, 1);
2785 if(debug) PRINT_TRACE
2786 gui->unlock_window();
2788 cwindow->gui->lock_window("MWindow::update_project 1");
2789 cwindow->update(0, 0, 1, 1, 1);
2790 cwindow->gui->unlock_window();
2792 if(debug) PRINT_TRACE
2794 // Close all the vwindows
2795 if(load_mode == LOADMODE_REPLACE ||
2796 load_mode == LOADMODE_REPLACE_CONCATENATE) {
2797 if(debug) PRINT_TRACE
2798 int first_vwindow = 0;
2799 if(session->show_vwindow) first_vwindow = 1;
2800 // Change visible windows to no source
2801 for(int i = 0; i < first_vwindow && i < vwindows.size(); i++) {
2802 VWindow *vwindow = vwindows[i];
2803 if( !vwindow->is_running() ) continue;
2804 vwindow->change_source(-1);
2807 // Close remaining windows
2808 for(int i = first_vwindow; i < vwindows.size(); i++) {
2809 VWindow *vwindow = vwindows[i];
2810 if( !vwindow->is_running() ) continue;
2811 vwindow->close_window();
2813 if(debug) PRINT_TRACE
2815 else if(vwindows.size()) {
2816 VWindow *vwindow = vwindows[DEFAULT_VWINDOW];
2817 if( vwindow->is_running() ) {
2818 vwindow->gui->lock_window("MWindow::update_project");
2820 vwindow->gui->unlock_window();
2824 if(debug) PRINT_TRACE
2825 cwindow->gui->lock_window("MWindow::update_project 2");
2826 cwindow->gui->timebar->update(0);
2827 cwindow->gui->unlock_window();
2829 if(debug) PRINT_TRACE
2830 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2835 awindow->gui->async_update_assets();
2836 if(debug) PRINT_TRACE
2838 gui->lock_window("MWindow::update_project");
2840 if(debug) PRINT_TRACE
2843 void MWindow::remove_indexfile(Indexable *indexable)
2845 if( !indexable->is_asset ) return;
2846 Asset *asset = (Asset *)indexable;
2848 IndexFile::delete_index(preferences, asset, ".toc");
2849 IndexFile::delete_index(preferences, asset, ".idx");
2850 IndexFile::delete_index(preferences, asset, ".mkr");
2853 void MWindow::rebuild_indices()
2855 for(int i = 0; i < session->drag_assets->total; i++)
2857 Indexable *indexable = session->drag_assets->get(i);
2858 //printf("MWindow::rebuild_indices 1 %s\n", indexable->path);
2859 remove_indexfile(indexable);
2860 // Schedule index build
2861 IndexState *index_state = indexable->index_state;
2862 index_state->index_status = INDEX_NOTTESTED;
2863 if( indexable->is_asset ) {
2864 Asset *asset = (Asset *)indexable;
2865 if( asset->format != FILE_PCM )
2866 asset->reset_audio();
2867 asset->reset_video();
2869 mainindexes->add_next_asset(0, indexable);
2871 mainindexes->start_build();
2875 void MWindow::save_backup()
2878 edl->set_path(session->filename);
2879 edl->save_xml(&file,
2883 file.terminate_string();
2884 char path[BCTEXTLEN];
2886 strcpy(path, BACKUP_PATH);
2887 fs.complete_path(path);
2889 if(file.write_to_file(path))
2892 sprintf(string2, _("Couldn't open %s for writing."), BACKUP_PATH);
2893 gui->show_message(string2);
2897 void MWindow::load_backup()
2899 ArrayList<char*> path_list;
2900 path_list.set_array_delete();
2902 char string[BCTEXTLEN];
2903 strcpy(string, BACKUP_PATH);
2905 fs.complete_path(string);
2907 path_list.append(out_path = new char[strlen(string) + 1]);
2908 strcpy(out_path, string);
2910 load_filenames(&path_list, LOADMODE_REPLACE, 0);
2911 edl->local_session->clip_title[0] = 0;
2912 // This is unique to backups since the path of the backup is different than the
2913 // path of the project.
2914 set_filename(edl->path);
2915 path_list.remove_all_objects();
2919 static inline int gcd(int m, int n)
2922 if( m < n ) { r = m; m = n; n = r; }
2923 while( (r = m % n) != 0 ) { m = n; n = r; }
2927 int MWindow::create_aspect_ratio(float &w, float &h, int width, int height)
2930 if(!width || !height) return 1;
2931 double ar = (double)width / height;
2932 // square-ish pixels
2933 if( EQUIV(ar, 1.0000) ) return 0;
2934 if( EQUIV(ar, 1.3333) ) { w = 4; h = 3; return 0; }
2935 if( EQUIV(ar, 1.7777) ) { w = 16; h = 9; return 0; }
2936 if( EQUIV(ar, 2.1111) ) { w = 19; h = 9; return 0; }
2937 if( EQUIV(ar, 2.2222) ) { w = 20; h = 9; return 0; }
2938 if( EQUIV(ar, 2.3333) ) { w = 21; h = 9; return 0; }
2939 int ww = width, hh = height;
2940 // numerator, denominator must be under mx
2941 int mx = 255, n = gcd(ww, hh);
2942 if( n > 1 ) { ww /= n; hh /= n; }
2943 // search near height in case extra/missing lines
2944 if( ww >= mx || hh >= mx ) {
2945 double err = height; // +/- 2 percent height
2946 for( int m=2*height/100, i=1; m>0; i=i>0 ? -i : (--m, -i+1) ) {
2947 int iw = width, ih = height+i;
2948 if( (n=gcd(iw, ih)) > 1 ) {
2949 int u = iw/n; if( u >= mx ) continue;
2950 int v = ih/n; if( v >= mx ) continue;
2951 double r = (double) u/v, er = fabs(ar-r);
2952 if( er >= err ) continue;
2953 err = er; ww = u; hh = v;
2962 void MWindow::reset_caches()
2964 frame_cache->remove_all();
2965 wave_cache->remove_all();
2966 audio_cache->remove_all();
2967 video_cache->remove_all();
2968 if( cwindow->playback_engine && cwindow->playback_engine->audio_cache )
2969 cwindow->playback_engine->audio_cache->remove_all();
2970 if( cwindow->playback_engine && cwindow->playback_engine->video_cache )
2971 cwindow->playback_engine->video_cache->remove_all();
2973 for(int i = 0; i < vwindows.size(); i++) {
2974 VWindow *vwindow = vwindows[i];
2975 if( !vwindow->is_running() ) continue;
2976 if(vwindow->playback_engine && vwindow->playback_engine->audio_cache)
2977 vwindow->playback_engine->audio_cache->remove_all();
2978 if(vwindow->playback_engine && vwindow->playback_engine->video_cache)
2979 vwindow->playback_engine->video_cache->remove_all();
2983 void MWindow::remove_asset_from_caches(Asset *asset)
2985 gui->resource_thread->get_video_source(0);
2986 gui->resource_thread->get_audio_source(0);
2987 frame_cache->remove_asset(asset);
2988 wave_cache->remove_asset(asset);
2989 audio_cache->delete_entry(asset);
2990 video_cache->delete_entry(asset);
2991 if( cwindow->playback_engine && cwindow->playback_engine->audio_cache )
2992 cwindow->playback_engine->audio_cache->delete_entry(asset);
2993 if( cwindow->playback_engine && cwindow->playback_engine->video_cache )
2994 cwindow->playback_engine->video_cache->delete_entry(asset);
2995 for(int i = 0; i < vwindows.size(); i++) {
2996 VWindow *vwindow = vwindows[i];
2997 if( !vwindow->is_running() ) continue;
2998 if(vwindow->playback_engine && vwindow->playback_engine->audio_cache)
2999 vwindow->playback_engine->audio_cache->delete_entry(asset);
3000 if(vwindow->playback_engine && vwindow->playback_engine->video_cache)
3001 vwindow->playback_engine->video_cache->delete_entry(asset);
3006 void MWindow::remove_assets_from_project(int push_undo, int redraw,
3007 ArrayList<Indexable*> *drag_assets, ArrayList<EDL*> *drag_clips)
3009 for(int i = 0; i < session->drag_assets->total; i++) {
3010 Indexable *indexable = session->drag_assets->get(i);
3011 if(indexable->is_asset) remove_asset_from_caches((Asset*)indexable);
3014 // Remove from VWindow.
3015 for(int i = 0; i < session->drag_clips->total; 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_clips->get(i) == vwindow->get_edl()) {
3020 vwindow->gui->lock_window("MWindow::remove_assets_from_project 1");
3021 vwindow->delete_source(1, 1);
3022 vwindow->gui->unlock_window();
3027 for(int i = 0; i < session->drag_assets->size(); i++) {
3028 for(int j = 0; j < vwindows.size(); j++) {
3029 VWindow *vwindow = vwindows[j];
3030 if( !vwindow->is_running() ) continue;
3031 if(session->drag_assets->get(i) == vwindow->get_source()) {
3032 vwindow->gui->lock_window("MWindow::remove_assets_from_project 2");
3033 vwindow->delete_source(1, 1);
3034 vwindow->gui->unlock_window();
3039 for(int i = 0; i < session->drag_assets->size(); i++) {
3040 Indexable *indexable = session->drag_assets->get(i);
3041 remove_indexfile(indexable);
3044 //printf("MWindow::rebuild_indices 1 %s\n", indexable->path);
3045 if(push_undo) undo->update_undo_before();
3046 if(drag_assets) edl->remove_from_project(drag_assets);
3047 if(drag_clips) edl->remove_from_project(session->drag_clips);
3048 if(redraw) save_backup();
3049 if(push_undo) undo->update_undo_after(_("remove assets"), LOAD_ALL);
3054 gui->lock_window("MWindow::remove_assets_from_project 3");
3062 gui->unlock_window();
3064 // Removes from playback here
3065 sync_parameters(CHANGE_ALL);
3068 awindow->gui->async_update_assets();
3071 void MWindow::remove_assets_from_disk()
3074 for(int i = 0; i < session->drag_assets->total; i++)
3076 remove(session->drag_assets->get(i)->path);
3079 remove_assets_from_project(1,
3081 session->drag_assets,
3082 session->drag_clips);
3085 void MWindow::dump_plugins(FILE *fp)
3087 if( !plugindb ) return;
3088 for(int i = 0; i < plugindb->total; i++)
3090 fprintf(fp, "type=%d audio=%d video=%d rt=%d multi=%d"
3091 " synth=%d transition=%d theme=%d %s\n",
3092 plugindb->get(i)->plugin_type,
3093 plugindb->get(i)->audio,
3094 plugindb->get(i)->video,
3095 plugindb->get(i)->realtime,
3096 plugindb->get(i)->multichannel,
3097 plugindb->get(i)->get_synthesis(),
3098 plugindb->get(i)->transition,
3099 plugindb->get(i)->theme,
3100 plugindb->get(i)->title);
3104 void MWindow::dump_edl(FILE *fp)
3110 void MWindow::dump_undo(FILE *fp)
3116 void MWindow::dump_exe(FILE *fp)
3118 char proc_path[BCTEXTLEN], exe_path[BCTEXTLEN];
3119 sprintf(proc_path, "/proc/%d/exe", (int)getpid());
3120 int len = readlink(proc_path, exe_path, sizeof(exe_path));
3121 if( len < 0 ) { fprintf(fp,"readlink: %m\n"); return; }
3124 if( stat(exe_path,&st) ) { fprintf(fp,"stat: %m\n"); return; }
3125 fprintf(fp, "path: %s = %9jd bytes\n",exe_path,st.st_size);
3126 int fd = open(exe_path,O_RDONLY);
3127 if( fd < 0 ) { fprintf(fp,"open: %m\n"); return; }
3128 uint8_t buf[65536]; SHA1 sha1;
3129 while( (len=read(fd,buf,sizeof(buf))) > 0 ) {
3130 sha1.addBytes(buf, len);
3133 fprintf(fp, "SHA1: ");
3134 uint8_t digest[20]; sha1.computeHash(digest);
3135 for( int i=0; i<20; ++i ) fprintf(fp, "%02x", digest[i]);
3140 void MWindow::trap_hook(FILE *fp, void *vp)
3142 MWindow *mwindow = (MWindow *)vp;
3143 fprintf(fp, "\nEXE:\n");
3144 mwindow->dump_exe(fp);
3145 fprintf(fp, "\nPLUGINS:\n");
3146 mwindow->dump_plugins(fp);
3147 fprintf(fp, "\nEDL:\n");
3148 mwindow->dump_edl(fp);
3149 fprintf(fp, "\nUNDO:\n");
3150 mwindow->dump_undo(fp);
3158 int MWindow::save_defaults()
3160 gui->save_defaults(defaults);
3161 edl->save_defaults(defaults);
3162 session->save_defaults(defaults);
3163 preferences->save_defaults(defaults);
3165 for(int i = 0; i < plugin_guis->total; i++)
3167 // Pointer comparison
3168 plugin_guis->get(i)->save_defaults();
3170 awindow->save_defaults(defaults);
3176 int MWindow::run_script(FileXML *script)
3178 int result = 0, result2 = 0;
3179 while(!result && !result2)
3181 result = script->read_tag();
3184 if(script->tag.title_is("new_project"))
3186 // Run new in immediate mode.
3187 // gui->mainmenu->new_project->run_script(script);
3190 if(script->tag.title_is("record"))
3192 // Run record as a thread. It is a terminal command.
3194 // Will read the complete scipt file without letting record read it if not
3200 printf("MWindow::run_script: Unrecognized command: %s\n",script->tag.get_title() );
3207 // ================================= synchronization
3210 int MWindow::interrupt_indexes()
3212 mainindexes->interrupt_build();
3218 void MWindow::next_time_format()
3220 switch(edl->session->time_format)
3222 case TIME_HMS: edl->session->time_format = TIME_HMSF; break;
3223 case TIME_HMSF: edl->session->time_format = TIME_SAMPLES; break;
3224 case TIME_SAMPLES: edl->session->time_format = TIME_SAMPLES_HEX; break;
3225 case TIME_SAMPLES_HEX: edl->session->time_format = TIME_FRAMES; break;
3226 case TIME_FRAMES: edl->session->time_format = TIME_FEET_FRAMES; break;
3227 case TIME_FEET_FRAMES: edl->session->time_format = TIME_SECONDS; break;
3228 case TIME_SECONDS: edl->session->time_format = TIME_HMS; break;
3231 time_format_common();
3234 void MWindow::prev_time_format()
3236 switch(edl->session->time_format)
3238 case TIME_HMS: edl->session->time_format = TIME_SECONDS; break;
3239 case TIME_SECONDS: edl->session->time_format = TIME_FEET_FRAMES; break;
3240 case TIME_FEET_FRAMES: edl->session->time_format = TIME_FRAMES; break;
3241 case TIME_FRAMES: edl->session->time_format = TIME_SAMPLES_HEX; break;
3242 case TIME_SAMPLES_HEX: edl->session->time_format = TIME_SAMPLES; break;
3243 case TIME_SAMPLES: edl->session->time_format = TIME_HMSF; break;
3244 case TIME_HMSF: edl->session->time_format = TIME_HMS; break;
3247 time_format_common();
3250 void MWindow::time_format_common()
3252 gui->lock_window("MWindow::next_time_format");
3253 gui->redraw_time_dependancies();
3256 char string[BCTEXTLEN], string2[BCTEXTLEN];
3257 sprintf(string, _("Using %s"), Units::print_time_format(edl->session->time_format, string2));
3258 gui->show_message(string);
3260 gui->unlock_window();
3264 int MWindow::set_filename(const char *filename)
3266 if( filename != session->filename )
3267 strcpy(session->filename, filename);
3268 if( filename != edl->path )
3269 strcpy(edl->path, filename);
3273 if(filename[0] == 0)
3275 gui->set_title(PROGRAM_NAME);
3280 char string[BCTEXTLEN], string2[BCTEXTLEN];
3281 dir.extract_name(string, filename);
3282 sprintf(string2, PROGRAM_NAME ": %s", string);
3283 gui->set_title(string2);
3296 int MWindow::set_loop_boundaries()
3298 double start = edl->local_session->get_selectionstart();
3299 double end = edl->local_session->get_selectionend();
3307 if(edl->tracks->total_length())
3310 end = edl->tracks->total_length();
3317 if(edl->local_session->loop_playback && start != end)
3319 edl->local_session->loop_start = start;
3320 edl->local_session->loop_end = end;
3331 int MWindow::reset_meters()
3333 cwindow->gui->lock_window("MWindow::reset_meters 1");
3334 cwindow->gui->meters->reset_meters();
3335 cwindow->gui->unlock_window();
3337 for(int j = 0; j < vwindows.size(); j++) {
3338 VWindow *vwindow = vwindows[j];
3339 if( !vwindow->is_running() ) continue;
3340 vwindow->gui->lock_window("MWindow::reset_meters 2");
3341 vwindow->gui->meters->reset_meters();
3342 vwindow->gui->unlock_window();
3345 lwindow->gui->lock_window("MWindow::reset_meters 3");
3346 lwindow->gui->panel->reset_meters();
3347 lwindow->gui->unlock_window();
3349 gui->lock_window("MWindow::reset_meters 4");
3350 gui->reset_meters();
3351 gui->unlock_window();
3356 void MWindow::resync_guis()
3360 gui->lock_window("MWindow::resync_guis");
3361 gui->update(1, 1, 1, 1, 1, 1, 0);
3362 gui->unlock_window();
3364 cwindow->gui->lock_window("MWindow::resync_guis");
3365 cwindow->gui->resize_event(cwindow->gui->get_w(),
3366 cwindow->gui->get_h());
3367 int channels = edl->session->audio_channels;
3368 cwindow->gui->meters->set_meters(channels, 1);
3369 cwindow->gui->flush();
3370 cwindow->gui->unlock_window();
3372 for(int i = 0; i < vwindows.size(); i++) {
3373 VWindow *vwindow = vwindows[i];
3374 if( !vwindow->is_running() ) continue;
3375 vwindow->gui->lock_window("MWindow::resync_guis");
3376 vwindow->gui->resize_event(vwindow->gui->get_w(),
3377 vwindow->gui->get_h());
3378 vwindow->gui->meters->set_meters(channels, 1);
3379 vwindow->gui->flush();
3380 vwindow->gui->unlock_window();
3383 lwindow->gui->lock_window("MWindow::resync_guis");
3384 lwindow->gui->panel->set_meters(channels, 1);
3385 lwindow->gui->flush();
3386 lwindow->gui->unlock_window();
3389 if(((edl->session->output_w % 4) ||
3390 (edl->session->output_h % 4)) &&
3391 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
3393 MainError::show_error(
3394 _("This project's dimensions are not multiples of 4 so\n"
3395 "it can't be rendered by OpenGL."));
3400 sync_parameters(CHANGE_ALL);
3403 int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tracks)
3405 File *file = new File;
3406 EDLSession *session = edl->session;
3407 double old_framerate = session->frame_rate;
3408 double old_samplerate = session->sample_rate;
3409 int result = file->open_file(preferences, asset, 1, 0);
3410 if( !result && delete_tracks > 0 )
3411 undo->update_undo_before();
3412 if( !result && asset->get_video_layers() > 0 ) {
3413 // try to get asset up to date, may fail
3414 file->select_video_stream(asset, vstream);
3415 // either way use what was/is there.
3416 double framerate = asset->get_frame_rate();
3417 int width = asset->get_w();
3418 int height = asset->get_h();
3419 // must be multiple of 4 for opengl
3420 width = (width+3) & ~3; height = (height+3) & ~3;
3421 int driver = session->playback_config->vconfig->driver;
3422 int color_model = file->get_best_colormodel(asset, driver);
3423 // color_model = BC_CModels::is_yuv(color_model) ?
3424 // BC_CModels::has_alpha(color_model) ? BC_YUVA8888 : BC_YUV888 :
3425 // BC_CModels::is_float(color_model) ?
3426 // BC_CModels::has_alpha(color_model) ? BC_RGBA_FLOAT : BC_RGB_FLOAT :
3427 // BC_CModels::has_alpha(color_model) ? BC_RGBA8888 : BC_RGB888;
3428 // have alpha for now
3429 color_model = BC_CModels::is_yuv(color_model) ? BC_YUVA8888 :
3430 BC_CModels::is_float(color_model) ? BC_RGBA_FLOAT : BC_RGBA8888;
3431 session->color_model = color_model;
3432 session->output_w = width;
3433 session->output_h = height;
3434 session->frame_rate = framerate;
3435 // not, asset->actual_width/actual_height
3436 asset->width = session->output_w;
3437 asset->height = session->output_h;
3438 asset->frame_rate = session->frame_rate;
3439 create_aspect_ratio(session->aspect_w, session->aspect_h,
3440 session->output_w, session->output_h);
3441 Track *track = edl->tracks->first;
3442 for( Track *next_track=0; track; track=next_track ) {
3443 next_track = track->next;
3444 if( track->data_type != TRACK_VIDEO ) continue;
3445 if( delete_tracks ) {
3446 Edit *edit = track->edits->first;
3447 for( Edit *next_edit=0; edit; edit=next_edit ) {
3448 next_edit = edit->next;
3449 if( edit->channel != vstream ||
3450 !edit->asset || !edit->asset->is_asset ||
3451 *asset != *edit->asset )
3455 if( track->edits->first ) {
3456 track->track_w = edl->session->output_w;
3457 track->track_h = edl->session->output_h;
3459 else if( delete_tracks )
3460 edl->tracks->delete_track(track);
3462 edl->resample(old_framerate, session->frame_rate, TRACK_VIDEO);
3464 if( !result && asset->channels > 0 ) {
3465 session->sample_rate = asset->get_sample_rate();
3466 int64_t channel_mask = 0;
3467 int astrm = file->get_audio_for_video(vstream, astream, channel_mask);
3468 if( astrm >= 0 ) file->select_audio_stream(asset, astrm);
3469 if( astrm < 0 || !channel_mask ) channel_mask = (1<<asset->channels)-1;
3471 for( uint64_t mask=channel_mask; mask!=0; mask>>=1 ) channels += mask & 1;
3472 if( channels > 6 ) channels = 6;
3473 session->audio_tracks = session->audio_channels = channels;
3474 switch( channels ) {
3476 session->achannel_positions[0] = 90;
3477 session->achannel_positions[1] = 150;
3478 session->achannel_positions[2] = 30;
3479 session->achannel_positions[3] = 210;
3480 session->achannel_positions[4] = 330;
3481 session->achannel_positions[5] = 270;
3484 session->achannel_positions[0] = 180;
3485 session->achannel_positions[1] = 0;
3488 remap_audio(MWindow::AUDIO_1_TO_1);
3490 if( delete_tracks ) {
3491 Track *track = edl->tracks->first;
3492 for( Track *next_track=0; track; track=next_track ) {
3493 next_track = track->next;
3494 if( track->data_type != TRACK_AUDIO ) continue;
3495 Edit *edit = track->edits->first;
3496 for( Edit *next_edit=0; edit; edit=next_edit ) {
3497 next_edit = edit->next;
3498 if( !((1<<edit->channel) & channel_mask) ||
3499 !edit->asset || !edit->asset->is_asset ||
3500 *asset != *edit->asset )
3503 if( !track->edits->first )
3504 edl->tracks->delete_track(track);
3508 edl->resample(old_samplerate, session->sample_rate, TRACK_AUDIO);
3511 if( !result && delete_tracks > 0 ) {
3513 undo->update_undo_after(_("select asset"), LOAD_ALL);
3519 int MWindow::select_asset(int vtrack, int delete_tracks)
3521 Track *track = edl->tracks->get(vtrack, TRACK_VIDEO);
3522 if( !track ) return 1;
3523 Edit *edit = track->edits->first;
3524 if( !edit ) return 1;
3525 Asset *asset = edit->asset;
3526 if( !asset || !asset->is_asset ) return 1;
3527 return select_asset(asset, edit->channel, -1, delete_tracks);
3530 void MWindow::dump_plugindb(FILE *fp)
3532 if( !plugindb ) return;
3533 for(int i = 0; i < plugindb->total; i++)
3534 plugindb->get(i)->dump(fp);