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 RESOURCETHREAD_H
23 #define RESOURCETHREAD_H
25 // This thread tries to draw picons into the timeline, asynchronous
28 // TrackCanvas draws the picons which are in the cache and makes a table of
29 // picons and locations which need to be decompressed. Then ResourceThread
30 // decompresses the picons and draws them one by one, refreshing the
31 // entire trackcanvas in the process.
34 #include "arraylist.h"
35 #include "bctimer.inc"
36 #include "condition.inc"
38 #include "indexable.inc"
39 #include "maxchannels.h"
40 #include "mwindow.inc"
41 #include "renderengine.inc"
42 #include "samples.inc"
47 class ResourceThreadItem
50 ResourceThreadItem(ResourcePixmap *pixmap,
55 virtual ~ResourceThreadItem();
57 ResourcePixmap *pixmap;
66 class AResourceThreadItem : public ResourceThreadItem
69 AResourceThreadItem(ResourcePixmap *pixmap,
77 ~AResourceThreadItem();
84 class VResourceThreadItem : public ResourceThreadItem
87 VResourceThreadItem(ResourcePixmap *pixmap,
98 ~VResourceThreadItem();
112 class ResourceThread : public Thread
115 ResourceThread(MWindow *mwindow, MWindowGUI *gui);
119 void create_objects();
120 // reset - delete all picons. Used for index building.
121 void stop_draw(int reset);
124 // Be sure to stop_draw before changing the asset table,
126 void add_picon(ResourcePixmap *pixmap,
135 Indexable *indexable);
137 void add_wave(ResourcePixmap *pixmap,
139 Indexable *indexable,
142 // samples relative to asset rate
143 int64_t source_start,
149 void do_video(VResourceThreadItem *item);
150 void do_audio(AResourceThreadItem *item);
152 void open_render_engine(EDL *nested_edl,
156 File *get_video_source(Asset *asset);
157 File *get_audio_source(Asset *asset);
161 Condition *draw_lock;
163 ArrayList<ResourceThreadItem*> items;
168 // Render engine for nested EDL
169 RenderEngine *render_engine;
170 // ID of nested EDL being rendered
171 int render_engine_id;
177 // Current audio buffer for spanning multiple pixels
178 Samples *audio_buffer;
179 // Temporary for nested EDL
180 Samples *temp_buffer[MAX_CHANNELS];
185 // Timer for waveform refreshes
191 // Incremented after every start_draw to prevent overlapping operations