X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fplaybackengine.C;h=7dcea2df1f6203d348dbb5ad096e0f427c535699;hb=3966bf849d26244bc8b9a39fa485a808272225d0;hp=faaff0e88db6cd9ab518b6ad0bca2f42a9bcfa49;hpb=49f85559268fc040fe7ba5611cc0520793cf728b;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/playbackengine.C b/cinelerra-5.1/cinelerra/playbackengine.C index faaff0e8..7dcea2df 100644 --- a/cinelerra-5.1/cinelerra/playbackengine.C +++ b/cinelerra-5.1/cinelerra/playbackengine.C @@ -2,21 +2,21 @@ /* * CINELERRA * Copyright (C) 2008 Adam Williams - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ #include "bchash.h" @@ -66,7 +66,7 @@ PlaybackEngine::~PlaybackEngine() { done = 1; que->send_command(STOP, - CHANGE_NONE, + CHANGE_NONE, 0, 0); interrupt_playback(); @@ -244,7 +244,7 @@ void PlaybackEngine::stop_cursor() void PlaybackEngine::init_tracking() { - tracking_active = !command->single_frame() ? 1 : 0; + tracking_active = !command->single_frame() ? 1 : 0; tracking_position = command->playbackstart; tracking_done->lock("PlaybackEngine::init_tracking"); init_cursor(tracking_active); @@ -300,8 +300,8 @@ double PlaybackEngine::get_tracking_position() if(command->get_direction() == PLAY_FORWARD) { // Interpolate - result = tracking_position + - command->get_speed() * + result = tracking_position + + command->get_speed() * tracking_timer.get_difference() / 1000.0; @@ -315,8 +315,8 @@ double PlaybackEngine::get_tracking_position() else { // Interpolate - result = tracking_position - - command->get_speed() * + result = tracking_position - + command->get_speed() * tracking_timer.get_difference() / 1000.0; @@ -351,14 +351,11 @@ void PlaybackEngine::run() { start_lock->unlock(); - do - { + while( !done ) { // Wait for current command to finish que->output_lock->lock("PlaybackEngine::run"); - wait_render_engine(); - // Read the new command que->input_lock->lock("PlaybackEngine::run"); if(done) return; @@ -366,61 +363,65 @@ void PlaybackEngine::run() command->copy_from(&que->command); que->command.reset(); que->input_lock->unlock(); - //printf("PlaybackEngine::run 1 %d\n", command->command); - - switch(command->command) - { + switch( command->command ) { // Parameter change only - case COMMAND_NONE: -// command->command = last_command; - perform_change(); - break; - - case PAUSE: - init_cursor(0); - pause_lock->lock("PlaybackEngine::run"); - stop_cursor(); - break; - - case STOP: + case COMMAND_NONE: +// command->command = last_command; + perform_change(); + break; + + case PAUSE: + init_cursor(0); + pause_lock->lock("PlaybackEngine::run"); + stop_cursor(); + break; + + case STOP: // No changing - break; + break; - case CURRENT_FRAME: - last_command = command->command; - perform_change(); - arm_render_engine(); + case CURRENT_FRAME: + last_command = command->command; + perform_change(); + arm_render_engine(); // Dispatch the command - start_render_engine(); - break; - - default: - last_command = command->command; - is_playing_back = 1; - if(command->command == SINGLE_FRAME_FWD || - command->command == SINGLE_FRAME_REWIND) - { - command->playbackstart = get_tracking_position(); - } + start_render_engine(); + break; - perform_change(); - arm_render_engine(); + case SINGLE_FRAME_FWD: + case SINGLE_FRAME_REWIND: +// fall through + default: + last_command = command->command; + is_playing_back = 1; + + perform_change(); + arm_render_engine(); // Start tracking after arming so the tracking position doesn't change. // The tracking for a single frame command occurs during PAUSE - init_tracking(); + init_tracking(); // Dispatch the command - start_render_engine(); - break; + start_render_engine(); + break; } //printf("PlaybackEngine::run 100\n"); - }while(!done); + } } +void PlaybackEngine::stop_playback() +{ + que->send_command(STOP, CHANGE_NONE, 0, 0); + interrupt_playback(1); + renderengine_lock->lock("PlaybackEngine::stop_playback"); + if(render_engine) + render_engine->wait_done(); + renderengine_lock->unlock(); +}