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, int use_inout)
135 if(!edl) edl = this->edl;
145 start_position = edl->local_session->get_selectionstart(1);
146 if(EQUIV(edl->local_session->get_selectionend(1), edl->local_session->get_selectionstart(1)))
147 end_position = edl->tracks->total_playable_length();
149 end_position = edl->local_session->get_selectionend(1);
150 // this prevents a crash if start position is after the loop when playing forwards
151 if (edl->local_session->loop_playback && start_position > edl->local_session->loop_end)
153 start_position = edl->local_session->loop_start;
160 end_position = edl->local_session->get_selectionend(1);
161 if(EQUIV(edl->local_session->get_selectionend(1), edl->local_session->get_selectionstart(1)))
164 start_position = edl->local_session->get_selectionstart(1);
165 // this prevents a crash if start position is before the loop when playing backwards
166 if (edl->local_session->loop_playback && start_position <= edl->local_session->loop_start)
168 start_position = edl->local_session->loop_end;
169 end_position = edl->local_session->loop_end;
174 case SINGLE_FRAME_FWD:
175 start_position = edl->local_session->get_selectionstart(1);
176 end_position = start_position +
178 edl->session->frame_rate;
181 case SINGLE_FRAME_REWIND:
182 start_position = edl->local_session->get_selectionend(1);
183 end_position = start_position -
185 edl->session->frame_rate;
192 if(edl->local_session->inpoint_valid())
193 start_position = edl->local_session->get_inpoint();
194 if(edl->local_session->outpoint_valid())
195 end_position = edl->local_session->get_outpoint();
198 switch(get_direction())
201 playbackstart = start_position;
205 playbackstart = end_position;
211 void TransportCommand::adjust_playback_range()
215 if(edl->local_session->inpoint_valid() ||
216 edl->local_session->outpoint_valid())
218 if(edl->local_session->inpoint_valid())
219 start_position = edl->local_session->get_inpoint();
223 if(edl->local_session->outpoint_valid())
224 end_position = edl->local_session->get_outpoint();
226 end_position = edl->tracks->total_playable_length();
247 TransportQue::TransportQue()
249 input_lock = new Condition(1, "TransportQue::input_lock");
250 output_lock = new Condition(0, "TransportQue::output_lock");
253 TransportQue::~TransportQue()
259 int TransportQue::send_command(int command,
266 input_lock->lock("TransportQue::send_command 1");
267 this->command.command = command;
268 // Mutually exclusive operation
269 this->command.change_type |= change_type;
270 this->command.realtime = realtime;
271 this->command.resume = resume;
275 // Just change the EDL if the change requires it because renderengine
276 // structures won't point to the new EDL otherwise and because copying the
277 // EDL for every cursor movement is slow.
278 if(change_type == CHANGE_EDL ||
279 change_type == CHANGE_ALL)
282 this->command.get_edl()->copy_all(new_edl);
285 if(change_type == CHANGE_PARAMS)
287 this->command.get_edl()->synchronize_params(new_edl);
290 // Set playback range
291 this->command.set_playback_range(new_edl, use_inout);
294 input_lock->unlock();
296 output_lock->unlock();
300 void TransportQue::update_change_type(int change_type)
302 input_lock->lock("TransportQue::update_change_type");
303 this->command.change_type |= change_type;
304 input_lock->unlock();