From 9ffdfbe8e6fa7daaad4dcfdd46b6ac7b6e7a47e8 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Sun, 28 Jun 2020 20:20:34 -0600 Subject: [PATCH] improve delays created by vicon drawing locks, reset_cache segv fix, gang track tooltip tweak, shift track zoom sets default, resize mwindow ffmpeg/shbtn position fix, fix x10tv init malloc abort, add BC_TRACE_XERROR stack trace --- cinelerra-5.1/cinelerra/awindowgui.C | 29 +++++++++++++------------- cinelerra-5.1/cinelerra/awindowgui.h | 5 ++--- cinelerra-5.1/cinelerra/editpanel.C | 10 ++++++++- cinelerra-5.1/cinelerra/editpanel.h | 1 + cinelerra-5.1/cinelerra/edl.inc | 1 + cinelerra-5.1/cinelerra/localsession.C | 4 ++-- cinelerra-5.1/cinelerra/mwindow.C | 9 +++++--- cinelerra-5.1/cinelerra/mwindowgui.C | 2 +- cinelerra-5.1/cinelerra/mwindowmove.C | 16 ++++++-------- cinelerra-5.1/cinelerra/x10tv.C | 2 +- cinelerra-5.1/cinelerra/zoombar.C | 6 ++++++ cinelerra-5.1/guicast/bcsignals.C | 8 +++++++ 12 files changed, 58 insertions(+), 35 deletions(-) diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index a0a2d5cf..d71d1588 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -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() { diff --git a/cinelerra-5.1/cinelerra/awindowgui.h b/cinelerra-5.1/cinelerra/awindowgui.h index 8584049d..aa182f9e 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.h +++ b/cinelerra-5.1/cinelerra/awindowgui.h @@ -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(); diff --git a/cinelerra-5.1/cinelerra/editpanel.C b/cinelerra-5.1/cinelerra/editpanel.C index 4d3f366b..ddc7595a 100644 --- a/cinelerra-5.1/cinelerra/editpanel.C +++ b/cinelerra-5.1/cinelerra/editpanel.C @@ -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() diff --git a/cinelerra-5.1/cinelerra/editpanel.h b/cinelerra-5.1/cinelerra/editpanel.h index a8104612..9adbaf62 100644 --- a/cinelerra-5.1/cinelerra/editpanel.h +++ b/cinelerra-5.1/cinelerra/editpanel.h @@ -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(); diff --git a/cinelerra-5.1/cinelerra/edl.inc b/cinelerra-5.1/cinelerra/edl.inc index 9f08c29b..ff56d686 100644 --- a/cinelerra-5.1/cinelerra/edl.inc +++ b/cinelerra-5.1/cinelerra/edl.inc @@ -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 diff --git a/cinelerra-5.1/cinelerra/localsession.C b/cinelerra-5.1/cinelerra/localsession.C index c8cd9041..47d86c28 100644 --- a/cinelerra-5.1/cinelerra/localsession.C +++ b/cinelerra-5.1/cinelerra/localsession.C @@ -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); diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 49709028..702bd8a7 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -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 *drag_assets, ArrayList *drag_clips) { - awindow->gui->stop_vicon_drawing(); + awindow->gui->stop_vicon_drawing(1); // Remove from VWindow. if( drag_clips ) { diff --git a/cinelerra-5.1/cinelerra/mwindowgui.C b/cinelerra-5.1/cinelerra/mwindowgui.C index c90acab7..9c3dc9d8 100644 --- a/cinelerra-5.1/cinelerra/mwindowgui.C +++ b/cinelerra-5.1/cinelerra/mwindowgui.C @@ -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()); diff --git a/cinelerra-5.1/cinelerra/mwindowmove.C b/cinelerra-5.1/cinelerra/mwindowmove.C index 2ee2a70a..2c0479bb 100644 --- a/cinelerra-5.1/cinelerra/mwindowmove.C +++ b/cinelerra-5.1/cinelerra/mwindowmove.C @@ -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; ilocal_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; ilocal_session->track_start[i] = diff --git a/cinelerra-5.1/cinelerra/x10tv.C b/cinelerra-5.1/cinelerra/x10tv.C index d97b7453..ee7438bb 100644 --- a/cinelerra-5.1/cinelerra/x10tv.C +++ b/cinelerra-5.1/cinelerra/x10tv.C @@ -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); } diff --git a/cinelerra-5.1/cinelerra/zoombar.C b/cinelerra-5.1/cinelerra/zoombar.C index 2d374014..5171469d 100644 --- a/cinelerra-5.1/cinelerra/zoombar.C +++ b/cinelerra-5.1/cinelerra/zoombar.C @@ -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; } diff --git a/cinelerra-5.1/guicast/bcsignals.C b/cinelerra-5.1/guicast/bcsignals.C index ffc8a1c1..779d7e40 100644 --- a/cinelerra-5.1/guicast/bcsignals.C +++ b/cinelerra-5.1/guicast/bcsignals.C @@ -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; } -- 2.26.2