3 #include "edlsession.h"
4 #include "localsession.h"
6 #include "transportque.h"
8 TransportCommand::TransportCommand()
10 // In rendering we want a master EDL so settings don't get clobbered
11 // in the middle of a job.
13 edl->create_objects();
19 TransportCommand::~TransportCommand()
24 void TransportCommand::reset()
32 // Don't reset the change type for commands which don't perform the change
33 if(command != STOP) change_type = 0;
34 command = COMMAND_NONE;
37 EDL* TransportCommand::get_edl()
42 TransportCommand& TransportCommand::operator=(TransportCommand &command)
44 this->command = command.command;
45 this->change_type = command.change_type;
46 //printf("TransportCommand::operator= 1\n");
47 *this->edl = *command.edl;
48 //printf("TransportCommand::operator= 2\n");
49 this->start_position = command.start_position;
50 this->end_position = command.end_position;
51 this->playbackstart = command.playbackstart;
52 this->realtime = command.realtime;
53 this->resume = command.resume;
57 int TransportCommand::single_frame()
59 return (command == SINGLE_FRAME_FWD ||
60 command == SINGLE_FRAME_REWIND ||
61 command == CURRENT_FRAME);
65 int TransportCommand::get_direction()
69 case SINGLE_FRAME_FWD:
77 case SINGLE_FRAME_REWIND:
90 float TransportCommand::get_speed()
101 case SINGLE_FRAME_FWD:
102 case SINGLE_FRAME_REWIND:
114 // Assume starting without pause
115 void TransportCommand::set_playback_range(EDL *edl)
122 start_position = edl->local_session->selectionstart;
123 if(EQUIV(edl->local_session->selectionend, edl->local_session->selectionstart))
124 end_position = edl->tracks->total_playable_length();
126 end_position = edl->local_session->selectionend;
127 // this prevents a crash if start position is after the loop when playing forwards
128 if (edl->local_session->loop_playback && start_position > edl->local_session->loop_end)
130 start_position = edl->local_session->loop_start;
137 end_position = edl->local_session->selectionend;
138 if(EQUIV(edl->local_session->selectionend, edl->local_session->selectionstart))
141 start_position = edl->local_session->selectionstart;
142 // this prevents a crash if start position is before the loop when playing backwards
143 if (edl->local_session->loop_playback && start_position <= edl->local_session->loop_start)
145 start_position = edl->local_session->loop_end;
146 end_position = edl->local_session->loop_end;
151 case SINGLE_FRAME_FWD:
152 start_position = edl->local_session->selectionstart;
153 end_position = start_position +
155 edl->session->frame_rate;
158 case SINGLE_FRAME_REWIND:
159 start_position = edl->local_session->selectionend;
160 end_position = start_position -
162 edl->session->frame_rate;
166 switch(get_direction())
169 playbackstart = start_position;
173 playbackstart = end_position;
176 // printf("TransportCommand::set_playback_range %f %f\n",
177 // start_position * edl->session->frame_rate,
178 // end_position * edl->session->frame_rate);
198 TransportQue::TransportQue()
203 TransportQue::~TransportQue()
207 int TransportQue::send_command(int command,
213 //printf("TransportQue::send_command 1\n");
215 this->command.command = command;
216 // Mutually exclusive operation
217 this->command.change_type |= change_type;
218 //printf("TransportQue::send_command 1 %x\n", change_type);
219 // if(command == STOP)
220 // this->command.change_type = CHANGE_NONE;
221 //printf("TransportQue::send_command 2\n");
223 this->command.realtime = realtime;
224 this->command.resume = resume;
228 // Just change the EDL if the change requires it because renderengine
229 // structures won't point to the new EDL otherwise and because copying the
230 // EDL for every cursor movement is slow.
231 if(change_type == CHANGE_EDL ||
232 change_type == CHANGE_ALL)
235 *this->command.get_edl() = *new_edl;
238 if(change_type == CHANGE_PARAMS)
240 this->command.get_edl()->synchronize_params(new_edl);
243 // Set playback range
244 this->command.set_playback_range(new_edl);
247 //printf("TransportQue::send_command 3\n");
248 //printf("TransportQue::send_command 2 %p %d %d\n", new_edl, this->command.playbackstart);
250 output_lock.unlock();
251 //printf("TransportQue::send_command 4\n");
255 void TransportQue::update_change_type(int change_type)
258 this->command.change_type |= change_type;