fix get_auto_at_position equivalence test, fix KeySpeedAutoEdge init toggle value...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / playbackengine.C
index 83bd3efa9027cbc000f2436c9f86d4d381a58682..82bd7bb6587b930b77caa7f4da7673255539b3a3 100644 (file)
@@ -85,8 +85,10 @@ PlaybackEngine::~PlaybackEngine()
        Thread::join();
        delete preferences;
        delete_render_engine();
-       delete audio_cache;
-       delete video_cache;
+       if( audio_cache )
+               audio_cache->remove_user();
+       if( video_cache )
+               video_cache->remove_user();
        delete tracking_lock;
        delete tracking_done;
        delete pause_lock;
@@ -162,10 +164,12 @@ void PlaybackEngine::wait_render_engine()
 
 void PlaybackEngine::create_cache()
 {
-       if(audio_cache) { delete audio_cache;  audio_cache = 0; }
-       if(video_cache) { delete video_cache;  video_cache = 0; }
-       if(!audio_cache) audio_cache = new CICache(preferences);
-       if(!video_cache) video_cache = new CICache(preferences);
+       if( audio_cache )
+               audio_cache->remove_user();
+       if( video_cache )
+               video_cache->remove_user();
+       audio_cache = new CICache(preferences);
+       video_cache = new CICache(preferences);
 }
 
 
@@ -258,8 +262,9 @@ void PlaybackEngine::init_tracking()
        init_meters();
 }
 
-void PlaybackEngine::stop_tracking()
+void PlaybackEngine::stop_tracking(double position)
 {
+       tracking_position = position;
        tracking_active = 0;
        stop_cursor();
        tracking_done->unlock();
@@ -468,7 +473,6 @@ void PlaybackEngine::send_command(int command, EDL *edl, int wait_tracking, int
        int single_frame = TransportCommand::single_frame(command);
        int next_audio = next_command->toggle_audio ? !single_frame : single_frame;
        float next_speed = next_command->speed;
-       int cmd = -1;
 // Dispatch command
        switch( command ) {
        case STOP:
@@ -510,17 +514,16 @@ void PlaybackEngine::send_command(int command, EDL *edl, int wait_tracking, int
                        break;
                }
                next_command->realtime = 1;
-               cmd = command;
+               transport_command(command, CHANGE_NONE, edl, use_inout);
                break;
        case REWIND:
        case GOTO_END:
                transport_stop(1);
                next_command->realtime = 1;
-               cmd = command;
+               transport_command(command, CHANGE_NONE, edl, use_inout);
+               stop_tracking(this->command->playbackstart);
                break;
        }
-       if( cmd >= 0 )
-               transport_command(cmd, CHANGE_NONE, edl, use_inout);
 }
 
 int PlaybackEngine::put_command(TransportCommand *command, int reset)