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 PLAYBACKENGINE_H
23 #define PLAYBACKENGINE_H
25 #include "arraylist.h"
26 #include "audiodevice.inc"
29 #include "channeldb.inc"
30 #include "condition.inc"
33 #include "mwindow.inc"
34 #include "maxchannels.h"
36 #include "tracking.inc"
37 #include "preferences.inc"
38 #include "renderengine.inc"
41 #include "transportque.inc"
43 class PlaybackEngine : public Thread
46 PlaybackEngine(MWindow *mwindow, Canvas *output);
47 virtual ~PlaybackEngine();
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();
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();
85 // Maintain caches through console changes
86 CICache *audio_cache, *video_cache;
87 // Maintain playback cursor on GUI
89 // Tracking variables updated by render engines
90 double tracking_position;
91 // Not accurate until the first update_tracking, at which time
92 // tracking_active is incremented to 2.
94 // Lock access to tracking data
96 // Lock access to renderengine between interrupt and deletion
97 Mutex *renderengine_lock;
98 // Block returns until tracking loop is finished
99 Condition *tracking_done;
100 // Pause the main loop for the PAUSE command
101 Condition *pause_lock;
102 // Wait until thread has started
103 Condition *start_lock;
107 // Copy of main preferences
108 Preferences *preferences;
111 // Currently executing command
112 TransportCommand *command;
113 // Last command which affected transport
118 RenderEngine *render_engine;
120 // Used by label commands to get current position
123 // General purpose debugging register