mixer enable playback, home/end fixes, stop throw with exrlist missing file
authorGood Guy <good1.2guy@gmail.com>
Fri, 20 Mar 2020 23:04:59 +0000 (17:04 -0600)
committerGood Guy <good1.2guy@gmail.com>
Fri, 20 Mar 2020 23:04:59 +0000 (17:04 -0600)
12 files changed:
cinelerra-5.1/cinelerra/fileexr.C
cinelerra-5.1/cinelerra/playbackengine.C
cinelerra-5.1/cinelerra/playbackengine.h
cinelerra-5.1/cinelerra/renderengine.C
cinelerra-5.1/cinelerra/tracking.C
cinelerra-5.1/cinelerra/tracking.h
cinelerra-5.1/cinelerra/transportque.C
cinelerra-5.1/cinelerra/transportque.h
cinelerra-5.1/cinelerra/zwindow.C
cinelerra-5.1/cinelerra/zwindow.h
cinelerra-5.1/cinelerra/zwindowgui.C
cinelerra-5.1/cinelerra/zwindowgui.h

index e84ef84d4bcc68987942b1d035b05575f91c16ee..2a54f3ed7ad668a7de36e682336a3f3c0f40b4fd 100644 (file)
@@ -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();
index 83bd3efa9027cbc000f2436c9f86d4d381a58682..8ce98234c3ffc7ed2b0ed6e4c00b4f6e3fa749ee 100644 (file)
@@ -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)
index c82d35083daaa33014d0d315a8455b343656127c..ee27ff19a4b55e4ddf1db4250d7655c2f8ddc02f 100644 (file)
@@ -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();
index ed991791f4e147e901da032af26dda5b89bab6e0..dd03089cd97521690c16485180e0c7df1ab9db27 100644 (file)
@@ -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();
index 4ba197e5cec27c5e9054a90639fc9431adab38e7..102178e6355a5f852b8b73a9628614de685da5ba 100644 (file)
@@ -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)
index 71fd582f85056cebd4f3645800e37dc837c713bc..556afecff67d71d2ca19149c5b5b30ba30397179 100644 (file)
@@ -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
index 5b3a3762a5abfb71355d4bc8ae4debf2236ad0cb..a8c1fb9297b065c1000afa793c2cc6f9f5046f4a 100644 (file)
@@ -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 )
index fd5a5cc4732e181591500ad7e0ecc1fc8d090901..2594594ff7a4723b180b8d84d023cdc64b134a3f 100644 (file)
@@ -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
index 62a98cc048441662d79bfcf0bd56a75a28eae5d6..a833b284fbf09c5ad866d27f22833a4cb91c984f 100644 (file)
@@ -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;
index 5af5ccd86d90a356eddbc7900cd23652e7aeae47..ea76bdf45aaea24ffa0524f033be6981a6156752 100644 (file)
@@ -82,7 +82,7 @@ public:
        EDL* edl;
 
        int idx;
-       int highlighted;
+       int highlighted, playable;
        char title[BCTEXTLEN];
        float zoom;
 };
index 6f1f8132848bfc62b8115c46640c30c445230a8c..515d41ba047d55ade72ef7f8b3ff53f82e9bb478 100644 (file)
@@ -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);
 }
+
index 5d9d292b6d589e4ae1f982ab850cb0093e2014d6..b3fcd698f2457377c43cc09e84750fa1f8449c31 100644 (file)
@@ -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: