improve delays created by vicon drawing locks, reset_cache segv fix, gang track toolt...
authorGood Guy <[email protected]>
Mon, 29 Jun 2020 02:20:34 +0000 (20:20 -0600)
committerGood Guy <[email protected]>
Mon, 29 Jun 2020 02:20:34 +0000 (20:20 -0600)
12 files changed:
cinelerra-5.1/cinelerra/awindowgui.C
cinelerra-5.1/cinelerra/awindowgui.h
cinelerra-5.1/cinelerra/editpanel.C
cinelerra-5.1/cinelerra/editpanel.h
cinelerra-5.1/cinelerra/edl.inc
cinelerra-5.1/cinelerra/localsession.C
cinelerra-5.1/cinelerra/mwindow.C
cinelerra-5.1/cinelerra/mwindowgui.C
cinelerra-5.1/cinelerra/mwindowmove.C
cinelerra-5.1/cinelerra/x10tv.C
cinelerra-5.1/cinelerra/zoombar.C
cinelerra-5.1/guicast/bcsignals.C

index a0a2d5cfde8499e2f5024820fc1c0ef9bfdaf203..d71d1588715e1e58e4d0f69028d38c5ba95e3edc 100644 (file)
@@ -29,8 +29,9 @@
 #include "awindow.h"
 #include "awindowgui.h"
 #include "bccmodels.h"
-#include "bcsignals.h"
 #include "bchash.h"
+#include "bcsignals.h"
+#include "bctimer.h"
 #include "binfolder.h"
 #include "cache.h"
 #include "cstrdup.h"
@@ -170,6 +171,8 @@ VFrame *AssetVIcon::frame()
                if( !temp )
                        temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
                File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
+               if( !file ) { broken = 1;  return 0; }
+               Timer timer;
                while( file && seq_no >= images.size() && !avt->interrupted ) {
                        int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
                        file->set_video_position(pos,0);
@@ -177,14 +180,15 @@ VFrame *AssetVIcon::frame()
                        if( file->read_frame(temp) ) temp->clear_frame();
                        add_image(temp, vw, vh, vicon_cmodel);
                        mwindow->video_cache->check_in(asset);
+                       if( timer.get_difference() > 500 ) return 0;
                        Thread::yield();
-                       file = 0;
-                       for( int retries=1000; !file && --retries>=0; usleep(10000) ) {
+                       file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
+                       for( int retries=10; !file && --retries>=0; usleep(1000) ) {
                                if( avt->interrupted ) return 0;
                                file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
                        }
+                       if( !file ) return 0;
                }
-               if( !file ) { broken = 1;  return 0; }
                mwindow->video_cache->check_in(asset);
        }
        if( seq_no >= images.size() ) return 0;
@@ -684,11 +688,13 @@ ViewPopup *AssetVIconThread::new_view_window(ViewPopup *vpopup)
        return av_popup;
 }
 
-void AssetVIconThread::close_view_popup()
+void AssetVIconThread::stop_vicon_drawing(int wait)
 {
        stop_drawing();
-       drawing_started(); // waits for draw lock
-       drawing_stopped();
+       if( wait ) {
+               drawing_started(); // waits for draw lock
+               drawing_stopped();
+       }
 }
 
 
@@ -1698,17 +1704,12 @@ int AWindowGUI::start_vicon_drawing()
        return 1;
 }
 
-int AWindowGUI::stop_vicon_drawing()
+int AWindowGUI::stop_vicon_drawing(int wait)
 {
-       if( !vicon_thread->interrupted )
-               vicon_thread->stop_drawing();
+       vicon_thread->stop_vicon_drawing(wait);
        return 0;
 }
 
-void AWindowGUI::close_view_popup()
-{
-       vicon_thread->close_view_popup();
-}
 
 VFrame *AssetPicon::get_vicon_frame()
 {
index 8584049de27b3e37d829809fffef8c9c599f6aa4..aa182f9ecf57eb1c6aef9206ba8b400bc3be16ad 100644 (file)
@@ -208,9 +208,9 @@ public:
        void set_view_popup(AssetVIcon *v, int draw_mode);
        void set_view_popup(AssetVIcon *v);
        ViewPopup *new_view_window(ViewPopup *popup);
+       void stop_vicon_drawing(int wait=0);
        void drawing_started();
        void drawing_stopped();
-       void close_view_popup();
 
        AWindowGUI *gui;
        int draw_mode;
@@ -288,8 +288,7 @@ public:
        int save_defaults(BC_Hash *defaults);
        int load_defaults(BC_Hash *defaults);
        int start_vicon_drawing();
-       int stop_vicon_drawing();
-       void close_view_popup();
+       int stop_vicon_drawing(int wait=0);
        void update_picon(Indexable *indexable);
        int cycle_assetlist_format();
        void hide_tip_info();
index 4d3f366b744f6e655c6ce3cf3322290d8b2514f6..ddc7595a82ab269c5a91175d0f4879a3a33353b9 100644 (file)
@@ -1314,13 +1314,20 @@ int EditPanelScope::handle_event()
        return 1;
 }
 
+const char *EditPanelGangTracks::gang_tips[TOTAL_GANGS] = {
+       N_("Currently: Gang None\n  Click to: Gang Channels"),
+       N_("Currently: Gang Channels\n  Click to: Gang Media"),
+       N_("Currently: Gang Media\n  Click to: Gang None"),
+};
+
 EditPanelGangTracks::EditPanelGangTracks(MWindow *mwindow, EditPanel *panel,
                int x, int y)
  : BC_Button(x, y, get_images(mwindow))
 {
        this->mwindow = mwindow;
        this->panel = panel;
-       set_tooltip(_("Gang Tracks"));
+       int gang = mwindow->edl->session->gang_tracks;
+       set_tooltip(_(gang_tips[gang]));
 }
 
 EditPanelGangTracks::~EditPanelGangTracks()
@@ -1342,6 +1349,7 @@ void EditPanelGangTracks::update(int gang)
 {
        set_images(gang_images[gang]);
        draw_face();
+       set_tooltip(_(gang_tips[gang]));
 }
 
 int EditPanelGangTracks::handle_event()
