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