mask mousewheel segv bug, mask opengl sw fallback read to ram, fix tiff config withou...
[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.h"
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         void clear_output();
59 // Set wait_tracking for events that change the cursor location but
60 // be sure to unlock the windows
61         void interrupt_playback(int wait_tracking = 0);
62 // Get levels for tracking.  Return 0 if no audio.
63         int get_output_levels(double *levels, long position);
64         int get_module_levels(ArrayList<double> *module_levels, long position);
65 // The MWindow starts the playback cursor loop
66 // The other windows start a slider loop
67 // For pausing only the cursor is run
68         virtual void init_cursor(int active);
69         virtual void stop_cursor();
70         virtual int brender_available(long position);
71 // For normal playback tracking and the cursor are started
72         virtual void init_tracking();
73         virtual void stop_tracking();
74         virtual void init_meters();
75 // The playback cursor calls this to calculate the current tracking position
76         virtual double get_tracking_position();
77 // Reset the transport after completion
78         virtual void update_transport(int command, int paused);
79 // The render engines call this to update tracking variables in the playback engine.
80         void update_tracking(double position);
81 // Get the output channel table for the current device or 0 if none exists.
82         ChannelDB* get_channeldb();
83
84         void run();
85         void send_command(int command, EDL *edl, int wait_tracking, int use_inout);
86         void stop_playback(int wait);
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
114         int put_command(TransportCommand *command, int reset);
115         int transport_stop(int wait_tracking);
116         int transport_command(int command, int change_type=CHANGE_NONE,
117                         EDL *new_edl=0, int use_inout=0);
118
119         Condition *input_lock, *output_lock;
120 // active command, stop command
121         TransportCommand *command, *stop_command;
122 // next command under construction, last sent command
123         TransportCommand *next_command, *sent_command;
124
125 // Render engine
126         RenderEngine *render_engine;
127
128         int done;
129         int is_playing_back;
130         int send_active;
131
132 // General purpose debugging register
133         int debug;
134 };
135
136
137
138
139
140 #endif