crikey rework, KP4 fix, added Shift-KPx, valgrind cleanups, hex eye-dropper, resize...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / transportque.C
index 5b7fba9d4266ebce17592041b7f1eae35e83f99e..61dbdb6d00e3cd7fbe12a37d02d42fedc5f908cf 100644 (file)
@@ -52,6 +52,7 @@ void TransportCommand::reset()
        infinite = 0;
        realtime = 0;
        resume = 0;
+       audio_toggle = 0;
 // Don't reset the change type for commands which don't perform the change
        if(command != STOP) change_type = 0;
        command = COMMAND_NONE;
@@ -85,6 +86,7 @@ void TransportCommand::copy_from(TransportCommand *command)
        this->playbackstart = command->playbackstart;
        this->realtime = command->realtime;
        this->resume = command->resume;
+       this->audio_toggle = command->audio_toggle;
 }
 
 TransportCommand& TransportCommand::operator=(TransportCommand &command)
@@ -93,70 +95,75 @@ TransportCommand& TransportCommand::operator=(TransportCommand &command)
        return *this;
 }
 
-int TransportCommand::single_frame()
+int TransportCommand::single_frame(int command)
 {
        return (command == SINGLE_FRAME_FWD ||
                command == SINGLE_FRAME_REWIND ||
                command == CURRENT_FRAME);
 }
-
-
-int TransportCommand::get_direction()
+int TransportCommand::single_frame()
 {
-       switch(command)
-       {
-               case SINGLE_FRAME_FWD:
-               case NORMAL_FWD:
-               case FAST_FWD:
-               case SLOW_FWD:
-               case CURRENT_FRAME:
-                       return PLAY_FORWARD;
-                       break;
+       return single_frame(command);
+}
 
-               case SINGLE_FRAME_REWIND:
-               case NORMAL_REWIND:
-               case FAST_REWIND:
-               case SLOW_REWIND:
-                       return PLAY_REVERSE;
-                       break;
 
-               default:
-                       return PLAY_FORWARD;
-                       break;
+int TransportCommand::get_direction(int command)
+{
+       switch(command) {
+       case SINGLE_FRAME_FWD:
+       case NORMAL_FWD:
+       case FAST_FWD:
+       case SLOW_FWD:
+       case CURRENT_FRAME:
+               return PLAY_FORWARD;
+
+       case SINGLE_FRAME_REWIND:
+       case NORMAL_REWIND:
+       case FAST_REWIND:
+       case SLOW_REWIND:
+               return PLAY_REVERSE;
+
+       default:
+               break;
        }
+       return PLAY_FORWARD;
 }
-
-float TransportCommand::get_speed()
+int TransportCommand::get_direction()
 {
-       switch(command)
-       {
-               case SLOW_FWD:
-               case SLOW_REWIND:
-                       return 0.5;
-
-               case NORMAL_FWD:
-               case NORMAL_REWIND:
-               case SINGLE_FRAME_FWD:
-               case SINGLE_FRAME_REWIND:
-               case CURRENT_FRAME:
-                       return 1.;
+       return get_direction(command);
+}
 
-               case FAST_FWD:
-               case FAST_REWIND:
-                       return 2.;
+float TransportCommand::get_speed(int command)
+{
+       switch(command) {
+       case SLOW_FWD:
+       case SLOW_REWIND:
+               return 0.5;
+
+       case NORMAL_FWD:
+       case NORMAL_REWIND:
+       case SINGLE_FRAME_FWD:
+       case SINGLE_FRAME_REWIND:
+       case CURRENT_FRAME:
+               return 1.;
+
+       case FAST_FWD:
+       case FAST_REWIND:
+               return 2.;
        }
 
        return 0.;
 }
+float TransportCommand::get_speed()
+{
+       return get_speed(command);
+}
 
 // Assume starting without pause
-void TransportCommand::set_playback_range(EDL *edl, int use_inout)
+void TransportCommand::set_playback_range(EDL *edl, int use_inout, int toggle_audio)
 {
        if(!edl) edl = this->edl;
 
-
-
-
        switch(command)
        {
                case SLOW_FWD:
@@ -195,16 +202,12 @@ void TransportCommand::set_playback_range(EDL *edl, int use_inout)
                case CURRENT_FRAME:
                case SINGLE_FRAME_FWD:
                        start_position = edl->local_session->get_selectionstart(1);
-                       end_position = start_position +
-                               1.0 /
-                               edl->session->frame_rate;
+                       end_position = start_position + 1.0 / edl->session->frame_rate;
                        break;
 
                case SINGLE_FRAME_REWIND:
-                       start_position = edl->local_session->get_selectionend(1);
-                       end_position = start_position -
-                               1.0 /
-                               edl->session->frame_rate;
+                       end_position = edl->local_session->get_selectionend(1);
+                       start_position = end_position - 1.0 / edl->session->frame_rate;
                        break;
        }
 
@@ -228,6 +231,7 @@ void TransportCommand::set_playback_range(EDL *edl, int use_inout)
                        break;
        }
 
+       audio_toggle = toggle_audio;
 }
 
 void TransportCommand::playback_range_adjust_inout()
@@ -258,19 +262,11 @@ void TransportCommand::playback_range_project()
        end_position = edl->tracks->total_playable_length();
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
+void TransportCommand::playback_range_1frame()
+{
+       start_position = end_position = edl->local_session->get_selectionstart(1);
+       if( edl->session->frame_rate > 0 ) end_position += 1./edl->session->frame_rate;
+}
 
 
 TransportQue::TransportQue()
@@ -285,12 +281,8 @@ TransportQue::~TransportQue()
        delete output_lock;
 }
 
-int TransportQue::send_command(int command,
-               int change_type,
-               EDL *new_edl,
-               int realtime,
-               int resume,
-               int use_inout)
+int TransportQue::send_command(int command, int change_type, EDL *new_edl,
+               int realtime, int resume, int use_inout, int toggle_audio)
 {
        input_lock->lock("TransportQue::send_command 1");
        this->command.command = command;
@@ -317,7 +309,7 @@ int TransportQue::send_command(int command,
                }
 
 // Set playback range
-               this->command.set_playback_range(new_edl, use_inout);
+               this->command.set_playback_range(new_edl, use_inout, toggle_audio);
        }
 
        input_lock->unlock();