summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-06-23 11:05:06 +0200
committerSebastian Dröge <sebastian@centricular.com>2015-06-23 11:05:06 +0200
commit0bff481011cf74c59869b511393d1696b570e3d5 (patch)
treeea595d65b2e7a716bd61ff21684392d1e508685f
parent1ece34af2cda3cfe2bbd2d69e6fbf6bea696b098 (diff)
downloadgstreamer-plugins-bad-0bff481011cf74c59869b511393d1696b570e3d5.tar.gz
eagl: Don't dispatch_sync() to the main thread if we are on the main thread
This will otherwise deadlock. https://bugzilla.gnome.org/show_bug.cgi?id=751101
-rw-r--r--gst-libs/gst/gl/eagl/gstglcontext_eagl.m41
1 files changed, 31 insertions, 10 deletions
diff --git a/gst-libs/gst/gl/eagl/gstglcontext_eagl.m b/gst-libs/gst/gl/eagl/gstglcontext_eagl.m
index 9fb29e65e..33e6d753d 100644
--- a/gst-libs/gst/gl/eagl/gstglcontext_eagl.m
+++ b/gst-libs/gst/gl/eagl/gstglcontext_eagl.m
@@ -168,7 +168,7 @@ gst_gl_context_eagl_update_layer (GstGLContext * context)
if (priv->eagl_layer)
gst_gl_context_eagl_release_layer (context);
- dispatch_sync (dispatch_get_main_queue (), ^{
+ void (^create_block) (void) = ^{
eagl_layer = (CAEAGLLayer *)[window_handle layer];
[EAGLContext setCurrentContext:priv->eagl_context];
@@ -194,7 +194,13 @@ gst_gl_context_eagl_update_layer (GstGLContext * context)
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER, depth_renderbuffer);
[EAGLContext setCurrentContext:nil];
- });
+ };
+
+ if ([NSThread isMainThread]) {
+ create_block ();
+ } else {
+ dispatch_sync (dispatch_get_main_queue (), create_block);
+ }
[EAGLContext setCurrentContext:priv->eagl_context];
@@ -224,7 +230,7 @@ gst_gl_context_eagl_create_context (GstGLContext * context, GstGLAPI gl_api,
GstGLContextEagl *context_eagl = GST_GL_CONTEXT_EAGL (context);
GstGLContextEaglPrivate *priv = context_eagl->priv;
- dispatch_sync (dispatch_get_main_queue (), ^{
+ void (^create_block) (void) = ^{
if (other_context) {
EAGLContext *external_gl_context = (EAGLContext *)
gst_gl_context_get_gl_context (other_context);
@@ -235,8 +241,14 @@ gst_gl_context_eagl_create_context (GstGLContext * context, GstGLAPI gl_api,
} else {
priv->eagl_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
}
- });
-
+ };
+
+ if ([NSThread isMainThread]) {
+ create_block ();
+ } else {
+ dispatch_sync (dispatch_get_main_queue (), create_block);
+ }
+
priv->eagl_layer = NULL;
priv->framebuffer = 0;
priv->color_renderbuffer = 0;
@@ -284,17 +296,26 @@ gst_gl_context_eagl_choose_format (GstGLContext * context, GError ** error)
gst_object_unref (window);
return TRUE;
}
-
- dispatch_sync (dispatch_get_main_queue (), ^{
+
+ void (^create_block) (void) = ^{
CAEAGLLayer *eagl_layer;
NSDictionary * dict =[NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking,
- kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
+ [NSNumber numberWithBool:NO],
+ kEAGLDrawablePropertyRetainedBacking,
+ kEAGLColorFormatRGBA8,
+ kEAGLDrawablePropertyColorFormat,
+ nil];
eagl_layer = (CAEAGLLayer *)[window_handle layer];
[eagl_layer setOpaque:YES];
[eagl_layer setDrawableProperties:dict];
- });
+ };
+
+ if ([NSThread isMainThread]) {
+ create_block ();
+ } else {
+ dispatch_sync (dispatch_get_main_queue (), create_block);
+ }
gst_object_unref (window);