From: Good Guy Date: Fri, 20 Mar 2020 23:04:59 +0000 (-0600) Subject: mixer enable playback, home/end fixes, stop throw with exrlist missing file X-Git-Tag: 2020-03~10 X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=f1fc28e0bbb5a7c0e153ef9c1abdbfb1186e1acc;p=goodguy%2Fcinelerra.git mixer enable playback, home/end fixes, stop throw with exrlist missing file --- diff --git a/cinelerra-5.1/cinelerra/fileexr.C b/cinelerra-5.1/cinelerra/fileexr.C index e84ef84d..2a54f3ed 100644 --- a/cinelerra-5.1/cinelerra/fileexr.C +++ b/cinelerra-5.1/cinelerra/fileexr.C @@ -281,7 +281,7 @@ int FileEXR::read_frame_header(char *path) // EXRIStream exr_stream(buffer, size); // Imf::InputFile file(exr_stream); - + if( access(path, R_OK) ) return 1; Imf::InputFile file(path); Imath::Box2i dw = file.header().dataWindow(); diff --git a/cinelerra-5.1/cinelerra/playbackengine.C b/cinelerra-5.1/cinelerra/playbackengine.C index 83bd3efa..8ce98234 100644 --- a/cinelerra-5.1/cinelerra/playbackengine.C +++ b/cinelerra-5.1/cinelerra/playbackengine.C @@ -258,8 +258,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 +469,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 +510,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) diff --git a/cinelerra-5.1/cinelerra/playbackengine.h b/cinelerra-5.1/cinelerra/playbackengine.h index c82d3508..ee27ff19 100644 --- a/cinelerra-5.1/cinelerra/playbackengine.h +++ b/cinelerra-5.1/cinelerra/playbackengine.h @@ -70,7 +70,7 @@ public: virtual int brender_available(long position); // For normal playback tracking and the cursor are started virtual void init_tracking(); - virtual void stop_tracking(); + virtual void stop_tracking(double position); virtual void init_meters(); // The playback cursor calls this to calculate the current tracking position virtual double get_tracking_position(); diff --git a/cinelerra-5.1/cinelerra/renderengine.C b/cinelerra-5.1/cinelerra/renderengine.C index ed991791..dd03089c 100644 --- a/cinelerra-5.1/cinelerra/renderengine.C +++ b/cinelerra-5.1/cinelerra/renderengine.C @@ -468,18 +468,16 @@ void RenderEngine::run() close_output(); if( playback_engine ) { - double position = command->command == CURRENT_FRAME ? command->playbackstart : + double position = command->command == CURRENT_FRAME || + command->command == LAST_FRAME ? command->playbackstart : playback_engine->is_playing_back && !interrupted ? ( command->get_direction() == PLAY_FORWARD ? command->end_position : command->start_position ) : playback_engine->get_tracking_position() ; - if( command->displacement ) { - position -= 1./command->get_edl()->session->frame_rate; - if( position < 0 ) position = 0; - } + position -= command->displacement; + if( position < 0 ) position = 0; playback_engine->is_playing_back = 0; - playback_engine->tracking_position = position; - playback_engine->stop_tracking(); + playback_engine->stop_tracking(position); } render_active->unlock(); diff --git a/cinelerra-5.1/cinelerra/tracking.C b/cinelerra-5.1/cinelerra/tracking.C index 4ba197e5..102178e6 100644 --- a/cinelerra-5.1/cinelerra/tracking.C +++ b/cinelerra-5.1/cinelerra/tracking.C @@ -97,15 +97,11 @@ int Tracking::stop_playback() // Not working in NPTL for some reason // Thread::cancel(); Thread::join(); - - mwindow->stop_mixers(); -// Final position is updated continuously during playback -// Get final position - double position = get_tracking_position(); -// Update cursor - update_tracker(position); - stop_meters(); + stop_mixers(); +// tracking_position is updated continuously during playback +// and when render ends, update cursor with final position + update_tracker(get_tracking_position()); } return 0; } @@ -159,7 +155,10 @@ void Tracking::stop_meters() mwindow->lwindow->gui->unlock_window(); } - +void Tracking::stop_mixers() +{ + mwindow->stop_mixers(); +} void Tracking::update_tracker(double position) diff --git a/cinelerra-5.1/cinelerra/tracking.h b/cinelerra-5.1/cinelerra/tracking.h index 71fd582f..556afecf 100644 --- a/cinelerra-5.1/cinelerra/tracking.h +++ b/cinelerra-5.1/cinelerra/tracking.h @@ -51,6 +51,7 @@ public: // Update meters virtual void update_meters(int64_t position); virtual void stop_meters(); + virtual void stop_mixers(); // int get_pixel(double position); // Erase cursor if it's visible. Called by start_playback diff --git a/cinelerra-5.1/cinelerra/transportque.C b/cinelerra-5.1/cinelerra/transportque.C index 5b3a3762..a8c1fb92 100644 --- a/cinelerra-5.1/cinelerra/transportque.C +++ b/cinelerra-5.1/cinelerra/transportque.C @@ -169,11 +169,19 @@ void TransportCommand::set_playback_range(EDL *edl, int use_inout, int do_displa end_position = use_inout && edl->local_session->outpoint_valid() ? edl->local_session->get_outpoint() : !loop_play ? edl->local_session->get_selectionend(1) : length; + if( start_position >= length ) + length = edl->tracks->total_length(); - if( !use_inout && EQUIV(start_position, end_position) ) { + if( command == REWIND ) { + start_position = end_position = 0; + command = CURRENT_FRAME; + } + else if( command == GOTO_END ) { + start_position = end_position = length; + command = LAST_FRAME; + } + else if( !use_inout && EQUIV(start_position, end_position) ) { // starting play at or past end_position, play to end_position of media (for mixers) - if( start_position >= length ) - length = edl->tracks->total_length(); switch( command ) { case SLOW_FWD: case FAST_FWD: @@ -184,6 +192,7 @@ void TransportCommand::set_playback_range(EDL *edl, int use_inout, int do_displa start_position > edl->local_session->loop_end ) { start_position = edl->local_session->loop_start; } + displacement = realtime && do_displacement ? frame_period : 0; break; } case SLOW_REWIND: @@ -197,31 +206,20 @@ void TransportCommand::set_playback_range(EDL *edl, int use_inout, int do_displa } break; - case REWIND: - start_position = 0; + case SINGLE_FRAME_FWD: + displacement = realtime && do_displacement ? frame_period : 0; case CURRENT_FRAME: case LAST_FRAME: - case SINGLE_FRAME_FWD: end_position = start_position + frame_period; break; - case GOTO_END: - end_position = length; case SINGLE_FRAME_REWIND: start_position = end_position - frame_period; break; } - - if( realtime && do_displacement ) { - if( (command != CURRENT_FRAME && get_direction() == PLAY_FORWARD ) || - (command != LAST_FRAME && get_direction() == PLAY_REVERSE ) ) { - start_position += frame_period; - end_position += frame_period; - displacement = 1; - } - } + start_position += displacement; + end_position += displacement; } - // if( start_position < 0 ) // start_position = 0; // if( end_position > length ) diff --git a/cinelerra-5.1/cinelerra/transportque.h b/cinelerra-5.1/cinelerra/transportque.h index fd5a5cc4..2594594f 100644 --- a/cinelerra-5.1/cinelerra/transportque.h +++ b/cinelerra-5.1/cinelerra/transportque.h @@ -62,8 +62,8 @@ public: int infinite; // Position used when starting playback double playbackstart; -// start at this=0/next=1 frame - int displacement; +// playback offset for always show next frame pref + double displacement; // Send output to device int realtime; // command must execute diff --git a/cinelerra-5.1/cinelerra/zwindow.C b/cinelerra-5.1/cinelerra/zwindow.C index 62a98cc0..a833b284 100644 --- a/cinelerra-5.1/cinelerra/zwindow.C +++ b/cinelerra-5.1/cinelerra/zwindow.C @@ -186,6 +186,7 @@ ZWindow::ZWindow(MWindow *mwindow) idx = -1; edl = 0; highlighted = 0; + playable = 1; title[0] = 0; zgui = 0; zoom = 0; @@ -235,6 +236,7 @@ void ZWindow::stop_playback(int wait) void ZWindow::handle_mixer(int command, int wait_tracking, int use_inout, int toggle_audio, int loop_play, float speed) { + if( !playable ) return; PlaybackEngine *engine = zgui->playback_engine; engine->next_command->toggle_audio = toggle_audio; engine->next_command->loop_play = loop_play; diff --git a/cinelerra-5.1/cinelerra/zwindow.h b/cinelerra-5.1/cinelerra/zwindow.h index 5af5ccd8..ea76bdf4 100644 --- a/cinelerra-5.1/cinelerra/zwindow.h +++ b/cinelerra-5.1/cinelerra/zwindow.h @@ -82,7 +82,7 @@ public: EDL* edl; int idx; - int highlighted; + int highlighted, playable; char title[BCTEXTLEN]; float zoom; }; diff --git a/cinelerra-5.1/cinelerra/zwindowgui.C b/cinelerra-5.1/cinelerra/zwindowgui.C index 6f1f8132..515d41ba 100644 --- a/cinelerra-5.1/cinelerra/zwindowgui.C +++ b/cinelerra-5.1/cinelerra/zwindowgui.C @@ -47,6 +47,7 @@ ZWindowGUI::ZWindowGUI(MWindow *mwindow, ZWindow *zwindow, Mixer *mixer) canvas = 0; playback_engine = 0; highlighted = 0; + playable = zwindow->playable; } ZWindowGUI::~ZWindowGUI() @@ -183,17 +184,40 @@ int ZWindowGUI::draw_overlays() { BC_WindowBase *cvs = canvas->get_canvas(); if( !cvs || cvs->get_video_on() ) return 0; - if( highlighted != zwindow->highlighted ) { - highlighted = zwindow->highlighted; - cvs->set_color(WHITE); - cvs->set_inverse(); - cvs->draw_rectangle(0, 0, cvs->get_w(), cvs->get_h()); - cvs->draw_rectangle(1, 1, cvs->get_w() - 2, cvs->get_h() - 2); - cvs->set_opaque(); - } + set_highlighted(zwindow->highlighted); + if( !playable ) set_playable(-1); return 1; } +void ZWindowGUI::set_highlighted(int v) +{ + if( highlighted == v ) return; + highlighted = v; + BC_WindowBase *cvs = canvas->get_canvas(); + cvs->set_color(WHITE); + cvs->set_inverse(); + cvs->draw_rectangle(0, 0, cvs->get_w(), cvs->get_h()); + cvs->draw_rectangle(1, 1, cvs->get_w() - 2, cvs->get_h() - 2); + cvs->set_opaque(); +} + +void ZWindowGUI::set_playable(int v) +{ + if( playable == v ) return; + playable = v>0 ? 1 : 0; + zwindow->playable = playable; + BC_WindowBase *cvs = canvas->get_canvas(); + cvs->set_color(WHITE); + cvs->set_inverse(); + int dx = cvs->get_w()/16+1, dy = cvs->get_h()/16+1; + int x = xS(5), y = yS(5), lw = (dx + dy)/16+1; + cvs->set_line_width(lw); + cvs->draw_line(x, y, x+dx, y+dy); + cvs->draw_line(x, y+dy, x+dx, y); + cvs->set_opaque(); + cvs->set_line_width(1); +} + ZWindowCanvasTileMixers::ZWindowCanvasTileMixers(ZWindowCanvas *canvas) : BC_MenuItem(_("Tile Mixers")) @@ -206,6 +230,21 @@ int ZWindowCanvasTileMixers::handle_event() return 1; } +ZWindowCanvasPlayable::ZWindowCanvasPlayable(ZWindowCanvas *canvas) + : BC_MenuItem(_("Playable")) +{ + this->canvas = canvas; + set_checked(canvas->gui->zwindow->playable); +} +int ZWindowCanvasPlayable::handle_event() +{ + int v = !get_checked() ? 1 : 0; + set_checked(v); + canvas->gui->set_playable(v); + canvas->get_canvas()->flash(1); + return 1; +} + ZWindowCanvas::ZWindowCanvas(MWindow *mwindow, ZWindowGUI *gui, int x, int y, int w, int h) : Canvas(mwindow, gui, x,y, w,h, 0,0,0) @@ -218,6 +257,7 @@ void ZWindowCanvas::create_objects(EDL *edl) { Canvas::create_objects(edl); canvas_menu->add_item(new ZWindowCanvasTileMixers(this)); + canvas_menu->add_item(new ZWindowCanvasPlayable(this)); } void ZWindowCanvas::close_source() @@ -257,7 +297,6 @@ void ZWindowCanvas::draw_refresh(int flush) if( gui->draw_overlays() ) dirty = 1; - if( dirty ) cvs->flash(flush); } @@ -306,3 +345,4 @@ void ZWindowCanvas::zoom_resize_window(float zoom) gui->resize_window(new_w, new_h); gui->resize_event(new_w, new_h); } + diff --git a/cinelerra-5.1/cinelerra/zwindowgui.h b/cinelerra-5.1/cinelerra/zwindowgui.h index 5d9d292b..b3fcd698 100644 --- a/cinelerra-5.1/cinelerra/zwindowgui.h +++ b/cinelerra-5.1/cinelerra/zwindowgui.h @@ -50,13 +50,15 @@ public: int cursor_motion_event(); int select_window(int n); int draw_overlays(); + void set_highlighted(int v); + void set_playable(int v); MWindow *mwindow; ZWindow *zwindow; ZWindowCanvas *canvas; PlaybackEngine *playback_engine; - int highlighted; + int highlighted, playable; }; class ZWindowCanvasTileMixers : public BC_MenuItem @@ -67,6 +69,15 @@ public: ZWindowCanvas *canvas; }; +class ZWindowCanvasPlayable : public BC_MenuItem +{ +public: + ZWindowCanvasPlayable(ZWindowCanvas *canvas); + int handle_event(); + ZWindowCanvas *canvas; +}; + + class ZWindowCanvas : public Canvas { public: