From: Good Guy Date: Sat, 23 Apr 2016 22:19:37 +0000 (-0600) Subject: pluginclient delete window bug/segv + cleanups/improvements X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=c76ba7b82b876025995364912d35f300a59ec200;p=goodguy%2Fhistory.git pluginclient delete window bug/segv + cleanups/improvements --- diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile index 84cbb729..11af0932 100644 --- a/cinelerra-5.1/cinelerra/Makefile +++ b/cinelerra-5.1/cinelerra/Makefile @@ -470,6 +470,9 @@ tags: $(OBJDIR)/%.o: %.C $(CXX) `cat $(OBJDIR)/c_flags` -c $< -o $@ +$(OBJDIR)/sha1.o: sha1.C sha1.h + $(CXX) `cat $(OBJDIR)/c_flags` -O3 -c $< -o $@ + $(DCRAW): dcraw.c $(GCC) `cat $(OBJDIR)/c_flags` dcraw.c -o $*.o diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index b9615c1f..98736302 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -119,11 +119,17 @@ #include "defaultformats.h" #include "ntsczones.h" -#include -#include +#include +#include +#include #include #include +#include #include +#include +#include +#include +#include extern "C" @@ -3107,37 +3113,50 @@ void MWindow::dump_exe(FILE *fp) { char proc_path[BCTEXTLEN], exe_path[BCTEXTLEN]; sprintf(proc_path, "/proc/%d/exe", (int)getpid()); - int len = readlink(proc_path, exe_path, sizeof(exe_path)); - if( len < 0 ) { fprintf(fp,"readlink: %m\n"); return; } - exe_path[len] = 0; + int ret = readlink(proc_path, exe_path, sizeof(exe_path)); + if( ret < 0 ) { fprintf(fp,"readlink: %m\n"); return; } + exe_path[ret] = 0; struct stat st; if( stat(exe_path,&st) ) { fprintf(fp,"stat: %m\n"); return; } fprintf(fp, "path: %s = %9jd bytes\n",exe_path,st.st_size); - int fd = open(exe_path,O_RDONLY); + int fd = open(exe_path,O_RDONLY+O_NONBLOCK); if( fd < 0 ) { fprintf(fp,"open: %m\n"); return; } - uint8_t buf[65536]; SHA1 sha1; - while( (len=read(fd,buf,sizeof(buf))) > 0 ) { - sha1.addBytes(buf, len); + uint8_t *bfr = 0; + int64_t bfrsz = 0; + int64_t pagsz = sysconf(_SC_PAGE_SIZE); + int64_t maxsz = 1024*pagsz; + int64_t size = st.st_size, pos = 0; + SHA1 sha1; + while( (bfrsz = size-pos) > 0 ) { + if( bfrsz > maxsz ) bfrsz = maxsz; + bfr = (uint8_t *)mmap(NULL, bfrsz, PROT_READ, + MAP_PRIVATE+MAP_NORESERVE+MAP_POPULATE, fd, pos); + if( bfr == MAP_FAILED ) break; + sha1.addBytes(bfr, bfrsz); + munmap(bfr, bfrsz); + pos += bfrsz; } close(fd); + ret = pos < size ? EIO : 0; fprintf(fp, "SHA1: "); uint8_t digest[20]; sha1.computeHash(digest); for( int i=0; i<20; ++i ) fprintf(fp, "%02x", digest[i]); + if( ret < 0 ) fprintf(fp, " (ret %d)", ret); + if( pos < st.st_size ) fprintf(fp, " (pos %jd)", pos); fprintf(fp, "\n"); } - void MWindow::trap_hook(FILE *fp, void *vp) { MWindow *mwindow = (MWindow *)vp; - fprintf(fp, "\nEXE:\n"); - mwindow->dump_exe(fp); - fprintf(fp, "\nPLUGINS:\n"); - mwindow->dump_plugins(fp); +// fprintf(fp, "\nPLUGINS:\n"); +// mwindow->dump_plugins(fp); fprintf(fp, "\nEDL:\n"); mwindow->dump_edl(fp); fprintf(fp, "\nUNDO:\n"); mwindow->dump_undo(fp); + fprintf(fp, "\nEXE:\n"); + mwindow->dump_exe(fp); } @@ -3400,7 +3419,7 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra int result = file->open_file(preferences, asset, 1, 0); if( !result && delete_tracks > 0 ) undo->update_undo_before(); - if( !result && asset->get_video_layers() > 0 ) { + if( !result && asset->video_data && asset->get_video_layers() > 0 ) { // try to get asset up to date, may fail file->select_video_stream(asset, vstream); // either way use what was/is there. @@ -3452,14 +3471,16 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra } edl->resample(old_framerate, session->frame_rate, TRACK_VIDEO); } - if( !result && asset->channels > 0 ) { + if( !result && asset->audio_data && asset->channels > 0 ) { session->sample_rate = asset->get_sample_rate(); int64_t channel_mask = 0; - int astrm = file->get_audio_for_video(vstream, astream, channel_mask); + int astrm = !asset->video_data ? -1 : + file->get_audio_for_video(vstream, astream, channel_mask); if( astrm >= 0 ) file->select_audio_stream(asset, astrm); if( astrm < 0 || !channel_mask ) channel_mask = (1<channels)-1; int channels = 0; for( uint64_t mask=channel_mask; mask!=0; mask>>=1 ) channels += mask & 1; + if( channels < 1 ) channels = 1; if( channels > 6 ) channels = 6; session->audio_tracks = session->audio_channels = channels; switch( channels ) { @@ -3475,6 +3496,15 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra session->achannel_positions[0] = 180; session->achannel_positions[1] = 0; break; + case 1: + session->achannel_positions[1] = 90; + break; + default: { + if( !channels ) break; + double t = 0, dt = 360./channels; + for( int i=channels; --i>=0; t+=dt ) + session->achannel_positions[i] = int(t+0.5); + break; } } remap_audio(MWindow::AUDIO_1_TO_1); @@ -3510,6 +3540,8 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra int MWindow::select_asset(int vtrack, int delete_tracks) { Track *track = edl->tracks->get(vtrack, TRACK_VIDEO); + if( !track ) + track = edl->tracks->get(vtrack, TRACK_AUDIO); if( !track ) return 1; Edit *edit = track->edits->first; if( !edit ) return 1; diff --git a/cinelerra-5.1/cinelerra/pluginclient.C b/cinelerra-5.1/cinelerra/pluginclient.C index cccdcde0..096d03e3 100644 --- a/cinelerra-5.1/cinelerra/pluginclient.C +++ b/cinelerra-5.1/cinelerra/pluginclient.C @@ -55,8 +55,9 @@ PluginClientThread::PluginClientThread(PluginClient *client) PluginClientThread::~PluginClientThread() { -//printf("PluginClientThread::~PluginClientThread %p %d\n", this, __LINE__); join(); +//printf("PluginClientThread::~PluginClientThread %p %d\n", this, __LINE__); + delete window; window = 0; //printf("PluginClientThread::~PluginClientThread %p %d\n", this, __LINE__); delete init_complete; } @@ -67,10 +68,10 @@ void PluginClientThread::run() int result = 0; if(client->window_x < 0) client->window_x = info.get_abs_cursor_x(); if(client->window_y < 0) client->window_y = info.get_abs_cursor_y(); - window = client->new_window(); + if(!window) + window = client->new_window(); - if(window) - { + if(window) { window->lock_window("PluginClientThread::run"); window->create_objects(); window->unlock_window(); @@ -84,7 +85,6 @@ void PluginClientThread::run() //printf("PluginClientThread::run %p %d\n", this, __LINE__); window->hide_window(1); window->unlock_window(); - delete window; window = 0; // Can't save defaults in the destructor because it's not called immediately // after closing. /* if(client->defaults) */ client->save_defaults_xml(); @@ -658,12 +658,6 @@ int PluginClient::get_gui_status() return server->get_gui_status(); } -int PluginClient::start_plugin() -{ - printf(_("No processing defined for this plugin.\n")); - return 0; -} - // close event from client side void PluginClient::client_side_close() { diff --git a/cinelerra-5.1/cinelerra/pluginclient.h b/cinelerra-5.1/cinelerra/pluginclient.h index da684b4f..9f5b10c2 100644 --- a/cinelerra-5.1/cinelerra/pluginclient.h +++ b/cinelerra-5.1/cinelerra/pluginclient.h @@ -241,7 +241,6 @@ public: // For realtime plugins give the requested framerate. virtual double get_framerate(); virtual int delete_nonrealtime_parameters(); - virtual int start_plugin(); // run a non realtime plugin virtual int get_parameters(); // get information from user before non realtime processing virtual int64_t get_in_buffers(int64_t recommended_size); // return desired size for input buffers virtual int64_t get_out_buffers(int64_t recommended_size); // return desired size for output buffers diff --git a/cinelerra-5.1/cinelerra/pluginfclient.C b/cinelerra-5.1/cinelerra/pluginfclient.C index 1bea7dd0..fdafc29e 100644 --- a/cinelerra-5.1/cinelerra/pluginfclient.C +++ b/cinelerra-5.1/cinelerra/pluginfclient.C @@ -76,6 +76,7 @@ void PluginFClientConfig::interpolate(PluginFClientConfig &prev, PluginFClientCo void PluginFClientConfig::initialize(const char *name) { + delete ffilt; ffilt = PluginFFilter::new_ffilter(name); const AVOption *opt = 0; void *obj = ffilt->filter_config(); @@ -154,7 +155,7 @@ PluginFClientReset:: int PluginFClientReset::handle_event() { - av_opt_set_defaults(fwin->ffmpeg->config.filter_config()); + fwin->ffmpeg->config.initialize(fwin->ffmpeg->name); if( fwin->ffmpeg->config.update() > 0 ) fwin->draw(); fwin->ffmpeg->plugin->send_configure_change(); diff --git a/cinelerra-5.1/cinelerra/pluginfclient.h b/cinelerra-5.1/cinelerra/pluginfclient.h index 781e2523..4d112568 100644 --- a/cinelerra-5.1/cinelerra/pluginfclient.h +++ b/cinelerra-5.1/cinelerra/pluginfclient.h @@ -232,7 +232,7 @@ public: int activate(); void reactivate(); - PluginFClientConfig curr_config, av_config; + PluginFClientConfig curr_config; PLUGIN_CLASS_MEMBERS(PluginFClientConfig) }; diff --git a/cinelerra-5.1/cinelerra/sha1.C b/cinelerra-5.1/cinelerra/sha1.C index ad5becf8..17471f94 100644 --- a/cinelerra-5.1/cinelerra/sha1.C +++ b/cinelerra-5.1/cinelerra/sha1.C @@ -3,10 +3,24 @@ void SHA1::addBytes(const uint8_t* input, size_t length) { - while (length--) { - m_buffer[m_cursor++] = *input++; - ++m_totalBytes; - if (m_cursor == 64) processBlock(); + m_totalBytes += length; + while (length > 0) { +#if 1 +// allow unaliged access + uint64_t *buf = (uint64_t*)&m_buffer[m_cursor]; + const uint64_t *inp = (const uint64_t*)input; + while (length >= sizeof(uint64_t) && m_cursor < 64) { + *buf++ = *inp++; + m_cursor += sizeof(uint64_t); + length -= sizeof(uint64_t); + } + input = (const uint8_t *)inp; +#endif + while (length > 0 && m_cursor < 64) { + m_buffer[m_cursor++] = *input++; + --length; + } + if( m_cursor >= 64 ) processBlock(); } } diff --git a/cinelerra-5.1/guicast/thread.C b/cinelerra-5.1/guicast/thread.C index 3d817272..355d23d5 100644 --- a/cinelerra-5.1/guicast/thread.C +++ b/cinelerra-5.1/guicast/thread.C @@ -316,7 +316,7 @@ void Thread::dump_threads(FILE *fp) { int i = thread_list.size(); while( --i >= 0 ) { - fprintf(fp, "thread %016lx, owner %016lx, %s\n", + fprintf(fp, "thread 0x%012lx, owner 0x%012lx, %s\n", (unsigned long)thread_list[i]->tid, (unsigned long)thread_list[i]->owner, thread_list[i]->name); } diff --git a/cinelerra-5.1/plugins/denoise/denoise.C b/cinelerra-5.1/plugins/denoise/denoise.C index 8aa7ed7d..063a23f4 100644 --- a/cinelerra-5.1/plugins/denoise/denoise.C +++ b/cinelerra-5.1/plugins/denoise/denoise.C @@ -618,7 +618,7 @@ Tree::~Tree() int i; for (i = 2 * levels - 1; i >= 0; i--) - delete values[i]; + delete [] values[i]; delete values; }