several bug fixes and minor feature changes:
authorGood Guy <[email protected]>
Sun, 21 Jun 2015 21:19:03 +0000 (15:19 -0600)
committerGood Guy <[email protected]>
Sun, 21 Jun 2015 21:19:03 +0000 (15:19 -0600)
vwindow close while playback active
format tools segv in preferences
1 frame video files are stretchable
opengl deadlocks reworked
added kernel version to dmp file
better dialog thread cleanup

cinelerra-5.0/cinelerra/file.C
cinelerra-5.0/cinelerra/formattools.C
cinelerra-5.0/cinelerra/main.C
cinelerra-5.0/cinelerra/mwindow.C
cinelerra-5.0/cinelerra/vwindowgui.C
cinelerra-5.0/guicast/bcdialog.C
cinelerra-5.0/guicast/bcsignals.C
cinelerra-5.0/guicast/bcsynchronous.C
cinelerra-5.0/guicast/bcsynchronous.h
cinelerra-5.0/guicast/mutex.C

index 5e870d42d5f3c0491aa198c989391a55bd17df71..294c6c6c52bc6f89f55c049ed840c0711135d145 100644 (file)
@@ -795,28 +795,31 @@ int File::open_file(Preferences *preferences,
 // Reopen file with correct parser and get header.
        if(file->open_file(rd, wr)) {
                delete file;
-               file = 0;
+               return FILE_NOT_FOUND;
        }
 
 
 
 // Set extra writing parameters to mandatory settings.
-       if(file && wr) {
+       if( wr ) {
                if(this->asset->dither) file->set_dither();
        }
 
-
+       if( rd ) {
+// one frame image file, no specific length
+               if( !this->asset->audio_data && this->asset->video_data &&
+                   this->asset->video_length == 1 )
+                       this->asset->video_length = -1;
+       }
 
 // Synchronize header parameters
-       if(file) {
-               asset->copy_from(this->asset, 1);
+       asset->copy_from(this->asset, 1);
 //asset->dump();
-       }
 
        if(debug) printf("File::open_file %d file=%p\n", __LINE__, file);
 // sleep(1);
 
-       return file ? FILE_OK : FILE_NOT_FOUND;
+       return FILE_OK;
 }
 
 void File::delete_temp_samples_buffer()
index b27409f96ed9e3ef55ee3188c41e22940d4153d6..0cf493facf096f4e1bfdfbbc1f45e13bd6e74c9b 100644 (file)
@@ -52,10 +52,34 @@ FormatTools::FormatTools(MWindow *mwindow,
        aparams_thread = 0;
        vparams_thread = 0;
        channels_tumbler = 0;
+       audio_switch = 0;
+       video_switch = 0;
        path_textbox = 0;
        path_button = 0;
-       w = window->get_w();
+       format_title = 0;
+       format_button = 0;
+       format_text = 0;
+       audio_title = 0;
+       audio_switch = 0;
+       video_title = 0;
+       video_switch = 0;
+       channels_title = 0;
+       channels_button = 0;
+       multiple_files = 0;
        file_entries = 0;
+       w = window->get_w();
+
+       recording = 0;
+       use_brender = 0;
+       do_audio = 0;
+       do_video = 0;
+       prompt_audio = 0;
+       prompt_audio_channels = 0;
+       prompt_video = 0;
+       prompt_video_compression = 0;
+       strategy = 0;
+       locked_compressor = 0;
+       video_driver = 0;
 }
 
 FormatTools::~FormatTools()
@@ -334,7 +358,7 @@ void FormatTools::update_driver(int driver)
 
 void FormatTools::update_format()
 {
-       if( do_audio && audio_switch ) {
+       if( do_audio && prompt_audio && audio_switch ) {
                asset->audio_data = File::supports_audio(asset->format);
                audio_switch->update(asset->audio_data);
                if( !asset->audio_data )
@@ -342,7 +366,7 @@ void FormatTools::update_format()
                else
                        audio_switch->enable();
        }
-       if( do_video && video_switch ) {
+       if( do_video && prompt_video && video_switch ) {
                asset->video_data = File::supports_video(asset->format);
                video_switch->update(asset->video_data);
                if( !asset->video_data )
@@ -445,8 +469,10 @@ void FormatTools::update(Asset *asset, int *strategy)
        if(path_textbox) 
                path_textbox->update(asset->path);
        format_text->update(File::formattostr(plugindb, asset->format));
-       if(do_audio && audio_switch) audio_switch->update(asset->audio_data);
-       if(do_video && video_switch) video_switch->update(asset->video_data);
+       if(do_audio && prompt_audio && audio_switch)
+               audio_switch->update(asset->audio_data);
+       if(do_video && prompt_video && video_switch)
+               video_switch->update(asset->video_data);
        if(strategy)
        {
                multiple_files->update(strategy);
index de0743ef6954da9c28f54351853d3f702fa530a9..9f9149d8ee9c8f8fb58dffe89fa0f1f191e25fd2 100644 (file)
@@ -404,6 +404,7 @@ COPYRIGHT_DATE);
 // run the program
 //PRINT_TRACE
                                mwindow.start();
+                               mwindow.run();
 //PRINT_TRACE
                                if( mwindow.reload() )
                                        start_remote_control =
index 40a8b4711775bd3e511890f2b8fd4467a743ba88..1a1d4dbae293db9ba4543dc807f828c3c1b40976 100644 (file)
@@ -235,7 +235,6 @@ MWindow::~MWindow()
        hide_keyframe_guis();
        clean_indexes();
        save_defaults();
-
 // Give up and go to a movie
 //  cant run valgrind if this is used
 //     if( !reload_status ) exit(0);
@@ -330,8 +329,7 @@ void MWindow::quit(int unlock)
        interrupt_indexes();
        clean_indexes();
        save_defaults();
-// This is the last thread to exit
-       playback_3d->quit();
+       gui->set_done(0);
        if(unlock) gui->lock_window("MWindow::quit");
 }
 
@@ -1807,7 +1805,7 @@ ENABLE_BUFFER
 //PRINT_TRACE
        gwindow->start();
 //PRINT_TRACE
-       Thread::start();
+//     Thread::start();
 //PRINT_TRACE
        playback_3d->start();
 //PRINT_TRACE
index 8fe9f99b27da9feb5239057d6a2eaae31fb88964..10ad8c87a6d12f8a208dc8b4d69f18dc39710ada 100644 (file)
@@ -79,6 +79,7 @@ VWindowGUI::VWindowGUI(MWindow *mwindow, VWindow *vwindow)
 
 VWindowGUI::~VWindowGUI()
 {
+       vwindow->playback_engine->interrupt_playback(1);
        sources.remove_all_objects();
        labels.remove_all_objects();
        delete canvas;
@@ -405,13 +406,8 @@ void VWindowGUI::drag_motion()
                cursor_y < canvas->y + canvas->h);
 
 
-printf("VWindowGUI::drag_motion 1 %d %d %d %d %d\n", 
-__LINE__, 
-mwindow->session->vcanvas_highlighted,
-get_cursor_over_window(),
-cursor_x,
-cursor_y);
-
+//printf("VWindowGUI::drag_motion 1 %d %d %d %d %d\n", __LINE__, 
+// mwindow->session->vcanvas_highlighted, get_cursor_over_window(), cursor_x, cursor_y);
 
        if(old_status != mwindow->session->vcanvas_highlighted)
                canvas->draw_refresh();
index 9528abbbae1a5fc426affe0c5b3d6bb9cdb4bbbc..b3501477c89bce374dcf01647147ceca1aff96fc 100644 (file)
@@ -46,6 +46,7 @@ BC_DialogThread::~BC_DialogThread()
                gui->unlock_window();
        }
        startup_lock->unlock();
+       cancel();
        join();
 
        delete startup_lock;
index 2610b2c44efb9ddbd22451aef787a7371de2e415..e2a8b149c42659c1744496f814e19c08797ef2aa 100644 (file)
@@ -863,6 +863,7 @@ static void handle_dump(int n, siginfo_t * info, void *sc)
                fprintf(fp,"\nMAIN HOOK:\n");
                BC_Signals::trap_hook(fp, BC_Signals::trap_data);
        }
+       fprintf(fp,"\nVERSION:\n");  bc_copy_textfile(fp,"/proc/version");
        fprintf(fp,"\nMEMINFO:\n");  bc_copy_textfile(fp,"/proc/meminfo");
        fprintf(fp,"\nMAPS:\n");     bc_copy_textfile(fp,"/proc/%d/maps",pid);
        fprintf(fp,"\n\n");
index 4ea90a52b7a9e1f2265df376b765771deb46ab62..671ec0df036733fa9f1b5c1815bb893acca4d438 100644 (file)
@@ -72,97 +72,6 @@ PBufferID::PBufferID(int window_id, GLXPbuffer glx_pbuffer, GLXContext glx_conte
 
 
 
-BC_SynchGarbage::BC_SynchGarbage(BC_Synchronous *synchronous)
- : Thread(1, 0, 0)
-{
-       this->synchronous = synchronous;
-       more_garbage = new Condition(0, "BC_SynchGarbage::more_garbage", 0);
-       garbage_lock = new Mutex("BC_SyncGarbage::garbage_lock");
-       done = -1;
-}
-
-BC_SynchGarbage::~BC_SynchGarbage()
-{
-       if( running() ) {
-               quit();
-               join();
-       }
-       garbage.remove_all_objects();
-       delete more_garbage;
-       delete garbage_lock;
-}
-
-void BC_SynchGarbage::send_garbage(BC_SynchronousCommand *command)
-{
-       garbage_lock->lock("BC_SynchGarbage::send_garbage");
-       garbage.append(command);
-       garbage_lock->unlock();
-       more_garbage->unlock();
-}
-
-void BC_SynchGarbage::handle_garbage()
-{
-       garbage_lock->lock("BC_SynchGarbage::handle_garbage 0");
-       while( !done && garbage.total ) {
-               BC_SynchronousCommand *command = garbage.get(0);
-               garbage.remove_number(0);
-               garbage_lock->unlock();
-
-               switch(command->command) {
-               case BC_SynchronousCommand::QUIT:
-                       done = 1;
-                       break;
-
-               case BC_SynchronousCommand::DELETE_WINDOW:
-                       synchronous->delete_window_sync(command);
-                       break;
-
-               case BC_SynchronousCommand::DELETE_PIXMAP:
-                       synchronous->delete_pixmap_sync(command);
-                       break;
-
-               case BC_SynchronousCommand::DELETE_DISPLAY:
-                       synchronous->delete_display_sync(command);
-                       break;
-               }
-
-               delete command;
-               garbage_lock->lock("BC_SynchGarbage::handle_garbage 1");
-       }
-       garbage_lock->unlock();
-}
-
-
-void BC_SynchGarbage::start()
-{
-       done = 0;
-       Thread::start();
-}
-
-void BC_SynchGarbage::stop()
-{
-       if( running() ) {
-               quit();
-               join();
-       }
-}
-
-void BC_SynchGarbage::quit()
-{
-       BC_SynchronousCommand *command = new BC_SynchronousCommand();
-       command->command = BC_SynchronousCommand::QUIT;
-       send_garbage(command);
-}
-
-void BC_SynchGarbage::run()
-{
-       while( !done ) {
-               more_garbage->lock("BC_SynchGarbage::run");
-               handle_garbage();
-       }
-}
-
-
 BC_SynchronousCommand::BC_SynchronousCommand()
 {
        command = BC_SynchronousCommand::NONE;
@@ -197,12 +106,11 @@ BC_Synchronous::BC_Synchronous()
  : Thread(1, 0, 0)
 {
        lock_sync = new Mutex("BC_Synchronous::lock_sync");
-       sync_garbage = new BC_SynchGarbage(this);
-       next_command = new Condition(0, "BC_Synchronous::next_command", 0);
+       next_command = new Condition(0, "BC_Synchronous::next_command", 1);
        command_lock = new Mutex("BC_Synchronous::command_lock");
        table_lock = new Mutex("BC_Synchronous::table_lock");
        done = 0;
-       is_running = 0;
+       is_started = 0;
        current_window = 0;
        BC_WindowBase::get_resources()->set_synchronous(this);
 }
@@ -214,7 +122,6 @@ BC_Synchronous::~BC_Synchronous()
                join();
        }
        commands.remove_all_objects();
-       delete sync_garbage;
        delete lock_sync;
        delete next_command;
        delete command_lock;
@@ -226,23 +133,11 @@ void BC_Synchronous::sync_lock(const char *cp)
        lock_sync->lock(cp);
 }
 
-void BC_Synchronous::sync_lock(Display *display, const char *cp)
-{
-       // get both display lock and sync_lock
-       XLockDisplay(display);
-       while( lock_sync->trylock(cp) ) {
-               XUnlockDisplay(display);
-               usleep(100000);
-               XLockDisplay(display);
-       }
-}
-
 void BC_Synchronous::sync_unlock()
 {
        lock_sync->unlock();
 }
 
-void sync_unlock();
 BC_SynchronousCommand* BC_Synchronous::new_command()
 {
        return new BC_SynchronousCommand();
@@ -254,18 +149,22 @@ void BC_Synchronous::create_objects()
 
 void BC_Synchronous::start()
 {
-       sync_garbage->start();
-       run();
+       is_started = 1;
+       //run();
+       Thread::start();
 }
 
 void BC_Synchronous::quit()
 {
+       if( !is_started ) return;
+       is_started = 0;
        BC_SynchronousCommand *command = new_command();
        command->command = BC_SynchronousCommand::QUIT;
        command_lock->lock("BC_Synchronous::quit");
        commands.append(command);
        command_lock->unlock();
        next_command->unlock();
+       command->command_done->lock("BC_Synchronous::quit");
 }
 
 long BC_Synchronous::send_command(BC_SynchronousCommand *command)
@@ -287,9 +186,8 @@ long BC_Synchronous::send_command(BC_SynchronousCommand *command)
 
 void BC_Synchronous::run()
 {
-       is_running = 1;
+       sync_lock("BC_Synchronous::run 0");
        while(!done) {
-               next_command->lock("BC_Synchronous::run");
                command_lock->lock("BC_Synchronous::run");
                BC_SynchronousCommand *command = 0;
                if(commands.total) {
@@ -297,28 +195,43 @@ void BC_Synchronous::run()
                        commands.remove_number(0);
                }
                command_lock->unlock();
-               if( !command ) continue;
-
+               if( !command ) {
+                       sync_unlock();
+                       next_command->lock("BC_Synchronous::run");
+                       sync_lock("BC_Synchronous::run 1");
+                       continue;
+               }
 //printf("BC_Synchronous::run %d\n", command->command);
                handle_command_base(command);
        }
-       is_running = 0;
+       sync_unlock();
 }
 
 void BC_Synchronous::handle_command_base(BC_SynchronousCommand *command)
 {
-       sync_lock("BC_Synchronous::handle_command_base");
        switch(command->command) {
        case BC_SynchronousCommand::QUIT:
                done = 1;
                break;
 
+       case BC_SynchronousCommand::DELETE_WINDOW:
+               delete_window_sync(command);
+               break;
+
+       case BC_SynchronousCommand::DELETE_PIXMAP:
+               delete_pixmap_sync(command);
+               break;
+
+       case BC_SynchronousCommand::DELETE_DISPLAY:
+               delete_display_sync(command);
+               break;
+
        default:
                handle_command(command);
                break;
        }
+
        command->command_done->unlock();
-       sync_unlock();
 }
 
 void BC_Synchronous::handle_command(BC_SynchronousCommand *command)
@@ -449,9 +362,6 @@ void BC_Synchronous::dump_shader(unsigned int handle)
        if(!got_it) printf("BC_Synchronous::dump_shader couldn't find %d\n", handle);
 }
 
-// has to run in sync_garbage thread, because mwindow playback_3d
-// thread ends before all windows are deleted.  runs as synchronous
-// command since resources must be freed immediately
 void BC_Synchronous::delete_window(BC_WindowBase *window)
 {
 #ifdef HAVE_GL
@@ -476,7 +386,7 @@ void BC_Synchronous::delete_window_sync(BC_SynchronousCommand *command)
        Window win = command->win;
        GLXWindow glx_win = command->glx_win;
        GLXContext glx_context = command->glx_context;
-       sync_lock(display, "BC_Synchronous::delete_window_sync");
+       XLockDisplay(display);
 //int debug = 0;
 
 // texture ID's are unique to different contexts
@@ -529,7 +439,6 @@ void BC_Synchronous::delete_window_sync(BC_SynchronousCommand *command)
                glXDestroyContext(display, glx_context);
        command->command_done->unlock();
        XUnlockDisplay(display);
-       sync_unlock();
 #endif
 }
 
@@ -548,10 +457,9 @@ void BC_Synchronous::delete_display_sync(BC_SynchronousCommand *command)
 {
 #ifdef HAVE_GL
        Display *display = command->display;
-       sync_lock(display, "BC_Synchronous::delete_display_sync");
+       XLockDisplay(display);
        XUnlockDisplay(display);
        XCloseDisplay(display);
-       sync_unlock();
 #endif
 }
 
@@ -633,12 +541,11 @@ void BC_Synchronous::delete_pixmap_sync(BC_SynchronousCommand *command)
 #ifdef HAVE_GL
        Display *display = command->display;
        GLXWindow glx_win = command->glx_win;
-       sync_lock(display, "BC_Synchronous::delete_pixmap_sync");
+       XLockDisplay(display);
        glXMakeContextCurrent(display, glx_win, glx_win, command->glx_context);
        glXDestroyContext(display, command->glx_context);
        glXDestroyGLXPixmap(display, command->glx_pixmap);
        XUnlockDisplay(display);
-       sync_unlock();
 #endif
 }
 
@@ -646,7 +553,10 @@ void BC_Synchronous::delete_pixmap_sync(BC_SynchronousCommand *command)
 
 void BC_Synchronous::send_garbage(BC_SynchronousCommand *command)
 {
-       sync_garbage->send_garbage(command);
+       command_lock->lock("BC_Synchronous::send_garbage");
+       commands.append(command);
+       command_lock->unlock();
+       next_command->unlock();
 }
 
 BC_WindowBase* BC_Synchronous::get_window()
index 0afb610e1b1cde0d4fae516c22f68ddf9ab2e496..ba347b784189a0a8c05296690aeeb347c9e0a65f 100644 (file)
@@ -146,31 +146,8 @@ public:
 #endif
 };
 
