vicon drawing segv fix, beeper consolidation, render_effect resize wdw fix, valgrind...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mwindow.h
1 /*
2  * CINELERRA
3  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
4  *
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.
9  *
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.
14  *
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
18  *
19  */
20
21 #ifndef MWINDOW_H
22 #define MWINDOW_H
23
24 #include <stdio.h>
25 #include <stdint.h>
26
27 #include "apatchgui.h"
28 #include "arraylist.h"
29 #include "asset.inc"
30 #include "assets.inc"
31 #include "audiodevice.inc"
32 #include "autos.inc"
33 #include "awindow.inc"
34 #include "batchrender.inc"
35 #include "bcwindowbase.inc"
36 #include "bdcreate.inc"
37 #include "brender.inc"
38 #include "cache.inc"
39 #include "channel.inc"
40 #include "channeldb.inc"
41 #include "commercials.inc"
42 #include "convert.inc"
43 #include "cwindow.inc"
44 #include "bchash.inc"
45 #include "devicedvbinput.inc"
46 #include "devicempeginput.inc"
47 #include "dvdcreate.inc"
48 #include "edit.inc"
49 #include "edl.inc"
50 #include "edlsession.inc"
51 #include "exportedl.inc"
52 #include "filesystem.inc"
53 #include "filexml.inc"
54 #include "framecache.inc"
55 #include "gwindow.inc"
56 #include "indexable.inc"
57 #include "keyframegui.inc"
58 #include "levelwindow.inc"
59 #include "loadmode.inc"
60 #include "mainerror.inc"
61 #include "mainindexes.inc"
62 #include "mainprogress.inc"
63 #include "mainsession.inc"
64 #include "mainundo.inc"
65 #include "maxchannels.h"
66 #include "mixersalign.inc"
67 #include "mutex.inc"
68 #include "mwindow.inc"
69 #include "mwindowgui.inc"
70 #include "new.inc"
71 #include "patchbay.inc"
72 #include "playback3d.inc"
73 #include "playbackengine.inc"
74 #include "plugin.inc"
75 #include "pluginclient.inc"
76 #include "pluginfclient.inc"
77 #include "pluginserver.inc"
78 #include "pluginset.inc"
79 #include "preferences.inc"
80 #include "preferencesthread.inc"
81 #include "proxy.inc"
82 #include "record.inc"
83 #include "recordlabel.inc"
84 #include "render.inc"
85 #include "sharedlocation.inc"
86 #include "sighandler.inc"
87 #include "splashgui.inc"
88 #include "shuttle.inc"
89 #include "theme.inc"
90 #include "thread.h"
91 #include "threadloader.inc"
92 #include "timebar.inc"
93 #include "tipwindow.inc"
94 #include "track.inc"
95 #include "tracking.inc"
96 #include "tracks.inc"
97 #include "transition.inc"
98 #include "transportque.inc"
99 #include "videowindow.inc"
100 #include "vpatchgui.h"
101 #include "vwindow.inc"
102 #include "zwindow.inc"
103 #include "wwindow.inc"
104 #include "wavecache.inc"
105
106 #define FONT_SEARCHPATH "fonts"
107
108 class StackItem
109 {
110 public:
111         EDL *edl, *new_edl;
112         MainUndo *undo;
113 };
114
115 class Stack : public ArrayList<StackItem>
116 {
117 public:
118 };
119
120
121 #define BEEP_SAMPLE_RATE 48000
122
123 class Beeper : public Thread
124 {
125 public:
126         typedef int16_t audio_data_t;
127         Beeper(MWindow *mwindow);
128         ~Beeper();
129
130         void run();
131         void start();
132         void stop(int wait);
133         void tone(double freq, double secs, double gain);
134
135         MWindow *mwindow;
136         double freq, secs, gain;
137         AudioDevice *audio;
138         int playing_audio, interrupted;
139         int audio_pos;
140 };
141
142
143 class MWindow : public Thread
144 {
145 public:
146         MWindow();
147         ~MWindow();
148
149 // ======================================== initialization commands
150         void create_objects(int want_gui,
151                 int want_new,
152                 char *config_path);
153         int uses_opengl();
154         void show_splash();
155         void hide_splash();
156         void start();
157         void run();
158
159         int run_script(FileXML *script);
160         int new_project();
161         int delete_project(int flash = 1);
162         void quit();
163         int restart() { return restart_status; }
164
165         int load_defaults();
166         int save_defaults();
167         int set_filename(const char *filename);
168 // Total vertical pixels in timeline
169         int get_tracks_height();
170 // Total horizontal pixels in timeline
171         int get_tracks_width();
172 // session stack
173         void stack_push(EDL *edl);
174         void stack_pop();
175         void forget_nested_edl(EDL *nested);
176         void clip_to_media();
177         void media_to_clip();
178 // Show windows
179         void show_vwindow();
180         void show_awindow();
181         void show_lwindow();
182         void show_cwindow();
183         void show_gwindow();
184         void hide_gwindow();
185         void restore_windows();
186         void load_layout(const char *layout);
187         void save_layout(const char *layout);
188         void delete_layout(const char *layout);
189         int tile_windows(int window_config);
190         char *get_cwindow_display();
191         void set_screens(int value);
192         int asset_to_edl(EDL *new_edl,
193                 Asset *new_asset,
194                 RecordLabels *labels = 0);
195
196 // Entry point to insert assets and insert edls.  Called by TrackCanvas
197 // and AssetPopup when assets are dragged in from AWindow.
198 // Takes the drag vectors from MainSession and
199 // pastes either assets or clips depending on which is full.
200 // Returns 1 if the vectors were full
201         int paste_assets(double position, Track *dest_track, int overwrite);
202
203 // Insert the assets at a point in the EDL.  Called by menueffects,
204 // render, and CWindow drop but recording calls paste_edls directly for
205 // labels.
206         void load_assets(ArrayList<Indexable*> *new_assets,
207                 double position,
208                 int load_mode,
209                 Track *first_track /* = 0 */,
210                 RecordLabels *labels /* = 0 */,
211                 int edit_labels,
212                 int edit_plugins,
213                 int edit_autos,
214                 int overwrite);
215         int paste_edls(ArrayList<EDL*> *new_edls,
216                 int load_mode,
217                 Track *first_track /* = 0 */,
218                 double current_position /* = -1 */,
219                 int edit_labels,
220                 int edit_plugins,
221                 int edit_autos,
222                 int overwrite);
223 // Reset everything for a load
224         void update_project(int load_mode);
225         void update_preferences(Preferences *prefs);
226         void update_vwindow();
227 // Fit selected time to horizontal display range
228         void fit_selection();
229 // Fit selected autos to the vertical display range
230         void fit_autos(int all);
231         void change_currentautorange(int autogrouptype, int increment, int changemax);
232         void expand_autos(int changeall, int domin, int domax);
233         void shrink_autos(int changeall, int domin, int domax);
234 // move the window to include the cursor
235         void find_cursor();
236 // Search plugindb and put results in argument
237         static void search_plugindb(int do_audio,
238                 int do_video,
239                 int is_realtime,
240                 int is_transition,
241                 int is_theme,
242                 ArrayList<PluginServer*> &results);
243 // Find the plugin whose title matches title and return it
244         static PluginServer* scan_plugindb(char *title,
245                 int data_type);
246         static void fix_plugin_title(char *title);
247         static int plugin_exists(const char *plugin_path, ArrayList<PluginServer*> &plugins);
248         static int plugin_exists(char *plugin_path);
249         void dump_plugindb(FILE *fp);
250         void stop_playback(int wait);
251         void stop_transport();
252         void undo_before(const char *description = "", void *creator = 0);
253         void undo_after(const char *description, uint32_t load_flags, int changes_made = 1);
254
255         void handle_mixers(EDL *edl, int command, int wait_tracking,
256                 int use_inout, int toggle_audio, int loop_play, float speed);
257         ZWindow *create_mixer(Indexable *indexable, double position);
258         void create_mixers(double position = 0);
259         void refresh_mixers(int dir=1);
260         void stop_mixers();
261         void close_mixers(int result=1);
262         void open_mixers();
263         ZWindow *get_mixer(Mixer *&mixer);
264         void del_mixer(ZWindow *zwindow);
265         int mixer_track_active(Track *track);
266         void update_mixer_tracks();
267         void start_mixer();
268         int select_zwindow(ZWindow *zwindow);
269         void tile_mixers();
270         int load_filenames(ArrayList<char*> *filenames,
271                 int load_mode = LOADMODE_REPLACE,
272 // Cause the project filename on the top of the window to be updated.
273 // Not wanted for loading backups.
274                 int update_filename = 1);
275
276 // Print out plugins which are referenced in the EDL but not loaded.
277         void test_plugins(EDL *new_edl, char *path);
278
279         int interrupt_indexes();  // Stop index building
280
281         int redraw_time_dependancies();     // after reconfiguring the time format, sample rate, frame rate
282
283 // =========================================== movement
284
285         void next_time_format();
286         void prev_time_format();
287         void time_format_common();
288         int reposition_timebar(int new_pixel, int new_height);
289         int expand_sample();
290         int zoom_in_sample();
291         int zoom_sample(int64_t zoom_sample);
292         void zoom_autos(float min, float max);
293         void zoom_amp(int64_t zoom_amp);
294         void zoom_track(int64_t zoom_track);
295         int fit_sample();
296         int move_left(int64_t distance = 0);
297         int move_right(int64_t distance = 0);
298         void move_up(int64_t distance = 0);
299         void move_down(int64_t distance = 0);
300         int find_selection(double position, int scroll_display = 0);
301         void toggle_camera_xyz();
302         void toggle_projector_xyz();
303         double get_position();
304         void set_position(double position);
305
306 // seek to labels
307 // shift_down must be passed by the caller because different windows call
308 // into this
309         int next_label(int shift_down);
310         int prev_label(int shift_down);
311 // seek to edit handles
312         int next_edit_handle(int shift_down);
313         int prev_edit_handle(int shift_down);
314 // seek to keyframes
315         int nearest_plugin_keyframe(int shift_down, int dir);
316 // offset is pixels to add to track_start
317         void trackmovement(int offset, int pane_number);
318 // view_start is pixels
319         int samplemovement(int64_t view_start, int pane_number);
320         void select_all();
321         int goto_start();
322         int goto_end();
323         int goto_position(double position);
324         int expand_y();
325         int zoom_in_y();
326         int expand_t();
327         int zoom_in_t();
328         void split_x();
329         void split_y();
330         void crop_video(int mode);
331         void update_plugins();
332         void get_backup_path(char *path, int len);
333 // Call after every edit operation
334         void save_backup();
335         void load_backup();
336         void show_plugin(Plugin *plugin);
337         void hide_plugin(Plugin *plugin, int lock);
338         void hide_plugins();
339         void delete_plugin(PluginServer *plugin);
340 // Update plugins with configuration changes.
341 // Called by TrackCanvas::cursor_motion_event.
342         void update_plugin_guis(int do_keyframe_guis = 1);
343         void update_plugin_states();
344         void update_plugin_titles();
345 // Called by Attachmentpoint during playback.
346 // Searches for matching plugin and renders data in it.
347         void render_plugin_gui(void *data, Plugin *plugin);
348         void render_plugin_gui(void *data, int size, Plugin *plugin);
349         void reset_plugin_gui_frames(Plugin *plugin);
350         void render_plugin_gui_frames(PluginClientFrames *frames, Plugin *plugin);
351         double get_tracking_position();
352         int get_tracking_direction();
353
354 // Called from PluginVClient::process_buffer
355 // Returns 1 if a GUI for the plugin is open so OpenGL routines can determine if
356 // they can run.
357         int plugin_gui_open(Plugin *plugin);
358         void stop_plugin_guis();
359
360         void show_keyframe_gui(Plugin *plugin);
361         void hide_keyframe_guis();
362         void hide_keyframe_gui(Plugin *plugin);
363         void update_keyframe_guis();
364         int get_hash_color(Edit *edit);
365         int get_hash_color(int v);
366         int get_group_color(int v);
367         int get_title_color(Edit *edit);
368
369 // ============================= editing commands ========================
370
371 // Map each recordable audio track to the desired pattern
372         void map_audio(int pattern);
373         void remap_audio(int pattern);
374         enum
375         {
376                 AUDIO_5_1_TO_2,
377                 AUDIO_1_TO_1
378         };
379         void add_audio_track_entry(int above, Track *dst);
380         int add_audio_track(int above, Track *dst);
381         void add_clip_to_edl(EDL *edl);
382         void add_video_track_entry(Track *dst = 0);
383         int add_video_track(int above, Track *dst);
384         void add_subttl_track_entry(Track *dst = 0);
385         int add_subttl_track(int above, Track *dst);
386
387         void asset_to_all();
388         void asset_to_size();
389         void asset_to_rate();
390 // Entry point for clear operations.
391         void clear_entry();
392 // Clears active region in EDL.
393 // If clear_handle, edit boundaries are cleared if the range is 0.
394 // Called by paste, record, menueffects, render, and CWindow drop.
395         void clear(int clear_handle);
396         void clear_labels();
397         int clear_labels(double start, double end);
398         void clear_hard_edges();
399         int clear_hard_edges(double start, double end);
400         void clear_select();
401         void concatenate_tracks();
402         int copy_flags(int copy_flags=COPY_CLIPBOARD);
403         void copy();
404         int copy(double start, double end);
405         void cut();
406         void blade(double position);
407         void cut(double start, double end, double new_position=-1);
408 // cut edit from current position to handle/label
409         void cut_left_edit();
410         void cut_right_edit();
411         void cut_left_label();
412         void cut_right_label();
413
414 // Calculate aspect ratio from pixel counts
415         static int create_aspect_ratio(float &w, float &h, int width, int height);
416 // Calculate defaults path
417         static void create_defaults_path(char *string, const char *config_file);
418
419         void delete_track(Track *track);
420         void delete_tracks();
421         int feather_edits(int64_t feather_samples, int audio, int video);
422         int64_t get_feather(int audio, int video);
423         float get_aspect_ratio();
424         void insert(double position, FileXML *file,
425                 int edit_labels, int edit_plugins, int edit_autos,
426                 EDL *parent_edl, Track *first_track, int overwrite);
427
428 // TrackCanvas calls this to insert multiple effects from the drag_pluginservers
429 // into pluginset_highlighted.
430         void insert_effects_canvas(double start, double length);
431
432 // CWindow calls this to insert multiple effects from
433 // the drag_pluginservers array.
434         void insert_effects_cwindow(Track *dest_track);
435
436 // Attach new effect to all recordable tracks
437 // single_standalone - attach 1 standalone on the first track and share it with
438 // other tracks
439         void insert_effect(char *title,
440                 SharedLocation *shared_location,
441                 int data_type, int plugin_type, int single_standalone);
442
443 // This is called multiple times by the above functions.
444 // It can't sync parameters.
445         void insert_effect(char *title,
446                 SharedLocation *shared_location,
447                 Track *track, PluginSet *plugin_set,
448                 double start, double length, int plugin_type);
449
450         void match_output_size(Track *track);
451         void delete_edit(Edit *edit, const char *msg, int collapse=0);
452         void delete_edits(ArrayList<Edit*> *edits, const char *msg, int collapse=0);
453         void delete_edits(int collapse=0);
454         void cut_selected_edits(int collapse, int packed);
455 // Move edit to new position
456         void move_edits(ArrayList<Edit*> *edits, Track *track, double position,
457                 int mode); // mode: 0 - mute and overwrite,  1 - cut and paste
458         void selected_edits_to_clipboard(int packed);
459         void paste_clipboard(Track *first_track, double position, int overwrite,
460                 int edit_edits, int edit_labels, int edit_autos, int edit_plugins);
461         void move_group(EDL *group, Track *first_track, double position, int overwrite);
462 // Move effect to position
463         void move_effect(Plugin *plugin, Track *track, int64_t position);
464         void move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position);
465         void move_plugins_up(PluginSet *plugin_set);
466         void move_plugins_down(PluginSet *plugin_set);
467         void move_track_down(Track *track);
468         void move_tracks_down();
469         void move_track_up(Track *track);
470         void move_tracks_up();
471         void mute_selection();
472         void new_folder(const char *new_folder, int is_clips);
473         void delete_folder(char *folder);
474 // For clipboard commands
475         void paste();
476         void paste(double start, Track *first_track, int clear_selection, int overwrite);
477 // For splice and overwrite
478         void overwrite(EDL *source, int all);
479         void splice(EDL *source, int all);
480         int paste(double start, double end, FileXML *file,
481                 int edit_labels, int edit_plugins, int edit_autos,
482                 Track *first_track, int overwrite);
483         int paste_output(int64_t startproject, int64_t endproject,
484                 int64_t startsource_sample, int64_t endsource_sample,
485                 int64_t startsource_frame, int64_t endsource_frame,
486                 Asset *asset, RecordLabels *new_labels);
487         void paste_silence();
488
489 // Detach single transition
490         void detach_transition(Transition *transition);
491 // Detach all transitions in selection
492         void detach_transitions();
493 // Attach dragged transition
494         void paste_transition();
495 // Attach transition to all edits in selection
496         void paste_transitions(int track_type, char *title);
497 // Attach transition dragged onto CWindow
498         void paste_transition_cwindow(Track *dest_track);
499 // Attach default transition to single edit
500         void paste_audio_transition();
501         void paste_video_transition();
502         void shuffle_edits();
503         void reverse_edits();
504         void align_edits();
505         void set_edit_length(double length);
506 // Set length of single transition
507         void set_transition_length(Transition *transition, double length);
508 // Set length in seconds of all transitions in active range
509         void set_transition_length(double length);
510
511         void remove_indexfile(Indexable *indexable);
512         void rebuild_indices();
513 // Asset removal from caches
514         void reset_caches();
515         void remove_asset_from_caches(Asset *asset);
516         void remove_assets_from_project(int push_undo, int redraw, int delete_indexes,
517                 ArrayList<Indexable*> *drag_assets /* mwindow->session->drag_assets */,
518                 ArrayList<EDL*> *drag_clips /* mwindow->session->drag_clips */);
519         void remove_assets_from_disk();
520         void resize_track(Track *track, int w, int h);
521
522         void set_automation_mode(int mode);
523         void set_keyframe_type(int mode);
524         void set_auto_keyframes(int value);
525         void set_span_keyframes(int value);
526         void set_auto_visibility(Autos *autos, int value);
527         void set_labels_follow_edits(int value);
528
529 // Update the editing mode
530         int set_editing_mode(int new_editing_mode);
531         void toggle_editing_mode();
532         void set_inpoint();
533         void set_outpoint();
534         void unset_inoutpoint();
535         void toggle_loop_playback();
536         void trim_selection();
537 // Synchronize EDL settings with all playback engines depending on current
538 // operation.  Doesn't redraw anything.
539         void sync_parameters(int change_type = CHANGE_PARAMS);
540         void save_clip(EDL *new_edl, const char *txt);
541         void to_clip(EDL *edl, const char *txt, int all);
542         int toggle_label();
543         void undo_entry(BC_WindowBase *calling_window_gui);
544         void redo_entry(BC_WindowBase *calling_window_gui);
545         void save_undo_data();
546         void load_undo_data();
547         int copy_target(const char *path, const char *target);
548         int link_target(const char *real_path, const char *link_path, int relative);
549         void save_project(const char *dir, int save_mode, int overwrite, int reload);
550
551         int cut_automation();
552         int copy_automation();
553         int paste_automation();
554         void clear_automation();
555         int cut_default_keyframe();
556         int copy_default_keyframe();
557 // Use paste_automation to paste the default keyframe in other position.
558 // Use paste_default_keyframe to replace the default keyframe with whatever is
559 // in the clipboard.
560         int paste_default_keyframe();
561         int clear_default_keyframe();
562
563         FloatAuto* get_float_auto(PatchGUI *patch,int idx);
564         IntAuto* get_int_auto(PatchGUI *patch,int idx);
565         PanAuto* get_pan_auto(PatchGUI *patch);
566         PatchGUI *get_patchgui(Track *track);
567
568         int modify_edithandles();
569         int modify_pluginhandles();
570         void finish_modify_handles();
571         void rescale_proxy(EDL *clip, int orig_scale, int new_scale);
572         void add_proxy(ArrayList<Indexable*> *orig_assets,
573                         ArrayList<Indexable*> *proxy_assets);
574         int render_proxy(ArrayList<Indexable *> &new_idxbls);
575         void beep(double freq, double secs, double gain);
576         int enable_proxy();
577         int disable_proxy();
578         int to_proxy(Asset *asset, int new_scale, int new_use_scaler);
579         Beeper *beeper;
580
581         void dump_plugins(FILE *fp=stdout);
582         void dump_edl(FILE *fp=stdout);
583         void dump_undo(FILE *fp=stdout);
584         void dump_exe(FILE *fp=stdout);
585         static void trap_hook(FILE *fp, void *vp);
586
587         void reset_android_remote();
588
589 // Send new EDL to caches
590         void age_caches();
591         int optimize_assets();            // delete unused assets from the cache and assets
592 // render edl assets to specified format, then replace in edl
593         void start_convert(Asset *format_asset, const char *suffix,
594                         float beep, int remove_originals);
595         void finish_convert(int remove_originals);
596         ConvertRender *convert_render;
597
598         void select_point(double position);
599         int set_loop_boundaries();         // toggle loop playback and set boundaries for loop playback
600
601
602         Playback3D *playback_3d;
603         SplashGUI *splash_window;
604
605 // Main undo stack
606         MainUndo *undo;
607         int undo_command;
608 // session stack
609         Stack stack;
610
611         BC_Hash *defaults;
612         Assets *assets;
613 // CICaches for drawing timeline only
614         CICache *audio_cache, *video_cache;
615 // Frame cache for drawing timeline only.
616 // Cache drawing doesn't wait for file decoding.
617         FrameCache *frame_cache;
618         WaveCache *wave_cache;
619         Preferences *preferences;
620         PreferencesThread *preferences_thread;
621         MainSession *session;
622         Theme *theme;
623         MainIndexes *mainindexes;
624         MainProgress *mainprogress;
625         BRender *brender;
626         char cin_lang[4];
627         int brender_active;
628         const char *default_standard;
629         static Commercials *commercials;
630         int commercial_active;
631         int has_commercials();
632 // copy of edl created in speed_before, used in speed_after to normalize_speed
633         EDL *speed_edl;
634
635 // Menu items
636         ArrayList<ColormodelItem*> colormodels;
637         ArrayList<InterlacemodeItem*>          interlace_project_modes;
638         ArrayList<InterlacemodeItem*>          interlace_asset_modes;
639
640         int reset_meters();
641         void resync_guis();
642
643         int select_asset(Asset *asset, int vstream, int astream, int delete_tracks);
644         int select_asset(int vtrack, int delete_tracks);
645
646 // Channel DB for playback only.  Record channel DB's are in record.C
647         ChannelDB *channeldb_buz;
648         ChannelDB *channeldb_v4l2jpeg;
649
650 // ====================================== plugins ==============================
651
652 // Contains file descriptors for all the dlopens
653         static ArrayList<PluginServer*> *plugindb;
654 // Currently visible plugins
655         int64_t plugin_visibility;
656         PluginGUIs *plugin_guis;
657 // GUI Plugins to delete
658         ArrayList<PluginServer*> *dead_plugins;
659 // Keyframe editors
660         ArrayList<KeyFrameThread*> *keyframe_threads;
661
662 // Adjust sample position to line up with frames.
663         int fix_timing(int64_t &samples_out,
664                 int64_t &frames_out,
665                 int64_t samples_in);
666
667
668         CreateBD_Thread *create_bd;
669         CreateDVD_Thread *create_dvd;
670         BatchRenderThread *batch_render;
671         Render *render;
672
673         ExportEDL *exportedl;
674
675
676 // Master edl
677         EDL *edl;
678 // Main Window GUI
679         MWindowGUI *gui;
680 // Compositor
681         CWindow *cwindow;
682 // Viewer
683         Mutex *vwindows_lock;
684         ArrayList<VWindow*> vwindows;
685 // Mixer
686         Mutex *zwindows_lock;
687         ArrayList<ZWindow*> zwindows;
688         MixersAlign *mixers_align;
689
690 // Asset manager
691         AWindow *awindow;
692 // Automation window
693         GWindow *gwindow;
694 // Tip of the day
695         TipWindow *twindow;
696 // Warning window
697         WWindow *wwindow;
698         void show_warning(int *do_warning, const char *text);
699         int wait_warning();
700 // Levels
701         LevelWindow *lwindow;
702         Mutex *run_lock;
703 // Lock during creation and destruction of GUI
704         Mutex *plugin_gui_lock;
705         Mutex *dead_plugin_lock;
706         Mutex *keyframe_gui_lock;
707 // Lock during creation and destruction of brender so playback doesn't use it.
708         Mutex *brender_lock;
709 // Initialize shared memory
710         void init_shm(const char *pfn, int64_t min);
711 // Initialize channel DB's for playback
712         void init_channeldb();
713         void init_render();
714         void init_exportedl();
715 // These three happen synchronously with each other
716 // Make sure this is called after synchronizing EDL's.
717         void init_brender();
718 // Restart brender after testing its existence
719         void restart_brender();
720 // Stops brender after testing its existence
721         void stop_brender();
722 // This one happens asynchronously of the others.  Used by playback to
723 // see what frame is background rendered.
724         int brender_available(int position);
725         void set_brender_active(int v, int update=1);
726         int put_commercial();
727         void activate_commercial() { commercial_active = 1; }
728         void commit_commercial();
729         void undo_commercial();
730         void cut_commercials();
731         void update_gui(int changed_edl);
732         int paste_subtitle_text(char *text, double start, double end);
733
734         void init_error();
735         void finit_error();
736         static void init_defaults(BC_Hash* &defaults, char *config_path);
737         void check_language();
738         const char *default_std();
739         void fill_preset_defaults(const char *preset, EDLSession *session);
740         const char *get_preset_name(int index);
741         void init_edl();
742         void init_awindow();
743         void init_gwindow();
744         void init_tipwindow();
745 // Used by MWindow and RenderFarmClient
746         static void get_plugin_path(char *path, const char *plug_dir, const char *fs_path);
747         static int init_plugins(MWindow *mwindow, Preferences *preferences);
748         static int init_ladspa_plugins(MWindow *mwindow, Preferences *preferences);
749         static void init_plugin_tips(ArrayList<PluginServer*> &plugins, const char *lang);
750         static int check_plugin_index(ArrayList<PluginServer*> &plugins,
751                 const char *plug_dir, const char *plug_path);
752         static void init_plugin_index(MWindow *mwindow, Preferences *preferences,
753                 FILE *fp, const char *plugin_dir);
754         static int init_ladspa_index(MWindow *mwindow, Preferences *preferences,
755                 FILE *fp, const char *plugin_dir);
756         static void scan_plugin_index(MWindow *mwindow, Preferences *preferences,
757                 FILE *fp, const char *plug_dir, const char *plug_path, int &idx);
758         static void init_ffmpeg();
759         static void init_ffmpeg_index(MWindow *mwindow, Preferences *preferences, FILE *fp);
760         static int load_plugin_index(MWindow *mwindow, FILE *fp, const char *plugin_dir);
761         static PluginServer *new_ffmpeg_server(MWindow *mwindow, const char *name);
762         static int init_lv2_index(MWindow *mwindow, Preferences *preferences, FILE *fp);
763         static PluginServer *new_lv2_server(MWindow *mwindow, const char *name);
764         static void remove_plugin_index();
765
766         void init_preferences();
767         void init_signals();
768         void init_shuttle();
769         void init_theme();
770         void init_compositor();
771         void init_levelwindow();
772 // Called when creating a new viewer to view footage
773         VWindow* get_viewer(int start_it, int idx=-1);
774         void init_cache();
775         void init_menus();
776         void init_indexes();
777         void init_gui();
778         void init_3d();
779         void init_playbackcursor();
780         void init_commercials();
781         static void add_plugins(ArrayList<PluginServer*> &plugins);
782         static void delete_plugins();
783         void speed_before();
784         int speed_after(int done);
785         int normalize_speed(EDL *old_edl, EDL *new_edl);
786 //
787         void clean_indexes();
788 //      TimeBomb timebomb;
789         SigHandler *sighandler;
790         int restart_status;
791         int screens;
792         int in_destructor;
793         Shuttle *shuttle;
794 };
795
796 #endif