summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Isorce <julien.isorce@gmail.com>2014-04-12 17:33:44 +0100
committerJulien Isorce <julien.isorce@gmail.com>2014-04-12 17:33:44 +0100
commit6b2c24d0c48c395c8aee4ce7e2823d30944aac00 (patch)
tree02947317bb817a26f275072bf6ba8839673ab5af
parent0bd53c9ccbb71f33e48bb90a7ae3587a1fae49c4 (diff)
gl/cocoa: make gst_gl_window_cocoa_send_message_async re-entrant
Backends that use g_main_context_invoke are re-entrant. Il allows to call two nested gst_gl_context_thread_add. ex: init_upload / init_colorconvert
-rw-r--r--gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m19
1 files changed, 13 insertions, 6 deletions
diff --git a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
index 02f74b2d3..509d57436 100644
--- a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
+++ b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
@@ -334,13 +334,20 @@ gst_gl_window_cocoa_send_message_async (GstGLWindow * window,
if (window) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- AppThreadPerformer* app_thread_performer = [[AppThreadPerformer alloc]
- initWithAll:window_cocoa callback:callback userData:data];
-
- [app_thread_performer performSelector:@selector(sendToApp) onThread:priv->thread
- withObject:nil waitUntilDone:NO];
+ /* performSelector is not re-entrant so do it manually */
+ if (G_UNLIKELY ([NSThread currentThread] == priv->thread)) {
+ if (callback)
+ callback (data);
+ } else {
+ AppThreadPerformer* app_thread_performer =
+ [[AppThreadPerformer alloc] initWithAll:window_cocoa
+ callback:callback userData:data];
- [pool release];
+ [app_thread_performer performSelector:@selector(sendToApp)
+ onThread:priv->thread withObject:nil waitUntilDone:NO];
+
+ [pool release];
+ }
}
}