-class BC_Synchronous;
-
-class BC_SynchGarbage : public Thread
-{
-public:
-       BC_SynchGarbage(BC_Synchronous*sync);
-       ~BC_SynchGarbage();
-
-       void send_garbage(BC_SynchronousCommand *command);
-       void handle_garbage();
-       void start();
-       void run();
-       void quit();
-       void stop();
-
-       BC_Synchronous *synchronous;
-       Condition *more_garbage;
-       Mutex *garbage_lock;
-       ArrayList<BC_SynchronousCommand*> garbage;
-       int done;
-};
-
 class BC_Synchronous : public Thread
 {
-       BC_SynchGarbage *sync_garbage;
 public:
        BC_Synchronous();
        virtual ~BC_Synchronous();
@@ -180,7 +157,6 @@ public:
        friend class BC_PBuffer;
        friend class BC_Pixmap;
        friend class BC_Texture;
-       friend class BC_SynchGarbage;
 
        void quit();
 // Must be called after constructor to create inherited objects.
@@ -266,7 +242,6 @@ private:
 
        Mutex *lock_sync;
        void sync_lock(const char *cp=0);
-       void sync_lock(Display *display, const char *cp);
        void sync_unlock();
 
        void get_display_sync(Display *display, const char *cp);
@@ -282,7 +257,7 @@ private:
        int done;
 // Command stack
        ArrayList<BC_SynchronousCommand*> commands;
-       int is_running;
+       int is_started;
 // The window the opengl context is currently bound to.
 // Set by BC_WindowBase::enable_opengl.
        BC_WindowBase *current_window;
index 9b993fe812fe9aa08c9bf9806b8d03e93b36de62..a4a6e21f99f605c1e30fe7a7ffb6092cad5ab40b 100644 (file)
  *
  */
 
+#include <stdio.h>
+#include <errno.h>
+
 #ifndef NO_GUICAST
 #include "bcsignals.h"
 #endif
 #include "mutex.h"
 
+
 Mutex::Mutex(const char *title, int recursive)
 {
        this->title = title;
@@ -122,6 +126,7 @@ int Mutex::unlock()
 
 int Mutex::trylock(const char *location)
 {
+       if( count ) return EBUSY;
        int ret = pthread_mutex_trylock(&mutex);
        if( ret ) return ret;