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