summaryrefslogtreecommitdiff
path: root/libs/fst/vstwin.c
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/vstwin.c
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/vstwin.c')
-rw-r--r--libs/fst/vstwin.c40
1 files changed, 34 insertions, 6 deletions
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)
{