camera position fix, rework transportque locks again, camera drag tweaks, window...
[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 // 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 send_command(int command, EDL *edl, int wait_tracking, int use_inout);
85         void stop_playback(int wait);
86         void refresh_frame(int change_type, EDL *edl, int dir=1);
87
88 // Maintain caches through console changes
89         CICache *audio_cache, *video_cache;
90 // Maintain playback cursor on GUI
91         int tracking_active;
92 // Tracking variables updated by render engines
93         double tracking_position;
94 // Not accurate until the first update_tracking, at which time
95 // tracking_active is incremented to 2.
96         Timer tracking_timer;
97 // Lock access to tracking data
98         Mutex *tracking_lock;
99 // Lock access to renderengine between interrupt and deletion
100         Mutex *renderengine_lock;
101 // Block returns until tracking loop is finished
102         Condition *tracking_done;
103 // Pause the main loop for the PAUSE command
104         Condition *pause_lock;
105 // Wait until thread has started
106         Condition *start_lock;
107
108         MWindow *mwindow;
109         Canvas *output;
110 // Copy of main preferences
111         Preferences *preferences;
112
113         int transport_stop(int wait_tracking);
114         int transport_command(int command, int change_type=CHANGE_NONE,
115                         EDL *new_edl=0, int use_inout=0);
116
117         Condition *input_lock, *output_lock;
118 // active command, stop command
119         TransportCommand *command, *stop_command;
120 // next command under construction, last sent command
121         TransportCommand *next_command, *sent_command;
122
123 // Render engine
124         RenderEngine *render_engine;
125
126         int done;
127         int is_playing_back;
128
129 // General purpose debugging register
130         int debug;
131 };
132
133
134
135
136
137 #endif