X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fplaybackengine.C;h=82bd7bb6587b930b77caa7f4da7673255539b3a3;hb=271d07e4385f187b88ffcd986e9ecf5635a51718;hp=917e0470b2fd19914e36215d9e8e32cd76d973c0;hpb=07af5297688e2f888e0a309eab76293093a003bb;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/playbackengine.C b/cinelerra-5.1/cinelerra/playbackengine.C index 917e0470..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(); @@ -426,9 +430,9 @@ void PlaybackEngine::run() void PlaybackEngine::clear_borders() { EDL *edl = command->get_edl(); - if( render_engine ) { - PlaybackConfig *config = edl->session->playback_config; - if( config->vconfig->driver == PLAYBACK_X11_GL ) { + PlaybackConfig *config = edl->session->playback_config; + if( config->vconfig->driver == PLAYBACK_X11_GL ) { + if( render_engine && render_engine->video ) { VDeviceBase *vdriver = render_engine->video->get_output_base(); ((VDeviceX11*)vdriver)->clear_output(); return; @@ -452,12 +456,16 @@ void PlaybackEngine::stop_playback(int wait_tracking) renderengine_lock->unlock(); } +int PlaybackEngine::get_direction() +{ + int curr_command = is_playing_back ? this->command->command : STOP; + return TransportCommand::get_direction(curr_command); +} void PlaybackEngine::send_command(int command, EDL *edl, int wait_tracking, int use_inout) { //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 ? @@ -465,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: @@ -482,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)