4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #ifndef RENDERENGINE_H
23 #define RENDERENGINE_H
28 #include "arender.inc"
29 #include "audiodevice.inc"
32 #include "channel.inc"
33 #include "channeldb.inc"
34 #include "condition.inc"
36 #include "mwindow.inc"
37 #include "playbackengine.inc"
38 #include "pluginserver.inc"
39 #include "preferences.inc"
41 #include "transportque.inc"
42 #include "videodevice.inc"
43 #include "vrender.inc"
45 class RenderEngine : public Thread
48 RenderEngine(PlaybackEngine *playback_engine,
49 Preferences *preferences,
55 void create_render_threads();
56 void arm_render_threads();
57 void start_render_threads();
58 void wait_render_threads();
59 void interrupt_playback();
62 int brender_available(int position, int direction);
63 double get_tracking_position();
64 CICache* get_acache();
65 CICache* get_vcache();
66 void set_acache(CICache *cache);
67 void set_vcache(CICache *cache);
68 // Get levels for tracking
69 void get_output_levels(double *levels, int64_t position);
70 void get_module_levels(ArrayList<double> *module_levels, int64_t position);
74 // Sends the command sequence, compensating for network latency
75 int arm_command(TransportCommand *command);
81 // return position to synchronize video against
82 int64_t sync_position();
83 // Called by VRender to reset the timers once the first frame is done.
84 void reset_sync_position();
85 // return samples since start of playback
86 int64_t session_position();
88 // Update preferences window
89 void update_framerate(float framerate);
92 TransportCommand *command;
93 // Pointer to playback config for one head
94 PlaybackConfig *config;
95 // Defined only for the master render engine
96 PlaybackEngine *playback_engine;
97 // Copy of preferences
98 Preferences *preferences;
99 // Canvas if being used for CWindow
103 // Lock out new commands until completion
104 Condition *input_lock;
105 // Lock out interrupts until started
106 Condition *start_lock;
107 Condition *output_lock;
108 // Lock out audio and synchronization timers until first frame is done
109 Condition *first_frame_lock;
110 // Lock out interrupts before and after renderengine is active
111 Mutex *interrupt_lock;
113 // Show the timecode on the video
118 // If nested, the devices are owned by someone else
125 // Timer for synchronization without audio
127 // If the termination came from interrupt or end of selection
130 // Samples in audio buffer to process
131 int64_t fragment_len;
132 // Samples to send to audio device after speed adjustment
133 int64_t adjusted_fragment_len;
134 // CICaches for use if no playbackengine exists
135 CICache *audio_cache, *video_cache;
138 // constructing with an audio device forces output buffer allocation
139 // constructing without an audio device puts in one buffer at a time mode
140 RenderEngine(MWindow *mwindow,
141 AudioDevice *audio = 0,
142 VideoDevice *video = 0,
143 PlaybackEngine *playbackengine = 0);
145 void reset_parameters();
147 // buffersize is in samples
148 void arm_playback_audio(int64_t input_length,
149 int64_t amodule_render_fragment,
150 int64_t playback_buffer,
151 int64_t output_length);
153 void arm_playback_video(int every_frame,
155 int64_t output_length,
161 // start video since vrender is the master
165 // information for playback
166 int follow_loop; // loop if mwindow is looped
167 int infinite; // don't stop rendering at the end of the range or loops
169 int64_t start_position; // lowest numbered sample in playback range
170 int64_t end_position; // highest numbered sample in playback range
171 int64_t current_sample;
173 // This is created in the first arm_command and not changed until deletion.
174 // The EDL in the command changes & pointers in it should not be referenced.