title color fader/tweaks, bg_color bcbitmap fix, inst.sh fix, lang fr pref tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / playbackengine.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef PLAYBACKENGINE_H
23 #define PLAYBACKENGINE_H
24
25 #include "arraylist.h"
26 #include "audiodevice.inc"
27 #include "cache.inc"
28 #include "canvas.inc"
29 #include "channeldb.inc"
30 #include "condition.inc"
31 #include "bchash.inc"
32 #include "edl.inc"
33 #include "mwindow.inc"
34 #include "maxchannels.h"
35 #include "mutex.inc"
36 #include "tracking.inc"
37 #include "preferences.inc"
38 #include "renderengine.inc"
39 #include "thread.h"
40 #include "bctimer.h"
41 #include "transportque.inc"
42
43 class PlaybackEngine : public Thread
44 {
45 public:
46         PlaybackEngine(MWindow *mwindow, Canvas *output);
47         virtual ~PlaybackEngine();
48
49         void create_objects();
50         virtual int create_render_engine();
51         void delete_render_engine();
52         void arm_render_engine();
53         void start_render_engine();
54         void wait_render_engine();
55         void create_cache();
56         void perform_change();
57         void sync_parameters(EDL *edl);
58 // Set wait_tracking for events that change the cursor location but
59 // be sure to unlock the windows
60         void interrupt_playback(int wait_tracking = 0);
61 // Get levels for tracking.  Return 0 if no audio.
62         int get_output_levels(double *levels, long position);
63         int get_module_levels(ArrayList<double> *module_levels, long position);
64 // The MWindow starts the playback cursor loop
65 // The other windows start a slider loop
66 // For pausing only the cursor is run
67         virtual void init_cursor(int active);
68         virtual void stop_cursor();
69         virtual int brender_available(long position);
70 // For normal playback tracking and the cursor are started
71         virtual void init_tracking();
72         virtual void stop_tracking();
73         virtual void init_meters();
74 // The playback cursor calls this to calculate the current tracking position
75         virtual double get_tracking_position();
76 // Reset the transport after completion
77         virtual void update_transport(int command, int paused);
78 // The render engines call this to update tracking variables in the playback engine.
79         void update_tracking(double position);
80 // Get the output channel table for the current device or 0 if none exists.
81         ChannelDB* get_channeldb();
82
83         void run();
84         void stop_playback(int wait);
85         void issue_command(EDL *edl, int command, int wait_tracking,
86                 int use_inout, int update_refresh, int toggle_audio, int loop_play);
87         void refresh_frame(int change_type, EDL *edl, int dir=1);
88
89 // Maintain caches through console changes
90         CICache *audio_cache, *video_cache;
91 // Maintain playback cursor on GUI
92         int tracking_active;
93 // Tracking variables updated by render engines
94         double tracking_position;
95 // Not accurate until the first update_tracking, at which time
96 // tracking_active is incremented to 2.
97         Timer tracking_timer;
98 // Lock access to tracking data
99         Mutex *tracking_lock;
100 // Lock access to renderengine between interrupt and deletion
101         Mutex *renderengine_lock;
102 // Block returns until tracking loop is finished
103         Condition *tracking_done;
104 // Pause the main loop for the PAUSE command
105         Condition *pause_lock;
106 // Wait until thread has started
107         Condition *start_lock;
108
109         MWindow *mwindow;
110         Canvas *output;
111 // Copy of main preferences
112         Preferences *preferences;
113 // Next command
114         TransportQue *que;
115 // Currently executing command
116         TransportCommand *command;
117 // Last command which affected transport
118         int last_command;
119         int done;
120         int do_cwindow;
121 // Render engine
122         RenderEngine *render_engine;
123
124 // Used by label commands to get current position
125         int is_playing_back;
126
127 // General purpose debugging register
128         int debug;
129 };
130
131
132
133
134
135 #endif