add "last modified" column to session-dialog
[ardour.git] / gtk2_ardour / linux_vst_gui_support.cc
index 65039f162db452d8114493d25111c2f85b679963..19671c8ad77cd08c9c5f711c8227fe825e1cac16 100644 (file)
@@ -22,8 +22,6 @@
 /** VSTFX - An engine based on FST for handling linuxVST plugins **/
 /******************************************************************/
 
-/** EDITOR tab stops at 4 **/
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <libgen.h>
@@ -350,11 +348,18 @@ void* gui_event_loop (void* ptr)
                /*Look at the XEvent queue - if there are any XEvents we need to handle them,
                including passing them to all the plugin (eventProcs) we are currently managing*/
                
+               bool may_sleep = true;
+
                if(LXVST_XDisplay)
                {
                        /*See if there are any events in the queue*/
                
                        int num_events = XPending(LXVST_XDisplay);
+
+                       if (num_events > 0) {
+                               // keep dispatching events as fast as possible
+                               may_sleep = false;
+                       }
                        
                        /*process them if there are any*/
                
@@ -466,6 +471,10 @@ again:
 
                        clock1 = g_get_monotonic_time();
                }
+
+               if (may_sleep && elapsed_time_ms + 1 < LXVST_sched_timer_interval) {
+                       Glib::usleep(1000 * (LXVST_sched_timer_interval - elapsed_time_ms - 1));
+               }
        }
 
        /*Drop out to here if we set gui_quit to 1 */
@@ -660,10 +669,6 @@ int vstfx_create_editor (VSTState* vstfx)
        
        XSendEvent(LXVST_XDisplay, parent_window, FALSE, NoEventMask, (XEvent*)&event);
 
-       /*Unlock - and we are done for the first part of staring the Editor...*/
-       
-       pthread_mutex_unlock (&vstfx->lock);
-       
        return 0;
 }