Credit Andrew fix Alpha Bug of BT558 + small cleanup
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / tracklist.C
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 #include "intauto.h"
23 #include "intautos.h"
24 #include "tracklist.h"
25
26 TrackList::TrackList(MWindow *mwindow, long position, int reverse)
27  : ArrayList<Track*>()
28 {
29         this->mwindow = mwindow;
30 }
31
32 TrackList::get_playable_audio(long position, int reverse)
33 {
34         get_playable_type(position, reverse, TRACK_AUDIO);
35 }
36
37 TrackList::get_playable_video(long position, int reverse)
38 {
39         get_playable_type(position, reverse, TRACK_VIDEO);
40 }
41
42
43
44 TrackList::get_recordable_audio()
45 {
46         get_recordable_type(TRACK_AUDIO);
47 }
48
49 TrackList::get_recordable_video()
50 {
51         get_recordable_type(TRACK_VIDEO);
52 }
53
54 TrackList::get_playable_type(long position, int reverse, int data_type)
55 {
56         Track *current_track;
57         Patch *current_patch;
58         Auto *current_auto;
59
60         for(current_track = mwindow->tracks->first,
61                 current_patch = mwindow->patches->first;
62                 current_track && current_patch;
63                 current_track = current_track->next,
64                 current_patch = current_patch->next)
65         {
66                 if(current_patch->play && current_track->data_type == data_type)
67                 {
68                         current_auto = current_track->play_autos->autoof(position);
69
70 // get auto right before position
71                         if(reverse)
72                         {
73                                 if(current_auto && current_auto->position < position)
74                                         current_auto = current_auto->next;
75                         }
76                         else
77                         {
78                                 if(current_auto && current_auto->position > position)
79                                         current_auto = current_auto->previous;
80                         }
81
82                         if(!current_auto || current_auto->value == 1)
83                                 append((ATrack*)current_track);
84                 }
85         }
86 }
87
88 TrackList::get_recordable_type(int data_type)
89 {
90         Track *current_track;
91         Patch *current_patch;
92
93         for(current_track = tracks->first, current_patch = patches->first;
94                 current_track && current_patch;
95                 current_track = current_track->next, current_patch = current_patch->next)
96         {
97                 if(current_patch->is_armed() && current_track->data_type == TRACK_AUDIO)
98                         append((ATrack*)current_track);
99         }
100 }