X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fplaybackengine.C;h=82bd7bb6587b930b77caa7f4da7673255539b3a3;hb=3cbe62ca61e2b35d3e228978f6cdedd11218077f;hp=f95f57581b0dcf7f3ee025d5620912069624d8ca;hpb=0e6cf5b52d1ebce9272270144bcf43df4683507e;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/playbackengine.C b/cinelerra-5.1/cinelerra/playbackengine.C index f95f5758..82bd7bb6 100644 --- a/cinelerra-5.1/cinelerra/playbackengine.C +++ b/cinelerra-5.1/cinelerra/playbackengine.C @@ -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(); @@ -402,12 +407,11 @@ void PlaybackEngine::run() // Dispatch the command start_render_engine(); break; - - case SINGLE_FRAME_FWD: - case SINGLE_FRAME_REWIND: // fall through default: is_playing_back = 1; + case REWIND: + case GOTO_END: perform_change(); arm_render_engine(); @@ -462,7 +466,6 @@ void PlaybackEngine::send_command(int command, EDL *edl, int wait_tracking, int { //printf("PlaybackEngine::send_command 1 %d\n", command); // Stop requires transferring the output buffer to a refresh buffer. - int do_stop = 0; int curr_command = is_playing_back ? this->command->command : STOP; int curr_single_frame = TransportCommand::single_frame(curr_command); int curr_audio = this->command->toggle_audio ? @@ -470,9 +473,11 @@ 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; - // Dispatch command switch( command ) { + case STOP: + transport_stop(wait_tracking); + break; case FAST_REWIND: // Commands that play back case NORMAL_REWIND: case SLOW_REWIND: @@ -487,38 +492,38 @@ void PlaybackEngine::send_command(int command, EDL *edl, int wait_tracking, int if( next_speed ) curr_command = COMMAND_NONE; // Same direction pressed twice, not shuttle, and no change in audio state, Stop if( curr_command == command && !curr_single_frame && - curr_audio == next_audio ) { do_stop = 1; break; } - + curr_audio == next_audio ) { + transport_stop(wait_tracking); + break; + } // Resume or change direction switch( curr_command ) { - default: - transport_stop(0); - next_command->resume = 1; -// fall through + case REWIND: + case GOTO_END: case STOP: case COMMAND_NONE: case SINGLE_FRAME_FWD: case SINGLE_FRAME_REWIND: case CURRENT_FRAME: case LAST_FRAME: - next_command->realtime = 1; -// Start from scratch - transport_command(command, CHANGE_NONE, edl, use_inout); +// already stopped + break; + default: + transport_stop(0); + next_command->resume = 1; break; } + next_command->realtime = 1; + transport_command(command, CHANGE_NONE, edl, use_inout); break; - -// Commands that stop - case STOP: case REWIND: case GOTO_END: - do_stop = 1; + transport_stop(1); + next_command->realtime = 1; + transport_command(command, CHANGE_NONE, edl, use_inout); + stop_tracking(this->command->playbackstart); break; } - - if( do_stop ) { - transport_stop(wait_tracking); - } } int PlaybackEngine::put_command(TransportCommand *command, int reset)