5 #include "edlsession.h"
6 #include "localsession.h"
8 #include "transportque.h"
10 TransportCommand::TransportCommand()
12 // In rendering we want a master EDL so settings don't get clobbered
13 // in the middle of a job.
15 edl->create_objects();
21 TransportCommand::~TransportCommand()
26 void TransportCommand::reset()
34 // Don't reset the change type for commands which don't perform the change
35 if(command != STOP) change_type = 0;
36 command = COMMAND_NONE;
39 EDL* TransportCommand::get_edl()
44 void TransportCommand::delete_edl()
50 void TransportCommand::new_edl()
53 edl->create_objects();
57 void TransportCommand::copy_from(TransportCommand *command)
59 this->command = command->command;
60 this->change_type = command->change_type;
61 this->edl->copy_all(command->edl);
62 this->start_position = command->start_position;
63 this->end_position = command->end_position;
64 this->playbackstart = command->playbackstart;
65 this->realtime = command->realtime;
66 this->resume = command->resume;
69 TransportCommand& TransportCommand::operator=(TransportCommand &command)
75 int TransportCommand::single_frame()
77 return (command == SINGLE_FRAME_FWD ||
78 command == SINGLE_FRAME_REWIND ||
79 command == CURRENT_FRAME);
83 int TransportCommand::get_direction()
87 case SINGLE_FRAME_FWD:
95 case SINGLE_FRAME_REWIND:
108 float TransportCommand::get_speed()
119 case SINGLE_FRAME_FWD:
120 case SINGLE_FRAME_REWIND:
132 // Assume starting without pause
133 void TransportCommand::set_playback_range(EDL *edl)
135 if(!edl) edl = this->edl;
141 start_position = edl->local_session->selectionstart;
142 if(EQUIV(edl->local_session->selectionend, edl->local_session->selectionstart))
143 end_position = edl->tracks->total_playable_length();
145 end_position = edl->local_session->selectionend;
146 // this prevents a crash if start position is after the loop when playing forwards
147 if (edl->local_session->loop_playback && start_position > edl->local_session->loop_end)
149 start_position = edl->local_session->loop_start;
156 end_position = edl->local_session->selectionend;
157 if(EQUIV(edl->local_session->selectionend, edl->local_session->selectionstart))
160 start_position = edl->local_session->selectionstart;
161 // this prevents a crash if start position is before the loop when playing backwards
162 if (edl->local_session->loop_playback && start_position <= edl->local_session->loop_start)
164 start_position = edl->local_session->loop_end;
165 end_position = edl->local_session->loop_end;
170 case SINGLE_FRAME_FWD:
171 start_position = edl->local_session->selectionstart;
172 end_position = start_position +
174 edl->session->frame_rate;
177 case SINGLE_FRAME_REWIND:
178 start_position = edl->local_session->selectionend;
179 end_position = start_position -
181 edl->session->frame_rate;
185 switch(get_direction())
188 playbackstart = start_position;
192 playbackstart = end_position;
195 // printf("TransportCommand::set_playback_range %f %f\n",
196 // start_position * edl->session->frame_rate,
197 // end_position * edl->session->frame_rate);
200 void TransportCommand::adjust_playback_range()
202 if(edl->local_session->in_point >= 0 ||
203 edl->local_session->out_point >= 0)
205 if(edl->local_session->in_point >= 0)
206 start_position = edl->local_session->in_point;
210 if(edl->local_session->out_point >= 0)
211 end_position = edl->local_session->out_point;
213 end_position = edl->tracks->total_playable_length();
234 TransportQue::TransportQue()
236 input_lock = new Condition(1, "TransportQue::input_lock");
237 output_lock = new Condition(0, "TransportQue::output_lock");
240 TransportQue::~TransportQue()
246 int TransportQue::send_command(int command,
252 input_lock->lock("TransportQue::send_command 1");
253 this->command.command = command;
254 // Mutually exclusive operation
255 this->command.change_type |= change_type;
256 this->command.realtime = realtime;
257 this->command.resume = resume;
261 // Just change the EDL if the change requires it because renderengine
262 // structures won't point to the new EDL otherwise and because copying the
263 // EDL for every cursor movement is slow.
264 if(change_type == CHANGE_EDL ||
265 change_type == CHANGE_ALL)
268 this->command.get_edl()->copy_all(new_edl);
271 if(change_type == CHANGE_PARAMS)
273 this->command.get_edl()->synchronize_params(new_edl);
276 // Set playback range
277 this->command.set_playback_range(new_edl);
280 input_lock->unlock();
282 output_lock->unlock();
286 void TransportQue::update_change_type(int change_type)
288 input_lock->lock("TransportQue::update_change_type");
289 this->command.change_type |= change_type;
290 input_lock->unlock();