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
1412 for(int j = 0; j < new_edls.total + 1; j++)
1415 if(j == new_edls.total)
1417 old_asset = edl->assets->get_asset(new_asset->path);
1420 *new_asset = *old_asset;
1426 old_asset = new_edls[j]->assets->get_asset(new_asset->path);
1429 *new_asset = *old_asset;
1439 char string[BCTEXTLEN];
1441 fs.extract_name(string, new_asset->path);
1443 strcat(string, _("'s format couldn't be determined."));
1444 new_asset->audio_data = 1;
1445 new_asset->format = FILE_PCM;
1446 new_asset->channels = defaults->get("AUDIO_CHANNELS", 2);
1447 new_asset->sample_rate = defaults->get("SAMPLE_RATE", 44100);
1448 new_asset->bits = defaults->get("AUDIO_BITS", 16);
1449 new_asset->byte_order = defaults->get("BYTE_ORDER", 1);
1450 new_asset->signed_ = defaults->get("SIGNED_", 1);
1451 new_asset->header = defaults->get("HEADER", 0);
1453 FileFormat fwindow(this);
1454 fwindow.create_objects(new_asset, string);
1455 result = fwindow.run_window();
1458 defaults->update("AUDIO_CHANNELS", new_asset->channels);
1459 defaults->update("SAMPLE_RATE", new_asset->sample_rate);
1460 defaults->update("AUDIO_BITS", new_asset->bits);
1461 defaults->update("BYTE_ORDER", new_asset->byte_order);
1462 defaults->update("SIGNED_", new_asset->signed_);
1463 defaults->update("HEADER", new_asset->header);
1470 // Recalculate length
1472 new_file = new File;
1473 result = new_file->open_file(preferences, new_asset, 1, 0);
1475 if(load_mode != LOADMODE_RESOURCESONLY)
1477 RecordLabels *labels = edl->session->label_cells ?
1478 new RecordLabels(new_file) : 0;
1479 asset_to_edl(new_edl, new_asset, labels);
1480 new_edls.append(new_edl);
1481 new_asset->Garbage::remove_user();
1487 new_assets.append(new_asset);
1501 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1502 xml_file.read_from_file(filenames->get(i));
1503 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1505 if(load_mode == LOADMODE_NESTED)
1507 // Load temporary EDL for nesting.
1508 EDL *nested_edl = new EDL;
1509 nested_edl->create_objects();
1510 nested_edl->set_path(filenames->get(i));
1511 nested_edl->load_xml(&xml_file, LOAD_ALL);
1512 //printf("MWindow::load_filenames %p %s\n", nested_edl, nested_edl->project_path);
1513 edl_to_nested(new_edl, nested_edl);
1514 nested_edl->Garbage::remove_user();
1518 // Load EDL for pasting
1519 new_edl->load_xml(&xml_file, LOAD_ALL);
1520 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1521 test_plugins(new_edl, filenames->get(i));
1522 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1524 if(load_mode == LOADMODE_REPLACE ||
1525 load_mode == LOADMODE_REPLACE_CONCATENATE)
1527 strcpy(session->filename, filenames->get(i));
1528 strcpy(new_edl->local_session->clip_title,
1531 set_filename(new_edl->local_session->clip_title);
1535 new_edls.append(new_edl);
1541 // edls are in new_edls
1542 if( result && new_edl ) new_edl->Garbage::remove_user();
1543 // assets are copied
1544 if( new_asset ) new_asset->Garbage::remove_user();
1546 // Store for testing index
1547 new_files.append(new_file);
1550 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1553 if(!result) gui->statusbar->default_message();
1561 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1564 // Don't back up here.
1567 // For pasting, clear the active region
1568 if(load_mode == LOADMODE_PASTE ||
1569 load_mode == LOADMODE_NESTED)
1571 double start = edl->local_session->get_selectionstart();
1572 double end = edl->local_session->get_selectionend();
1573 if(!EQUIV(start, end))
1576 edl->session->labels_follow_edits,
1577 edl->session->plugins_follow_edits,
1578 edl->session->autos_follow_edits);
1581 paste_edls(&new_edls,
1585 edl->session->labels_follow_edits,
1586 edl->session->plugins_follow_edits,
1587 edl->session->autos_follow_edits,
1594 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1596 // Add new assets to EDL and schedule assets for index building.
1597 int got_indexes = 0;
1598 for(int i = 0; i < new_edls.size(); i++)
1600 EDL *new_edl = new_edls[i];
1601 for(int j = 0; j < new_edl->nested_edls->size(); j++)
1603 mainindexes->add_next_asset(0,
1604 new_edl->nested_edls->get(j));
1606 edl->nested_edls->update_index(new_edl->nested_edls->get(j));
1611 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1612 if(new_assets.size())
1614 for(int i = 0; i < new_assets.size(); i++)
1616 Asset *new_asset = new_assets[i];
1620 for(int j = 0; j < new_files.size(); j++)
1622 new_file = new_files[j];
1623 if(!strcmp(new_file->asset->path,
1631 mainindexes->add_next_asset(got_it ? new_file : 0, new_asset);
1633 edl->assets->update(new_asset);
1639 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1641 // Start examining next batch of index files
1642 if(got_indexes) mainindexes->start_build();
1643 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1646 Track *track = edl->tracks->first;
1649 for(int j = 0; j < track->plugin_set.size(); j++)
1651 PluginSet *plugins = track->plugin_set[j];
1652 Plugin *plugin = plugins->get_first_plugin();
1656 if(load_mode == LOADMODE_REPLACE ||
1657 load_mode == LOADMODE_REPLACE_CONCATENATE)
1659 if(plugin->plugin_type == PLUGIN_STANDALONE &&
1662 show_plugin(plugin);
1670 plugin = (Plugin*)plugin->next;
1674 track = track->next;
1677 // if just opening one new resource in replace mode
1678 if( load_mode == LOADMODE_REPLACE && new_edls.size() == 1 &&
1679 ftype != FILE_IS_XML )
1682 edl->local_session->preview_start = 0;
1683 edl->local_session->preview_end = edl->tracks->total_playable_length();
1684 edl->local_session->loop_playback = 0;
1685 edl->local_session->set_selectionstart(0);
1686 edl->local_session->set_selectionend(0);
1691 // need to update undo before project, since mwindow is unlocked & a new load
1692 // can begin here. Should really prevent loading until we're done.
1693 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1694 undo->update_undo_after(_("load"), LOAD_ALL);
1696 for(int i = 0; i < new_edls.size(); i++)
1698 new_edls[i]->remove_user();
1700 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1702 new_edls.remove_all();
1704 for(int i = 0; i < new_assets.size(); i++)
1706 new_assets[i]->Garbage::remove_user();
1709 new_assets.remove_all();
1710 new_files.remove_all_objects();
1713 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1714 if(load_mode == LOADMODE_REPLACE ||
1715 load_mode == LOADMODE_REPLACE_CONCATENATE)
1717 session->changes_made = 0;
1721 session->changes_made = 1;
1724 gui->stop_hourglass();
1727 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1728 update_project(load_mode);
1730 if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
1738 void MWindow::test_plugins(EDL *new_edl, char *path)
1740 char string[BCTEXTLEN];
1742 // Do a check weather plugins exist
1743 for(Track *track = new_edl->tracks->first; track; track = track->next)
1745 for(int k = 0; k < track->plugin_set.total; k++)
1747 PluginSet *plugin_set = track->plugin_set[k];
1748 for(Plugin *plugin = (Plugin*)plugin_set->first;
1750 plugin = (Plugin*)plugin->next)
1752 if(plugin->plugin_type == PLUGIN_STANDALONE)
1754 // ok we need to find it in plugindb
1755 int plugin_found = 0;
1757 for(int j = 0; j < plugindb->size(); j++)
1759 PluginServer *server = plugindb->get(j);
1761 !strcasecmp(server->title, plugin->title) &&
1762 ((track->data_type == TRACK_AUDIO && server->audio) ||
1763 (track->data_type == TRACK_VIDEO && server->video)) &&
1764 (!server->transition))
1771 _("The %s '%s' in file '%s' is not part of your installation of Cinelerra.\n"
1772 "The project won't be rendered as it was meant and Cinelerra might crash.\n"),
1773 "effect", plugin->title,
1775 MainError::show_error(string);
1781 for(Edit *edit = (Edit*)track->edits->first;
1783 edit = (Edit*)edit->next)
1785 if (edit->transition)
1787 // ok we need to find transition in plugindb
1789 int transition_found = 0;
1790 for(int j = 0; j < plugindb->size(); j++)
1792 PluginServer *server = plugindb->get(j);
1794 !strcasecmp(server->title, edit->transition->title) &&
1795 ((track->data_type == TRACK_AUDIO && server->audio) ||
1796 (track->data_type == TRACK_VIDEO && server->video)) &&
1797 (server->transition))
1798 transition_found = 1;
1801 if (!transition_found)
1804 _("The %s '%s' in file '%s' is not part of your installation of Cinelerra.\n"
1805 "The project won't be rendered as it was meant and Cinelerra might crash.\n"),
1806 "transition", edit->transition->title,
1808 MainError::show_error(string);
1816 void MWindow::init_shm()
1818 // Fix shared memory
1819 FILE *fd = fopen("/proc/sys/kernel/shmmax", "w");
1821 fprintf(fd, "0x7fffffff");
1826 fd = fopen("/proc/sys/kernel/shmmax", "r");
1828 MainError::show_error("MWindow::init_shm: couldn't open /proc/sys/kernel/shmmax for reading.\n");
1833 fscanf(fd, _LD, &result);
1836 if(result < 0x7fffffff) {
1837 eprintf(_("MWindow::init_shm: /proc/sys/kernel/shmmax is %p.\n"
1838 "you probably need to be root, or:\n"
1839 "as root, run: echo 0x7fffffff > /proc/sys/kernel/shmmax\n"
1840 "before trying to start cinelerra.\n"
1841 "It should be at least 0x7fffffff for Cinelerra.\n"), (void *)result);
1845 void MWindow::create_objects(int want_gui,
1850 const int debug = 0;
1851 if(debug) PRINT_TRACE
1853 // For some reason, init_signals must come after show_splash or the signals won't
1856 if(debug) PRINT_TRACE
1859 if(debug) PRINT_TRACE
1862 if(debug) PRINT_TRACE
1863 default_standard = default_std();
1864 init_defaults(defaults, config_path);
1867 splash_window->operation->update(_("Initializing Plugins"));
1868 init_plugins(this, preferences);
1869 if(debug) PRINT_TRACE
1870 init_ladspa_plugins(this, preferences);
1871 if(debug) PRINT_TRACE
1873 splash_window->operation->update(_("Initializing GUI"));
1874 if(debug) PRINT_TRACE
1877 if(debug) PRINT_TRACE
1881 splash_window->operation->update(_("Initializing Fonts"));
1882 char string[BCTEXTLEN];
1883 strcpy(string, preferences->plugin_dir);
1884 strcat(string, "/" FONT_SEARCHPATH);
1885 BC_Resources::init_fontconfig(string);
1886 if(debug) PRINT_TRACE
1888 // Initialize before too much else is running
1889 // Preferences & theme are required for building MPEG table of contents
1891 // Default project created here
1893 if(debug) PRINT_TRACE
1896 if(debug) PRINT_TRACE
1901 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1903 //printf("MWindow::create_objects %d session->show_vwindow=%d\n", __LINE__, session->show_vwindow);
1904 if(session->show_vwindow)
1905 get_viewer(1, DEFAULT_VWINDOW);
1906 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1909 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());
1915 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());
1920 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1924 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1926 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1928 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1932 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1933 mainprogress = new MainProgress(this, gui);
1934 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1935 undo = new MainUndo(this);
1937 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1939 plugin_guis = new ArrayList<PluginServer*>;
1940 dead_plugins = new ArrayList<PluginServer*>;
1941 keyframe_threads = new ArrayList<KeyFrameThread*>;
1943 if(debug) printf("MWindow::create_objects %d vwindows=%d show_vwindow=%d\n",
1946 session->show_vwindow);
1948 // Show all vwindows
1949 // if(session->show_vwindow) {
1950 // for(int j = 0; j < vwindows.size(); j++) {
1951 // VWindow *vwindow = vwindows[j];
1952 // if( !vwindow->is_running() ) continue;
1953 // if(debug) printf("MWindow::create_objects %d vwindow=%p\n",
1956 // if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1957 // vwindow->gui->lock_window("MWindow::create_objects 1");
1958 // if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1959 // vwindow->gui->show_window();
1960 // if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1961 // vwindow->gui->unlock_window();
1966 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1968 if(session->show_cwindow)
1970 cwindow->gui->lock_window("MWindow::create_objects 1");
1971 cwindow->gui->show_window();
1972 cwindow->gui->unlock_window();
1975 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1976 if(session->show_awindow)
1978 awindow->gui->lock_window("MWindow::create_objects 1");
1979 awindow->gui->show_window();
1980 awindow->gui->unlock_window();
1983 if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference());
1984 if(session->show_lwindow)
1986 lwindow->gui->lock_window("MWindow::create_objects 1");
1987 lwindow->gui->show_window();
1988 lwindow->gui->unlock_window();
1991 if(debug) printf("MWindow::create_objects %d total_time=%d gwindow=%p\n",
1993 (int)timer.get_difference(),
1995 if(session->show_gwindow)
1997 gwindow->gui->lock_window("MWindow::create_objects 1");
1998 gwindow->gui->show_window();
1999 gwindow->gui->unlock_window();
2002 if(debug) PRINT_TRACE
2004 gui->lock_window("MWindow::create_objects 1");
2005 gui->mainmenu->load_defaults(defaults);
2006 gui->mainmenu->update_toggles(0);
2007 gui->update_patchbay();
2008 gui->draw_canvas(0, 0);
2009 gui->draw_cursor(1);
2011 gui->raise_window();
2012 gui->unlock_window();
2014 if(debug) PRINT_TRACE
2016 if(preferences->use_tipwindow)
2018 if(debug) PRINT_TRACE
2020 gui->add_keyboard_listener(
2021 (int (BC_WindowBase::*)(BC_WindowBase *))
2022 &MWindowGUI::keyboard_listener);
2026 if(debug) PRINT_TRACE
2028 BC_WindowBase::get_resources()->vframe_shm = 1;
2032 void MWindow::show_splash()
2034 #include "data/heroine_logo9_png.h"
2035 VFrame *frame = new VFramePng(heroine_logo9_png);
2036 BC_DisplayInfo dpyi;
2037 int rw = dpyi.get_root_w(), rh = dpyi.get_root_h();
2038 int rr = (rw < rh ? rw : rh) / 4;
2039 splash_window = new SplashGUI(frame, rr, rr);
2040 splash_window->create_objects();
2043 void MWindow::hide_splash()
2046 delete splash_window;
2051 void MWindow::start()
2055 // vwindows[DEFAULT_VWINDOW]->start();
2066 playback_3d->start();
2075 void MWindow::show_vwindow()
2077 int total_running = 0;
2078 session->show_vwindow = 1;
2080 //printf("MWindow::show_vwindow %d %d\n", __LINE__, vwindows.size());
2081 // Raise all windows which are visible
2082 for(int j = 0; j < vwindows.size(); j++) {
2083 VWindow *vwindow = vwindows[j];
2084 if( !vwindow->is_running() ) continue;
2085 vwindow->gui->lock_window("MWindow::show_vwindow");
2086 vwindow->gui->show_window(0);
2087 vwindow->gui->raise_window();
2088 vwindow->gui->flush();
2089 vwindow->gui->unlock_window();
2093 // If no windows visible
2096 get_viewer(1, DEFAULT_VWINDOW);
2099 gui->mainmenu->show_vwindow->set_checked(1);
2102 void MWindow::show_awindow()
2104 session->show_awindow = 1;
2105 awindow->gui->lock_window("MWindow::show_awindow");
2106 awindow->gui->show_window();
2107 awindow->gui->raise_window();
2108 awindow->gui->flush();
2109 awindow->gui->unlock_window();
2110 gui->mainmenu->show_awindow->set_checked(1);
2113 char *MWindow::get_cwindow_display()
2115 char *x11_host = screens < 2 || session->window_config == 0 ?
2116 session->a_x11_host : session->b_x11_host;
2117 return *x11_host ? x11_host : 0;
2120 void MWindow::show_cwindow()
2122 session->show_cwindow = 1;
2123 cwindow->show_window();
2124 gui->mainmenu->show_cwindow->set_checked(1);
2127 void MWindow::show_gwindow()
2129 session->show_gwindow = 1;
2131 gwindow->gui->lock_window("MWindow::show_gwindow");
2132 gwindow->gui->show_window();
2133 gwindow->gui->raise_window();
2134 gwindow->gui->flush();
2135 gwindow->gui->unlock_window();
2137 gui->mainmenu->show_gwindow->set_checked(1);
2140 void MWindow::show_lwindow()
2142 session->show_lwindow = 1;
2143 lwindow->gui->lock_window("MWindow::show_lwindow");
2144 lwindow->gui->show_window();
2145 lwindow->gui->raise_window();
2146 lwindow->gui->flush();
2147 lwindow->gui->unlock_window();
2148 gui->mainmenu->show_lwindow->set_checked(1);
2151 int MWindow::tile_windows(int window_config)
2153 int need_reload = 0;
2154 int play_config = window_config==0 ? 0 : 1;
2155 edl->session->playback_config->load_defaults(defaults, play_config);
2156 session->default_window_positions(window_config);
2157 if( screens == 1 ) {
2158 gui->default_positions();
2159 sync_parameters(CHANGE_ALL);
2166 void MWindow::toggle_loop_playback()
2168 edl->local_session->loop_playback = !edl->local_session->loop_playback;
2169 set_loop_boundaries();
2172 gui->draw_overlays(1);
2173 sync_parameters(CHANGE_PARAMS);
2176 //void MWindow::set_titles(int value)
2178 // edl->session->show_titles = value;
2179 // trackmovement(edl->local_session->track_start);
2182 void MWindow::set_screens(int value)
2187 void MWindow::set_auto_keyframes(int value, int lock_mwindow, int lock_cwindow)
2189 if(lock_mwindow) gui->lock_window("MWindow::set_auto_keyframes");
2190 edl->session->auto_keyframes = value;
2191 gui->mbuttons->edit_panel->keyframe->update(value);
2193 if(lock_mwindow) gui->unlock_window();
2195 if(lock_cwindow) cwindow->gui->lock_window("MWindow::set_auto_keyframes");
2196 cwindow->gui->edit_panel->keyframe->update(value);
2197 cwindow->gui->flush();
2198 if(lock_cwindow) cwindow->gui->unlock_window();
2201 void MWindow::set_keyframe_type(int mode)
2203 gui->lock_window("MWindow::set_keyframe_type");
2204 edl->local_session->floatauto_type = mode;
2205 gui->mainmenu->update_toggles(0);
2206 gui->unlock_window();
2209 int MWindow::set_editing_mode(int new_editing_mode, int lock_mwindow, int lock_cwindow)
2211 if(lock_mwindow) gui->lock_window("MWindow::set_editing_mode");
2212 edl->session->editing_mode = new_editing_mode;
2213 gui->mbuttons->edit_panel->editing_mode = edl->session->editing_mode;
2214 gui->mbuttons->edit_panel->update();
2215 gui->set_editing_mode(1);
2216 if(lock_mwindow) gui->unlock_window();
2219 if(lock_cwindow) cwindow->gui->lock_window("MWindow::set_editing_mode");
2220 cwindow->gui->edit_panel->update();
2221 cwindow->gui->edit_panel->editing_mode = edl->session->editing_mode;
2222 if(lock_cwindow) cwindow->gui->unlock_window();
2226 void MWindow::toggle_editing_mode()
2228 int mode = edl->session->editing_mode;
2229 if( mode == EDITING_ARROW )
2230 set_editing_mode(EDITING_IBEAM, 0, 1);
2232 set_editing_mode(EDITING_ARROW, 0, 1);
2236 void MWindow::set_labels_follow_edits(int value)
2238 gui->lock_window("MWindow::set_labels_follow_edits");
2239 edl->session->labels_follow_edits = value;
2240 gui->mbuttons->edit_panel->locklabels->update(value);
2241 gui->mainmenu->labels_follow_edits->set_checked(value);
2243 gui->unlock_window();
2246 void MWindow::sync_parameters(int change_type)
2248 if( in_destructor ) return;
2250 // Sync engines which are playing back
2251 if(cwindow->playback_engine->is_playing_back)
2253 if(change_type == CHANGE_PARAMS)
2255 // TODO: block keyframes until synchronization is done
2256 cwindow->playback_engine->sync_parameters(edl);
2261 int command = cwindow->playback_engine->command->command;
2262 cwindow->playback_engine->que->send_command(STOP,
2266 // Waiting for tracking to finish would make the restart position more
2267 // accurate but it can't lock the window to stop tracking for some reason.
2268 // Not waiting for tracking gives a faster response but restart position is
2269 // only as accurate as the last tracking update.
2270 cwindow->playback_engine->interrupt_playback(0);
2271 cwindow->playback_engine->que->send_command(command,
2280 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2287 void MWindow::age_caches()
2289 // printf("MWindow::age_caches %d %lld %lld %lld %lld\n",
2291 // preferences->cache_size,
2292 // audio_cache->get_memory_usage(1),
2293 // video_cache->get_memory_usage(1),
2294 // frame_cache->get_memory_usage(),
2295 // wave_cache->get_memory_usage(),
2297 frame_cache->age_cache(512);
2298 wave_cache->age_cache(8192);
2300 int64_t memory_usage;
2301 int64_t prev_memory_usage = 0;
2303 int64_t video_size = (int64_t)(preferences->cache_size * 0.80);
2304 while( !result && prev_memory_usage !=
2305 (memory_usage=video_cache->get_memory_usage(1)) &&
2306 memory_usage > video_size ) {
2307 video_cache->delete_oldest();
2308 prev_memory_usage = memory_usage;
2311 prev_memory_usage = 0;
2313 int64_t audio_size = (int64_t)(preferences->cache_size * 0.20);
2314 while( !result && prev_memory_usage !=
2315 (memory_usage=audio_cache->get_memory_usage(1)) &&
2316 memory_usage > audio_size ) {
2317 audio_cache->delete_oldest();
2318 prev_memory_usage = memory_usage;
2322 void MWindow::reset_android_remote()
2324 gui->use_android_remote(preferences->android_remote);
2328 void MWindow::show_keyframe_gui(Plugin *plugin)
2330 keyframe_gui_lock->lock("MWindow::show_keyframe_gui");
2331 // Find existing thread
2332 for(int i = 0; i < keyframe_threads->size(); i++)
2334 if(keyframe_threads->get(i)->plugin == plugin)
2336 keyframe_threads->get(i)->start_window(plugin, 0);
2337 keyframe_gui_lock->unlock();
2342 // Find unused thread
2343 for(int i = 0; i < keyframe_threads->size(); i++)
2345 if(!keyframe_threads->get(i)->plugin)
2347 keyframe_threads->get(i)->start_window(plugin, 0);
2348 keyframe_gui_lock->unlock();
2353 // Create new thread
2354 KeyFrameThread *thread = new KeyFrameThread(this);
2355 keyframe_threads->append(thread);
2356 thread->start_window(plugin, 0);
2358 keyframe_gui_lock->unlock();
2365 void MWindow::show_plugin(Plugin *plugin)
2370 // Remove previously deleted plugin GUIs
2371 dead_plugin_lock->lock("MWindow::show_plugin");
2372 dead_plugins->remove_all_objects();
2373 dead_plugin_lock->unlock();
2375 //printf("MWindow::show_plugin %d\n", __LINE__);
2379 plugin_gui_lock->lock("MWindow::show_plugin");
2380 for(int i = 0; i < plugin_guis->total; i++)
2382 // Pointer comparison
2383 if(plugin_guis->get(i)->plugin == plugin)
2385 plugin_guis->get(i)->raise_window();
2392 //printf("MWindow::show_plugin 1\n");
2397 printf("MWindow::show_plugin track not defined.\n");
2399 PluginServer *server = scan_plugindb(plugin->title,
2400 plugin->track->data_type);
2402 //printf("MWindow::show_plugin %p %d\n", server, server->uses_gui);
2403 if(server && server->uses_gui)
2405 PluginServer *gui = new PluginServer(*server);
2406 plugin_guis->append(gui);
2407 // Needs mwindow to do GUI
2408 gui->set_mwindow(this);
2409 gui->open_plugin(0, preferences, edl, plugin);
2414 plugin_gui_lock->unlock();
2415 //printf("MWindow::show_plugin %d\n", __LINE__);
2418 //printf("MWindow::show_plugin 2\n");
2421 void MWindow::hide_plugin(Plugin *plugin, int lock)
2424 // Update the toggle
2425 gui->lock_window("MWindow::hide_plugin");
2426 gui->update(0, 1, 0, 0, 0, 0, 0);
2427 gui->unlock_window();
2429 if(lock) plugin_gui_lock->lock("MWindow::hide_plugin");
2430 for(int i = 0; i < plugin_guis->total; i++)
2432 if(plugin_guis->get(i)->plugin == plugin)
2434 PluginServer *ptr = plugin_guis->get(i);
2435 plugin_guis->remove(ptr);
2436 if(lock) plugin_gui_lock->unlock();
2437 // Last command executed in client side close
2438 // Schedule for deletion
2445 if(lock) plugin_gui_lock->unlock();
2448 void MWindow::delete_plugin(PluginServer *plugin)
2450 dead_plugin_lock->lock("MWindow::delete_plugin");
2451 dead_plugins->append(plugin);
2452 dead_plugin_lock->unlock();
2455 void MWindow::hide_plugins()
2457 plugin_gui_lock->lock("MWindow::hide_plugins 1");
2458 while(plugin_guis->size())
2460 PluginServer *ptr = plugin_guis->get(0);
2461 plugin_guis->remove(ptr);
2462 plugin_gui_lock->unlock();
2463 // Last command executed in client side close
2464 // Schedule for deletion
2467 plugin_gui_lock->lock("MWindow::hide_plugins 2");
2469 plugin_gui_lock->unlock();
2471 hide_keyframe_guis();
2474 void MWindow::hide_keyframe_guis()
2476 keyframe_gui_lock->lock("MWindow::hide_keyframe_guis");
2477 for(int i = 0; i < keyframe_threads->size(); i++)
2479 keyframe_threads->get(i)->close_window();
2481 keyframe_gui_lock->unlock();
2484 void MWindow::hide_keyframe_gui(Plugin *plugin)
2486 keyframe_gui_lock->lock("MWindow::hide_keyframe_gui");
2487 for(int i = 0; i < keyframe_threads->size(); i++)
2489 if(keyframe_threads->get(i)->plugin == plugin)
2491 keyframe_threads->get(i)->close_window();
2495 keyframe_gui_lock->unlock();
2498 void MWindow::update_keyframe_guis()
2500 // Send new configuration to keyframe GUI's
2501 keyframe_gui_lock->lock("MWindow::update_keyframe_guis");
2502 for(int i = 0; i < keyframe_threads->size(); i++)
2504 KeyFrameThread *ptr = keyframe_threads->get(i);
2505 if(edl->tracks->plugin_exists(ptr->plugin))
2509 ptr->close_window();
2512 keyframe_gui_lock->unlock();
2515 void MWindow::update_plugin_guis(int do_keyframe_guis)
2517 // Send new configuration to plugin GUI's
2518 plugin_gui_lock->lock("MWindow::update_plugin_guis");
2520 for(int i = 0; i < plugin_guis->size(); i++)
2522 PluginServer *ptr = plugin_guis->get(i);
2523 if(edl->tracks->plugin_exists(ptr->plugin))
2527 // Schedule for deletion if no plugin
2528 plugin_guis->remove_number(i);
2537 // Change plugin variable if not visible
2538 Track *track = edl->tracks->first;
2541 for(int i = 0; i < track->plugin_set.size(); i++)
2543 Plugin *plugin = (Plugin*)track->plugin_set[i]->first;
2547 for(int i = 0; i < plugin_guis->size(); i++)
2549 PluginServer *server = plugin_guis->get(i);
2550 if(server->plugin == plugin)
2557 if(!got_it) plugin->show = 0;
2559 plugin = (Plugin*)plugin->next;
2563 track = track->next;
2566 plugin_gui_lock->unlock();
2569 if(do_keyframe_guis) update_keyframe_guis();
2572 int MWindow::plugin_gui_open(Plugin *plugin)
2575 plugin_gui_lock->lock("MWindow::plugin_gui_open");
2576 for(int i = 0; i < plugin_guis->total; i++)
2578 if(plugin_guis->get(i)->plugin->identical_location(plugin))
2584 plugin_gui_lock->unlock();
2588 void MWindow::render_plugin_gui(void *data, Plugin *plugin)
2590 plugin_gui_lock->lock("MWindow::render_plugin_gui");
2591 for(int i = 0; i < plugin_guis->total; i++)
2593 if(plugin_guis->get(i)->plugin->identical_location(plugin))
2595 plugin_guis->get(i)->render_gui(data);
2599 plugin_gui_lock->unlock();
2602 void MWindow::render_plugin_gui(void *data, int size, Plugin *plugin)
2604 plugin_gui_lock->lock("MWindow::render_plugin_gui");
2605 for(int i = 0; i < plugin_guis->total; i++)
2607 if(plugin_guis->get(i)->plugin->identical_location(plugin))
2609 plugin_guis->get(i)->render_gui(data, size);
2613 plugin_gui_lock->unlock();
2617 void MWindow::update_plugin_states()
2619 plugin_gui_lock->lock("MWindow::update_plugin_states");
2620 for(int i = 0; i < plugin_guis->total; i++)
2624 Plugin *src_plugin = plugin_guis->get(i)->plugin;
2625 PluginServer *src_plugingui = plugin_guis->get(i);
2627 // Search for plugin in EDL. Only the master EDL shows plugin GUIs.
2628 for(Track *track = edl->tracks->first;
2630 track = track->next)
2633 j < track->plugin_set.total && !result;
2636 PluginSet *plugin_set = track->plugin_set[j];
2637 for(Plugin *plugin = (Plugin*)plugin_set->first;
2639 plugin = (Plugin*)plugin->next)
2641 if(plugin == src_plugin &&
2642 !strcmp(plugin->title, src_plugingui->title)) result = 1;
2648 // Doesn't exist anymore
2651 hide_plugin(src_plugin, 0);
2655 plugin_gui_lock->unlock();
2659 void MWindow::update_plugin_titles()
2661 for(int i = 0; i < plugin_guis->total; i++)
2663 plugin_guis->get(i)->update_title();
2667 int MWindow::asset_to_edl(EDL *new_edl,
2669 RecordLabels *labels)
2671 const int debug = 0;
2672 if(debug) printf("MWindow::asset_to_edl %d new_asset->layers=%d\n",
2675 // Keep frame rate, sample rate, and output size unchanged.
2676 // These parameters would revert the project if VWindow displayed an asset
2677 // of different size than the project.
2678 if(new_asset->video_data)
2680 new_edl->session->video_tracks = new_asset->layers;
2683 new_edl->session->video_tracks = 0;
2685 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2691 if(new_asset->audio_data)
2693 new_edl->session->audio_tracks = new_asset->channels;
2696 new_edl->session->audio_tracks = 0;
2697 //printf("MWindow::asset_to_edl 2 %d %d\n", new_edl->session->video_tracks, new_edl->session->audio_tracks);
2699 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2700 new_edl->create_default_tracks();
2701 //printf("MWindow::asset_to_edl 2 %d %d\n", new_edl->session->video_tracks, new_edl->session->audio_tracks);
2702 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2706 //printf("MWindow::asset_to_edl 3\n");
2707 new_edl->insert_asset(new_asset,
2712 //printf("MWindow::asset_to_edl 3\n");
2713 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2715 // Align cursor on frames:: clip the new_edl to the minimum of the last joint frame.
2716 if(edl->session->cursor_on_frames)
2718 double length = new_edl->tracks->total_length();
2719 double edl_length = new_edl->tracks->total_length_framealigned(edl->session->frame_rate);
2720 new_edl->tracks->clear(length, edl_length, 1, 1);
2726 char string[BCTEXTLEN];
2728 fs.extract_name(string, new_asset->path);
2729 //printf("MWindow::asset_to_edl 3\n");
2731 strcpy(new_edl->local_session->clip_title, string);
2732 //printf("MWindow::asset_to_edl 4 %s\n", string);
2733 if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__);
2738 int MWindow::edl_to_nested(EDL *new_edl,
2742 // Keep frame rate, sample rate, and output size unchanged.
2743 // These parameters would revert the project if VWindow displayed an asset
2744 // of different size than the project.
2748 // Nest all video & audio outputs
2749 new_edl->session->video_tracks = 1;
2750 new_edl->session->audio_tracks = nested_edl->session->audio_channels;
2751 new_edl->create_default_tracks();
2755 new_edl->insert_asset(0,
2761 char string[BCTEXTLEN];
2763 fs.extract_name(string, nested_edl->path);
2764 //printf("MWindow::edl_to_nested %p %s\n", nested_edl, nested_edl->path);
2766 strcpy(new_edl->local_session->clip_title, string);
2771 // Reset everything after a load.
2772 void MWindow::update_project(int load_mode)
2774 const int debug = 0;
2776 if(debug) PRINT_TRACE
2778 edl->tracks->update_y_pixels(theme);
2780 if(debug) PRINT_TRACE
2782 if(load_mode == LOADMODE_REPLACE ||
2783 load_mode == LOADMODE_REPLACE_CONCATENATE)
2788 gui->update(1, 1, 1, 1, 1, 1, 1);
2789 if(debug) PRINT_TRACE
2790 gui->unlock_window();
2792 cwindow->gui->lock_window("MWindow::update_project 1");
2793 cwindow->update(0, 0, 1, 1, 1);
2794 cwindow->gui->unlock_window();
2796 if(debug) PRINT_TRACE
2798 // Close all the vwindows
2799 if(load_mode == LOADMODE_REPLACE ||
2800 load_mode == LOADMODE_REPLACE_CONCATENATE) {
2801 if(debug) PRINT_TRACE
2802 int first_vwindow = 0;
2803 if(session->show_vwindow) first_vwindow = 1;
2804 // Change visible windows to no source
2805 for(int i = 0; i < first_vwindow && i < vwindows.size(); i++) {
2806 VWindow *vwindow = vwindows[i];
2807 if( !vwindow->is_running() ) continue;
2808 vwindow->change_source(-1);
2811 // Close remaining windows
2812 for(int i = first_vwindow; i < vwindows.size(); i++) {
2813 VWindow *vwindow = vwindows[i];
2814 if( !vwindow->is_running() ) continue;
2815 vwindow->close_window();
2817 if(debug) PRINT_TRACE
2819 else if(vwindows.size()) {
2820 VWindow *vwindow = vwindows[DEFAULT_VWINDOW];
2821 if( vwindow->is_running() ) {
2822 vwindow->gui->lock_window("MWindow::update_project");
2824 vwindow->gui->unlock_window();
2828 if(debug) PRINT_TRACE
2829 cwindow->gui->lock_window("MWindow::update_project 2");
2830 cwindow->gui->timebar->update(0);
2831 cwindow->gui->unlock_window();
2833 if(debug) PRINT_TRACE
2834 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
2839 awindow->gui->async_update_assets();
2840 if(debug) PRINT_TRACE
2842 gui->lock_window("MWindow::update_project");
2844 if(debug) PRINT_TRACE
2847 void MWindow::remove_indexfile(Indexable *indexable)
2849 if( !indexable->is_asset ) return;
2850 Asset *asset = (Asset *)indexable;
2852 IndexFile::delete_index(preferences, asset, ".toc");
2853 IndexFile::delete_index(preferences, asset, ".idx");
2854 IndexFile::delete_index(preferences, asset, ".mkr");
2857 void MWindow::rebuild_indices()
2859 for(int i = 0; i < session->drag_assets->total; i++)
2861 Indexable *indexable = session->drag_assets->get(i);
2862 //printf("MWindow::rebuild_indices 1 %s\n", indexable->path);
2863 remove_indexfile(indexable);
2864 // Schedule index build
2865 IndexState *index_state = indexable->index_state;
2866 index_state->index_status = INDEX_NOTTESTED;
2867 if( indexable->is_asset ) {
2868 Asset *asset = (Asset *)indexable;
2869 if( asset->format != FILE_PCM )
2870 asset->reset_audio();
2871 asset->reset_video();
2873 mainindexes->add_next_asset(0, indexable);
2875 mainindexes->start_build();
2879 void MWindow::save_backup()
2882 edl->set_path(session->filename);
2883 edl->save_xml(&file,
2887 file.terminate_string();
2888 char path[BCTEXTLEN];
2890 strcpy(path, BACKUP_PATH);
2891 fs.complete_path(path);
2893 if(file.write_to_file(path))
2896 sprintf(string2, _("Couldn't open %s for writing."), BACKUP_PATH);
2897 gui->show_message(string2);
2901 void MWindow::load_backup()
2903 ArrayList<char*> path_list;
2904 path_list.set_array_delete();
2906 char string[BCTEXTLEN];
2907 strcpy(string, BACKUP_PATH);
2909 fs.complete_path(string);
2911 path_list.append(out_path = new char[strlen(string) + 1]);
2912 strcpy(out_path, string);
2914 load_filenames(&path_list, LOADMODE_REPLACE, 0);
2915 edl->local_session->clip_title[0] = 0;
2916 // This is unique to backups since the path of the backup is different than the
2917 // path of the project.
2918 set_filename(edl->path);
2919 path_list.remove_all_objects();
2923 static inline int gcd(int m, int n)
2926 if( m < n ) { r = m; m = n; n = r; }
2927 while( (r = m % n) != 0 ) { m = n; n = r; }
2931 int MWindow::create_aspect_ratio(float &w, float &h, int width, int height)
2934 if(!width || !height) return 1;
2935 double ar = (double)width / height;
2936 // square-ish pixels
2937 if( EQUIV(ar, 1.0000) ) return 0;
2938 if( EQUIV(ar, 1.3333) ) { w = 4; h = 3; return 0; }
2939 if( EQUIV(ar, 1.7777) ) { w = 16; h = 9; return 0; }
2940 if( EQUIV(ar, 2.1111) ) { w = 19; h = 9; return 0; }
2941 if( EQUIV(ar, 2.2222) ) { w = 20; h = 9; return 0; }
2942 if( EQUIV(ar, 2.3333) ) { w = 21; h = 9; return 0; }
2943 int ww = width, hh = height;
2944 // numerator, denominator must be under mx
2945 int mx = 255, n = gcd(ww, hh);
2946 if( n > 1 ) { ww /= n; hh /= n; }
2947 // search near height in case extra/missing lines
2948 if( ww >= mx || hh >= mx ) {
2949 double err = height; // +/- 2 percent height
2950 for( int m=2*height/100, i=1; m>0; i=i>0 ? -i : (--m, -i+1) ) {
2951 int iw = width, ih = height+i;
2952 if( (n=gcd(iw, ih)) > 1 ) {
2953 int u = iw/n; if( u >= mx ) continue;
2954 int v = ih/n; if( v >= mx ) continue;
2955 double r = (double) u/v, er = fabs(ar-r);
2956 if( er >= err ) continue;
2957 err = er; ww = u; hh = v;
2966 void MWindow::reset_caches()
2968 frame_cache->remove_all();
2969 wave_cache->remove_all();
2970 audio_cache->remove_all();
2971 video_cache->remove_all();
2972 if( cwindow->playback_engine && cwindow->playback_engine->audio_cache )
2973 cwindow->playback_engine->audio_cache->remove_all();
2974 if( cwindow->playback_engine && cwindow->playback_engine->video_cache )
2975 cwindow->playback_engine->video_cache->remove_all();
2977 for(int i = 0; i < vwindows.size(); i++) {
2978 VWindow *vwindow = vwindows[i];
2979 if( !vwindow->is_running() ) continue;
2980 if(vwindow->playback_engine && vwindow->playback_engine->audio_cache)
2981 vwindow->playback_engine->audio_cache->remove_all();
2982 if(vwindow->playback_engine && vwindow->playback_engine->video_cache)
2983 vwindow->playback_engine->video_cache->remove_all();
2987 void MWindow::remove_asset_from_caches(Asset *asset)
2989 gui->resource_thread->get_video_source(0);
2990 gui->resource_thread->get_audio_source(0);
2991 frame_cache->remove_asset(asset);
2992 wave_cache->remove_asset(asset);
2993 audio_cache->delete_entry(asset);
2994 video_cache->delete_entry(asset);
2995 if( cwindow->playback_engine && cwindow->playback_engine->audio_cache )
2996 cwindow->playback_engine->audio_cache->delete_entry(asset);
2997 if( cwindow->playback_engine && cwindow->playback_engine->video_cache )
2998 cwindow->playback_engine->video_cache->delete_entry(asset);
2999 for(int i = 0; i < vwindows.size(); i++) {
3000 VWindow *vwindow = vwindows[i];
3001 if( !vwindow->is_running() ) continue;
3002 if(vwindow->playback_engine && vwindow->playback_engine->audio_cache)
3003 vwindow->playback_engine->audio_cache->delete_entry(asset);
3004 if(vwindow->playback_engine && vwindow->playback_engine->video_cache)
3005 vwindow->playback_engine->video_cache->delete_entry(asset);
3010 void MWindow::remove_assets_from_project(int push_undo, int redraw,
3011 ArrayList<Indexable*> *drag_assets, ArrayList<EDL*> *drag_clips)
3013 for(int i = 0; i < session->drag_assets->total; i++) {
3014 Indexable *indexable = session->drag_assets->get(i);
3015 if(indexable->is_asset) remove_asset_from_caches((Asset*)indexable);
3018 // Remove from VWindow.
3019 for(int i = 0; i < session->drag_clips->total; i++) {
3020 for(int j = 0; j < vwindows.size(); j++) {
3021 VWindow *vwindow = vwindows[j];
3022 if( !vwindow->is_running() ) continue;
3023 if(session->drag_clips->get(i) == vwindow->get_edl()) {
3024 vwindow->gui->lock_window("MWindow::remove_assets_from_project 1");
3025 vwindow->delete_source(1, 1);
3026 vwindow->gui->unlock_window();
3031 for(int i = 0; i < session->drag_assets->size(); i++) {
3032 for(int j = 0; j < vwindows.size(); j++) {
3033 VWindow *vwindow = vwindows[j];
3034 if( !vwindow->is_running() ) continue;
3035 if(session->drag_assets->get(i) == vwindow->get_source()) {
3036 vwindow->gui->lock_window("MWindow::remove_assets_from_project 2");
3037 vwindow->delete_source(1, 1);
3038 vwindow->gui->unlock_window();
3043 for(int i = 0; i < session->drag_assets->size(); i++) {
3044 Indexable *indexable = session->drag_assets->get(i);
3045 remove_indexfile(indexable);
3048 //printf("MWindow::rebuild_indices 1 %s\n", indexable->path);
3049 if(push_undo) undo->update_undo_before();
3050 if(drag_assets) edl->remove_from_project(drag_assets);
3051 if(drag_clips) edl->remove_from_project(session->drag_clips);
3052 if(redraw) save_backup();
3053 if(push_undo) undo->update_undo_after(_("remove assets"), LOAD_ALL);
3058 gui->lock_window("MWindow::remove_assets_from_project 3");
3066 gui->unlock_window();
3068 // Removes from playback here
3069 sync_parameters(CHANGE_ALL);
3072 awindow->gui->async_update_assets();
3075 void MWindow::remove_assets_from_disk()
3078 for(int i = 0; i < session->drag_assets->total; i++)
3080 remove(session->drag_assets->get(i)->path);
3083 remove_assets_from_project(1,
3085 session->drag_assets,
3086 session->drag_clips);
3089 void MWindow::dump_plugins(FILE *fp)
3091 if( !plugindb ) return;
3092 for(int i = 0; i < plugindb->total; i++)
3094 fprintf(fp, "type=%d audio=%d video=%d rt=%d multi=%d"
3095 " synth=%d transition=%d theme=%d %s\n",
3096 plugindb->get(i)->plugin_type,
3097 plugindb->get(i)->audio,
3098 plugindb->get(i)->video,
3099 plugindb->get(i)->realtime,
3100 plugindb->get(i)->multichannel,
3101 plugindb->get(i)->get_synthesis(),
3102 plugindb->get(i)->transition,
3103 plugindb->get(i)->theme,
3104 plugindb->get(i)->title);
3108 void MWindow::dump_edl(FILE *fp)
3114 void MWindow::dump_undo(FILE *fp)
3120 void MWindow::dump_exe(FILE *fp)
3122 char proc_path[BCTEXTLEN], exe_path[BCTEXTLEN];
3123 sprintf(proc_path, "/proc/%d/exe", (int)getpid());
3124 int len = readlink(proc_path, exe_path, sizeof(exe_path));
3125 if( len < 0 ) { fprintf(fp,"readlink: %m\n"); return; }
3128 if( stat(exe_path,&st) ) { fprintf(fp,"stat: %m\n"); return; }
3129 fprintf(fp, "path: %s = %9jd bytes\n",exe_path,st.st_size);
3130 int fd = open(exe_path,O_RDONLY);
3131 if( fd < 0 ) { fprintf(fp,"open: %m\n"); return; }
3132 uint8_t buf[65536]; SHA1 sha1;
3133 while( (len=read(fd,buf,sizeof(buf))) > 0 ) {
3134 sha1.addBytes(buf, len);
3137 fprintf(fp, "SHA1: ");
3138 uint8_t digest[20]; sha1.computeHash(digest);
3139 for( int i=0; i<20; ++i ) fprintf(fp, "%02x", digest[i]);
3144 void MWindow::trap_hook(FILE *fp, void *vp)
3146 MWindow *mwindow = (MWindow *)vp;
3147 fprintf(fp, "\nEXE:\n");
3148 mwindow->dump_exe(fp);
3149 fprintf(fp, "\nPLUGINS:\n");
3150 mwindow->dump_plugins(fp);
3151 fprintf(fp, "\nEDL:\n");
3152 mwindow->dump_edl(fp);
3153 fprintf(fp, "\nUNDO:\n");
3154 mwindow->dump_undo(fp);
3162 int MWindow::save_defaults()
3164 gui->save_defaults(defaults);
3165 edl->save_defaults(defaults);
3166 session->save_defaults(defaults);
3167 preferences->save_defaults(defaults);
3169 for(int i = 0; i < plugin_guis->total; i++)
3171 // Pointer comparison
3172 plugin_guis->get(i)->save_defaults();
3174 awindow->save_defaults(defaults);
3180 int MWindow::run_script(FileXML *script)
3182 int result = 0, result2 = 0;
3183 while(!result && !result2)
3185 result = script->read_tag();
3188 if(script->tag.title_is("new_project"))
3190 // Run new in immediate mode.
3191 // gui->mainmenu->new_project->run_script(script);
3194 if(script->tag.title_is("record"))
3196 // Run record as a thread. It is a terminal command.
3198 // Will read the complete scipt file without letting record read it if not
3204 printf("MWindow::run_script: Unrecognized command: %s\n",script->tag.get_title() );
3211 // ================================= synchronization
3214 int MWindow::interrupt_indexes()
3216 mainindexes->interrupt_build();
3222 void MWindow::next_time_format()
3224 switch(edl->session->time_format)
3226 case TIME_HMS: edl->session->time_format = TIME_HMSF; break;
3227 case TIME_HMSF: edl->session->time_format = TIME_SAMPLES; break;
3228 case TIME_SAMPLES: edl->session->time_format = TIME_SAMPLES_HEX; break;
3229 case TIME_SAMPLES_HEX: edl->session->time_format = TIME_FRAMES; break;
3230 case TIME_FRAMES: edl->session->time_format = TIME_FEET_FRAMES; break;
3231 case TIME_FEET_FRAMES: edl->session->time_format = TIME_SECONDS; break;
3232 case TIME_SECONDS: edl->session->time_format = TIME_HMS; break;
3235 time_format_common();
3238 void MWindow::prev_time_format()
3240 switch(edl->session->time_format)
3242 case TIME_HMS: edl->session->time_format = TIME_SECONDS; break;
3243 case TIME_SECONDS: edl->session->time_format = TIME_FEET_FRAMES; break;
3244 case TIME_FEET_FRAMES: edl->session->time_format = TIME_FRAMES; break;
3245 case TIME_FRAMES: edl->session->time_format = TIME_SAMPLES_HEX; break;
3246 case TIME_SAMPLES_HEX: edl->session->time_format = TIME_SAMPLES; break;
3247 case TIME_SAMPLES: edl->session->time_format = TIME_HMSF; break;
3248 case TIME_HMSF: edl->session->time_format = TIME_HMS; break;
3251 time_format_common();
3254 void MWindow::time_format_common()
3256 gui->lock_window("MWindow::next_time_format");
3257 gui->redraw_time_dependancies();
3260 char string[BCTEXTLEN], string2[BCTEXTLEN];
3261 sprintf(string, _("Using %s"), Units::print_time_format(edl->session->time_format, string2));
3262 gui->show_message(string);
3264 gui->unlock_window();
3268 int MWindow::set_filename(const char *filename)
3270 if( filename != session->filename )
3271 strcpy(session->filename, filename);
3272 if( filename != edl->path )
3273 strcpy(edl->path, filename);
3277 if(filename[0] == 0)
3279 gui->set_title(PROGRAM_NAME);
3284 char string[BCTEXTLEN], string2[BCTEXTLEN];
3285 dir.extract_name(string, filename);
3286 sprintf(string2, PROGRAM_NAME ": %s", string);
3287 gui->set_title(string2);
3300 int MWindow::set_loop_boundaries()
3302 double start = edl->local_session->get_selectionstart();
3303 double end = edl->local_session->get_selectionend();
3311 if(edl->tracks->total_length())
3314 end = edl->tracks->total_length();
3321 if(edl->local_session->loop_playback && start != end)
3323 edl->local_session->loop_start = start;
3324 edl->local_session->loop_end = end;
3335 int MWindow::reset_meters()
3337 cwindow->gui->lock_window("MWindow::reset_meters 1");
3338 cwindow->gui->meters->reset_meters();
3339 cwindow->gui->unlock_window();
3341 for(int j = 0; j < vwindows.size(); j++) {
3342 VWindow *vwindow = vwindows[j];
3343 if( !vwindow->is_running() ) continue;
3344 vwindow->gui->lock_window("MWindow::reset_meters 2");
3345 vwindow->gui->meters->reset_meters();
3346 vwindow->gui->unlock_window();
3349 lwindow->gui->lock_window("MWindow::reset_meters 3");
3350 lwindow->gui->panel->reset_meters();
3351 lwindow->gui->unlock_window();
3353 gui->lock_window("MWindow::reset_meters 4");
3354 gui->reset_meters();
3355 gui->unlock_window();
3360 void MWindow::resync_guis()
3364 gui->lock_window("MWindow::resync_guis");
3365 gui->update(1, 1, 1, 1, 1, 1, 0);
3366 gui->unlock_window();
3368 cwindow->gui->lock_window("MWindow::resync_guis");
3369 cwindow->gui->resize_event(cwindow->gui->get_w(),
3370 cwindow->gui->get_h());
3371 int channels = edl->session->audio_channels;
3372 cwindow->gui->meters->set_meters(channels, 1);
3373 cwindow->gui->flush();
3374 cwindow->gui->unlock_window();
3376 for(int i = 0; i < vwindows.size(); i++) {
3377 VWindow *vwindow = vwindows[i];
3378 if( !vwindow->is_running() ) continue;
3379 vwindow->gui->lock_window("MWindow::resync_guis");
3380 vwindow->gui->resize_event(vwindow->gui->get_w(),
3381 vwindow->gui->get_h());
3382 vwindow->gui->meters->set_meters(channels, 1);
3383 vwindow->gui->flush();
3384 vwindow->gui->unlock_window();
3387 lwindow->gui->lock_window("MWindow::resync_guis");
3388 lwindow->gui->panel->set_meters(channels, 1);
3389 lwindow->gui->flush();
3390 lwindow->gui->unlock_window();
3393 if(((edl->session->output_w % 4) ||
3394 (edl->session->output_h % 4)) &&
3395 edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
3397 MainError::show_error(
3398 _("This project's dimensions are not multiples of 4 so\n"
3399 "it can't be rendered by OpenGL."));
3404 sync_parameters(CHANGE_ALL);
3407 int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tracks)
3409 File *file = new File;
3410 EDLSession *session = edl->session;
3411 double old_framerate = session->frame_rate;
3412 double old_samplerate = session->sample_rate;
3413 int result = file->open_file(preferences, asset, 1, 0);
3414 if( !result && delete_tracks > 0 )
3415 undo->update_undo_before();
3416 if( !result && asset->get_video_layers() > 0 ) {
3417 // try to get asset up to date, may fail
3418 file->select_video_stream(asset, vstream);
3419 // either way use what was/is there.
3420 double framerate = asset->get_frame_rate();
3421 int width = asset->get_w();
3422 int height = asset->get_h();
3423 // must be multiple of 4 for opengl
3424 width = (width+3) & ~3; height = (height+3) & ~3;
3425 int driver = session->playback_config->vconfig->driver;
3426 int color_model = file->get_best_colormodel(asset, driver);
3427 // color_model = BC_CModels::is_yuv(color_model) ?
3428 // BC_CModels::has_alpha(color_model) ? BC_YUVA8888 : BC_YUV888 :
3429 // BC_CModels::is_float(color_model) ?
3430 // BC_CModels::has_alpha(color_model) ? BC_RGBA_FLOAT : BC_RGB_FLOAT :
3431 // BC_CModels::has_alpha(color_model) ? BC_RGBA8888 : BC_RGB888;
3432 // have alpha for now
3433 color_model = BC_CModels::is_yuv(color_model) ? BC_YUVA8888 :
3434 BC_CModels::is_float(color_model) ? BC_RGBA_FLOAT : BC_RGBA8888;
3435 session->color_model = color_model;
3436 session->output_w = width;
3437 session->output_h = height;
3438 session->frame_rate = framerate;
3439 // not, asset->actual_width/actual_height
3440 asset->width = session->output_w;
3441 asset->height = session->output_h;
3442 asset->frame_rate = session->frame_rate;
3443 create_aspect_ratio(session->aspect_w, session->aspect_h,
3444 session->output_w, session->output_h);
3445 Track *track = edl->tracks->first;
3446 for( Track *next_track=0; track; track=next_track ) {
3447 next_track = track->next;
3448 if( track->data_type != TRACK_VIDEO ) continue;
3449 if( delete_tracks ) {
3450 Edit *edit = track->edits->first;
3451 for( Edit *next_edit=0; edit; edit=next_edit ) {
3452 next_edit = edit->next;
3453 if( edit->channel != vstream ||
3454 !edit->asset || !edit->asset->is_asset ||
3455 *asset != *edit->asset )
3459 if( track->edits->first ) {
3460 track->track_w = edl->session->output_w;
3461 track->track_h = edl->session->output_h;
3463 else if( delete_tracks )
3464 edl->tracks->delete_track(track);
3466 edl->resample(old_framerate, session->frame_rate, TRACK_VIDEO);
3468 if( !result && asset->channels > 0 ) {
3469 session->sample_rate = asset->get_sample_rate();
3470 int64_t channel_mask = 0;
3471 int astrm = file->get_audio_for_video(vstream, astream, channel_mask);
3472 if( astrm >= 0 ) file->select_audio_stream(asset, astrm);
3473 if( astrm < 0 || !channel_mask ) channel_mask = (1<<asset->channels)-1;
3475 for( uint64_t mask=channel_mask; mask!=0; mask>>=1 ) channels += mask & 1;
3476 if( channels > 6 ) channels = 6;
3477 session->audio_tracks = session->audio_channels = channels;
3478 switch( channels ) {
3480 session->achannel_positions[0] = 90;
3481 session->achannel_positions[1] = 150;
3482 session->achannel_positions[2] = 30;
3483 session->achannel_positions[3] = 210;
3484 session->achannel_positions[4] = 330;
3485 session->achannel_positions[5] = 270;
3488 session->achannel_positions[0] = 180;
3489 session->achannel_positions[1] = 0;
3492 remap_audio(MWindow::AUDIO_1_TO_1);
3494 if( delete_tracks ) {
3495 Track *track = edl->tracks->first;
3496 for( Track *next_track=0; track; track=next_track ) {
3497 next_track = track->next;
3498 if( track->data_type != TRACK_AUDIO ) continue;
3499 Edit *edit = track->edits->first;
3500 for( Edit *next_edit=0; edit; edit=next_edit ) {
3501 next_edit = edit->next;
3502 if( !((1<<edit->channel) & channel_mask) ||
3503 !edit->asset || !edit->asset->is_asset ||
3504 *asset != *edit->asset )
3507 if( !track->edits->first )
3508 edl->tracks->delete_track(track);
3512 edl->resample(old_samplerate, session->sample_rate, TRACK_AUDIO);
3515 if( !result && delete_tracks > 0 ) {
3517 undo->update_undo_after(_("select asset"), LOAD_ALL);
3523 int MWindow::select_asset(int vtrack, int delete_tracks)
3525 Track *track = edl->tracks->get(vtrack, TRACK_VIDEO);
3526 if( !track ) return 1;
3527 Edit *edit = track->edits->first;
3528 if( !edit ) return 1;
3529 Asset *asset = edit->asset;
3530 if( !asset || !asset->is_asset ) return 1;
3531 return select_asset(asset, edit->channel, -1, delete_tracks);
3534 void MWindow::dump_plugindb(FILE *fp)
3536 if( !plugindb ) return;
3537 for(int i = 0; i < plugindb->total; i++)
3538 plugindb->get(i)->dump(fp);