projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
assert no null pointer dereference
[ardour.git]
/
gtk2_ardour
/
linux_vst_gui_support.cc
diff --git
a/gtk2_ardour/linux_vst_gui_support.cc
b/gtk2_ardour/linux_vst_gui_support.cc
index 4d90bdd4aa98e1388fababee0ba0be087e7d8671..65039f162db452d8114493d25111c2f85b679963 100644
(file)
--- a/
gtk2_ardour/linux_vst_gui_support.cc
+++ b/
gtk2_ardour/linux_vst_gui_support.cc
@@
-26,9
+26,8
@@
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
-#include <jack/jack.h>
-#include <jack/thread.h>
#include <libgen.h>
#include <libgen.h>
+#include <assert.h>
#include <pthread.h>
#include <signal.h>
#include <pthread.h>
#include <signal.h>
@@
-44,6
+43,7
@@
#include <time.h>
#include <unistd.h>
#include <pthread.h>
#include <time.h>
#include <unistd.h>
#include <pthread.h>
+#include <sys/time.h>
struct ERect{
short top;
struct ERect{
short top;
@@
-335,10
+335,11
@@
windows, that is if they don't manage their own UIs **/
void* gui_event_loop (void* ptr)
{
VSTState* vstfx;
void* gui_event_loop (void* ptr)
{
VSTState* vstfx;
- int LXVST_sched_event_timer = 0;
- int LXVST_sched_timer_interval = 50; //ms
+ int LXVST_sched_timer_interval = 40; //ms, 25fps
XEvent event;
XEvent event;
+ uint64_t clock1, clock2;
+ clock1 = g_get_monotonic_time();
/*The 'Forever' loop - runs the plugin UIs etc - based on the FST gui event loop*/
while (!gui_quit)
/*The 'Forever' loop - runs the plugin UIs etc - based on the FST gui event loop*/
while (!gui_quit)
@@
-380,14
+381,14
@@
void* gui_event_loop (void* ptr)
Glib::usleep(1000);
Glib::usleep(1000);
- LXVST_sched_event_timer++;
-
- LXVST_sched_event_timer = LXVST_sched_event_timer & 0x00FFFFFF;
-
/*See if its time for us to do a scheduled event pass on all the plugins*/
/*See if its time for us to do a scheduled event pass on all the plugins*/
- if((LXVST_sched_timer_interval!=0) && (!(LXVST_sched_event_timer% LXVST_sched_timer_interval)))
+ clock2 = g_get_monotonic_time();
+ const int64_t elapsed_time_ms = (clock2 - clock1) / 1000;
+
+ if((LXVST_sched_timer_interval != 0) && elapsed_time_ms >= LXVST_sched_timer_interval)
{
{
+ //printf("elapsed %d ms ^= %.2f Hz\n", elapsed_time_ms, 1000.0/(double)elapsed_time_ms); // DEBUG
pthread_mutex_lock (&plugin_mutex);
again:
pthread_mutex_lock (&plugin_mutex);
again:
@@
-462,6
+463,8
@@
again:
pthread_mutex_unlock (&vstfx->lock);
}
pthread_mutex_unlock (&plugin_mutex);
pthread_mutex_unlock (&vstfx->lock);
}
pthread_mutex_unlock (&plugin_mutex);
+
+ clock1 = g_get_monotonic_time();
}
}
}
}
@@
-770,6
+773,10
@@
vstfx_event_loop_remove_plugin (VSTState* vstfx)
}
}
}
}
+ // if this function is called, there must be
+ // at least one plugin in the linked list
+ assert(vstfx_first);
+
if (vstfx_first == vstfx) {
vstfx_first = vstfx_first->next;
}
if (vstfx_first == vstfx) {
vstfx_first = vstfx_first->next;
}