index a8104612ba1b37a8aff4f835390ae42750e10e93..9adbaf62b567be40dc2c015ff9f7ebf45a211b4b 100644 (file)
@@ -382,6 +382,7 @@ public:
 class EditPanelGangTracks : public BC_Button
 {
        static VFrame **gang_images[TOTAL_GANGS];
+       static const char *gang_tips[TOTAL_GANGS];
 public:
        EditPanelGangTracks(MWindow *mwindow, EditPanel *panel, int x, int y);
        ~EditPanelGangTracks();
index 9f08c29b6dce0764f88dd62c52764248bbfbd9d5..ff56d686877ff6244529ea407acd07044304a67a 100644 (file)
@@ -158,6 +158,7 @@ class EDL;
 #define MIN_ZOOM_TIME 1
 #define MAX_ZOOM_TIME 0x100000
 #define DEFAULT_ZOOM_TIME 1024
+#define DEFAULT_ZOOM_TRACK 64
 #define MIN_AMP_ZOOM 8
 #define MAX_AMP_ZOOM 8192
 #define MIN_TRACK_ZOOM 8
index c8cd9041a8019711706d96e4f8418870b757e92b..47d86c28f239cc4113423667d66c3d57d043f35d 100644 (file)
@@ -347,9 +347,9 @@ int LocalSession::load_defaults(BC_Hash *defaults)
 //     track_start = defaults->get("TRACK_START", 0);
 //     view_start = defaults->get("VIEW_START", 0);
        zoom_sample = defaults->get("ZOOM_SAMPLE", DEFAULT_ZOOM_TIME);
-       zoom_y = defaults->get("ZOOMY", 64);
+       zoom_y = defaults->get("ZOOMY", DEFAULT_ZOOM_TRACK);
        int64_t zoom_track = defaults->get("ZOOM_TRACK", 0);
-       if( zoom_track == 0 ) zoom_track = 64;
+       if( zoom_track == 0 ) zoom_track = DEFAULT_ZOOM_TRACK;
        zoom_atrack = defaults->get("ZOOM_ATRACK", zoom_track);
        zoom_vtrack = defaults->get("ZOOM_VTRACK", zoom_track);
        red = defaults->get("RED", 0.0);
index 49709028846b0a50f886a8a9d4fbc5130f838df2..702bd8a7c6fde6bb0aaa68bbe0354f74b607efd2 100644 (file)
@@ -4465,7 +4465,9 @@ int MWindow::create_aspect_ratio(float &w, float &h, int width, int height)
 
 void MWindow::reset_caches()
 {
-       awindow->gui->stop_vicon_drawing();
+       int locked  = gui->get_window_lock();
+       if( locked ) gui->unlock_window();
+       awindow->gui->stop_vicon_drawing(1);
        frame_cache->remove_all();
        wave_cache->remove_all();
        audio_cache->remove_all();
@@ -4485,11 +4487,12 @@ void MWindow::reset_caches()
                if( vwindow->playback_engine->video_cache )
                        vwindow->playback_engine->video_cache->remove_all();
        }
+       if( locked ) gui->lock_window("MWindow::reset_caches");
 }
 
 void MWindow::remove_from_caches(Indexable *idxbl)
 {
-       awindow->gui->stop_vicon_drawing();
+       awindow->gui->stop_vicon_drawing(1);
        frame_cache->remove_item(idxbl);
        wave_cache->remove_item(idxbl);
        if( gui->render_engine &&
@@ -4529,7 +4532,7 @@ void MWindow::remove_from_caches(Indexable *idxbl)
 void MWindow::remove_assets_from_project(int push_undo, int redraw, int delete_indexes,
                ArrayList<Indexable*> *drag_assets, ArrayList<EDL*> *drag_clips)
 {
-       awindow->gui->stop_vicon_drawing();
+       awindow->gui->stop_vicon_drawing(1);
 
 // Remove from VWindow.
        if( drag_clips ) {
index c90acab712b75130c88b011d4a7105bf81276177..9c3dc9d8fa0b5df2798f9bcbbe648ad7d0cbc1cb 100644 (file)
@@ -316,7 +316,7 @@ int MWindowGUI::resize_event(int w, int h)
 //printf("MWindowGUI::resize_event %d\n", __LINE__);
        mwindow->session->mwindow_w = w;
        mwindow->session->mwindow_h = h;
-       int x1 = get_w() - MainShBtns::calculate_w(-1, 0, -1) - xS(5);
+       int x1 = w - MainShBtns::calculate_w(-1, 0, -1) - xS(5);
        mainshbtns->reposition_window(x1, -1);
        int x2 = x1 - mwindow->theme->stack_button_w - xS(5);
        stack_button->reposition_window(x2, stack_button->get_y());
index 2ee2a70a2bd4863f26b6d5cad6035fbbcce17e4d..2c0479bb947953c8f1383ea1035831ce999498f2 100644 (file)
@@ -356,17 +356,13 @@ void MWindow::zoom_amp(int64_t zoom_amp)
 void MWindow::zoom_atrack(int64_t zoom)
 {
        int64_t old_zoom = edl->local_session->zoom_atrack;
-// scale waveforms
-       edl->local_session->zoom_y = (int64_t)((float)edl->local_session->zoom_y *
-                       zoom / old_zoom);
-       CLAMP(edl->local_session->zoom_y, MIN_AMP_ZOOM, MAX_AMP_ZOOM);
+       CLAMP(zoom, MIN_TRACK_ZOOM, MAX_TRACK_ZOOM);
+       edl->local_session->zoom_atrack = zoom;
 
-// scale tracks
        edl->local_session->zoom_atrack = zoom;
        for( Track *track= edl->tracks->first; track; track=track->next ) {
                if( track->data_type != TRACK_AUDIO ) continue;
-               track->data_h = track->data_h * zoom / old_zoom;
-               bclamp(track->data_h, MIN_TRACK_ZOOM, MAX_TRACK_ZOOM);
+               track->data_h = zoom;
        }
 // shift row position
        for( int i=0; i<TOTAL_PANES; ++i ) edl->local_session->track_start[i] =
@@ -378,12 +374,12 @@ void MWindow::zoom_atrack(int64_t zoom)
 void MWindow::zoom_vtrack(int64_t zoom)
 {
        int64_t old_zoom = edl->local_session->zoom_vtrack;
-// scale tracks
+       CLAMP(zoom, MIN_TRACK_ZOOM, MAX_TRACK_ZOOM);
        edl->local_session->zoom_vtrack = zoom;
+
        for( Track *track= edl->tracks->first; track; track=track->next ) {
                if( track->data_type != TRACK_VIDEO ) continue;
-               track->data_h = track->data_h * zoom / old_zoom;
-               bclamp(track->data_h, MIN_TRACK_ZOOM, MAX_TRACK_ZOOM);
+               track->data_h = zoom;
        }
 // shift row position
        for( int i=0; i<TOTAL_PANES; ++i ) edl->local_session->track_start[i] =
index d97b7453c18cda2e062c0f805876b089e6fcbe60..ee7438bbf368429e6e4fe209ccc5502f07ce3426 100644 (file)
@@ -118,7 +118,7 @@ X10TV *X10TV::probe(MWindow *mwindow)
 {
        int ver = -1, ifds[16];
        int nfds = open_usb_inputs(0x0bc7, 0x0004, ver, ifds, 16);
-       if( !nfds ) return 0;
+       if( nfds <= 0 ) return 0;
        printf("detected ATI X10 remote, ver=0x%04x\n", ver);
        return new X10TV(mwindow, ifds, nfds);
 }
index 2d37401413f8d429f660b778a7f5b098b353b4cc..5171469d3f1e0a6e9fc77917da01b583cb7b33a8 100644 (file)
@@ -388,6 +388,8 @@ AmpZoomPanel::AmpZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
 }
 int AmpZoomPanel::handle_event()
 {
+       if( zoombar->shift_down() )
+               update(DEFAULT_ZOOM_TRACK);
        mwindow->zoom_amp((int64_t)get_value());
        return 1;
 }
@@ -401,6 +403,8 @@ ATrackZoomPanel::ATrackZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int
 }
 int ATrackZoomPanel::handle_event()
 {
+       if( zoombar->shift_down() )
+               update(DEFAULT_ZOOM_TRACK);
        mwindow->zoom_atrack((int64_t)get_value());
        zoombar->amp_zoom->update(mwindow->edl->local_session->zoom_y);
        return 1;
@@ -415,6 +419,8 @@ VTrackZoomPanel::VTrackZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int
 }
 int VTrackZoomPanel::handle_event()
 {
+       if( zoombar->shift_down() )
+               update(DEFAULT_ZOOM_TRACK);
        mwindow->zoom_vtrack((int64_t)get_value());
        return 1;
 }
index ffc8a1c156d4062adb38c80846620cb2f9e00080..779d7e40922ff8919bc2e190ce2dea1fee967f20 100644 (file)
@@ -313,6 +313,8 @@ BC_Signals::~BC_Signals()
 }
 
 
+int dump_xerror = -1;
+
 int BC_Signals::x_error_handler(Display *display, XErrorEvent *event)
 {
        char string[1024];
@@ -320,6 +322,12 @@ int BC_Signals::x_error_handler(Display *display, XErrorEvent *event)
        fprintf(stderr, "BC_Signals::x_error_handler: error_code=%d opcode=%d,%d id=0x%jx %s\n",
                event->error_code, event->request_code, event->minor_code,
                (int64_t)event->resourceid, string);
+       if( dump_xerror < 0 ) {
+               char *env = getenv("BC_TRACE_XERROR");
+               dump_xerror = !env || !atoi(env) ? 0 : 1;
+       }
+       if( dump_xerror )
+               dump_stack();
        return 0;
 }