summaryrefslogtreecommitdiff
path: root/libs/fst
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-02-22 02:44:34 +0100
committerRobin Gareus <robin@gareus.org>2014-02-22 03:11:48 +0100
commitdfdf9a35f1e990c45f35632eb993eb67f4f7abf8 (patch)
treea74a58b39c8f08859c547b8e0f6c8a443cba8bf2 /libs/fst
parentb3154e8ed6b5bb62acdc4b5a72133ceaeab7e53e (diff)
resolve gtk + VST threading issues
while (gtk_events_pending()) gtk_main_iteration(); never returns as long as there's a idle call registered somewhere (and it's not called from an idle callback itself)
Diffstat (limited to 'libs/fst')
-rw-r--r--libs/fst/fst.c2
-rw-r--r--libs/fst/fst.h3
-rw-r--r--libs/fst/vstwin.c40
3 files changed, 38 insertions, 7 deletions
diff --git a/libs/fst/fst.c b/libs/fst/fst.c
index 433354e1f1..3ceee5278f 100644
--- a/libs/fst/fst.c
+++ b/libs/fst/fst.c
@@ -15,7 +15,7 @@ fst_error (const char *fmt, ...)
va_end (ap);
}
-void
+static void
default_fst_error_callback (const char *desc)
{
fprintf(stderr, "%s\n", desc);
diff --git a/libs/fst/fst.h b/libs/fst/fst.h
index e3cba8d3d5..10ccda4d41 100644
--- a/libs/fst/fst.h
+++ b/libs/fst/fst.h
@@ -48,6 +48,9 @@ extern void fst_move_window_into_view (VSTState *);
extern VSTInfo *fst_get_info (char *dllpathname);
extern void fst_free_info (VSTInfo *info);
extern void fst_event_loop_remove_plugin (VSTState* fst);
+extern void fst_start_threading(void);
+extern void fst_stop_threading(void);
+extern void fst_audio_master_idle(void);
#ifdef __cplusplus
}
diff --git a/libs/fst/vstwin.c b/libs/fst/vstwin.c
index 37ea86dc19..75bf2372da 100644
--- a/libs/fst/vstwin.c
+++ b/libs/fst/vstwin.c
@@ -16,6 +16,7 @@ static UINT_PTR idle_timer_id = 0;
#include <wine/exception.h>
#include <pthread.h>
static int gui_quit = 0;
+static unsigned int idle_id = 0;
#endif
@@ -249,12 +250,14 @@ fst_handle_new (void)
#ifndef PLATFORM_WINDOWS /* linux + wine */
static gboolean
g_idle_call (gpointer ignored) {
+ if (gui_quit) return FALSE;
MSG msg;
if (PeekMessageA (&msg, NULL, 0, 0, 1)) {
TranslateMessage (&msg);
DispatchMessageA (&msg);
}
idle_hands(NULL, 0, 0, 0);
+ g_main_context_iteration(NULL, FALSE);
return gui_quit ? FALSE : TRUE;
}
#endif
@@ -311,12 +314,31 @@ fst_init (void* possible_hmodule)
fst_error ("Error in fst_init(): (class registration failed");
return -1;
}
+ return 0;
+}
+
+void
+fst_start_threading(void)
+{
#ifndef PLATFORM_WINDOWS /* linux + wine */
- gui_quit = 0;
- g_idle_add (g_idle_call, NULL); // XXX too early ?
- //g_timeout_add(40, g_idle_call, NULL);
+ if (idle_id == 0) {
+ gui_quit = 0;
+ idle_id = g_idle_add (g_idle_call, NULL);
+ }
+#endif
+}
+
+void
+fst_stop_threading(void) {
+#ifndef PLATFORM_WINDOWS /* linux + wine */
+ if (idle_id != 0) {
+ gui_quit = 1;
+ PostQuitMessage (0);
+ g_main_context_iteration(NULL, FALSE);
+ //g_source_remove(idle_id);
+ idle_id = 0;
+ }
#endif
- return 0;
}
void
@@ -333,8 +355,10 @@ fst_exit (void)
KillTimer(NULL, idle_timer_id);
}
#else /* linux + wine */
- gui_quit = 1;
- PostQuitMessage (0);
+ if (idle_id) {
+ gui_quit = 1;
+ PostQuitMessage (0);
+ }
#endif
host_initialized = FALSE;
@@ -562,6 +586,10 @@ fst_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
return fst;
}
+void fst_audio_master_idle(void) {
+ while(g_main_context_iteration(NULL, FALSE)) ;
+}
+
void
fst_close (VSTState* fst)
{