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::playback_range_adjust_inout()
213 if(edl->local_session->inpoint_valid() ||
214 edl->local_session->outpoint_valid())
216 playback_range_inout();
220 void TransportCommand::playback_range_inout()
222 if(edl->local_session->inpoint_valid())
223 start_position = edl->local_session->get_inpoint();
227 if(edl->local_session->outpoint_valid())
228 end_position = edl->local_session->get_outpoint();
230 end_position = edl->tracks->total_playable_length();
233 void TransportCommand::playback_range_project()
236 end_position = edl->tracks->total_playable_length();
254 TransportQue::TransportQue()
256 input_lock = new Condition(1, "TransportQue::input_lock");
257 output_lock = new Condition(0, "TransportQue::output_lock", 1);
260 TransportQue::~TransportQue()
266 int TransportQue::send_command(int command,
273 input_lock->lock("TransportQue::send_command 1");
274 this->command.command = command;
275 // Mutually exclusive operation
276 this->command.change_type |= change_type;
277 this->command.realtime = realtime;
278 this->command.resume = resume;
282 // Just change the EDL if the change requires it because renderengine
283 // structures won't point to the new EDL otherwise and because copying the
284 // EDL for every cursor movement is slow.
285 if(change_type == CHANGE_EDL ||
286 change_type == CHANGE_ALL)
289 this->command.get_edl()->copy_all(new_edl);
292 if(change_type == CHANGE_PARAMS)
294 this->command.get_edl()->synchronize_params(new_edl);
297 // Set playback range
298 this->command.set_playback_range(new_edl, use_inout);
301 input_lock->unlock();
303 output_lock->unlock();
307 void TransportQue::update_change_type(int change_type)
309 input_lock->lock("TransportQue::update_change_type");
310 this->command.change_type |= change_type;
311 input_lock->unlock();
316 // c-file-style: "linux"