mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 18:51:11 +00:00
gl/eagl: Don't call anything synchronously from the main thread
This will deadlock if the main thread is the one who creates the GstGLContext. All things we call from the main thread should be possible from any thread. https://bugzilla.gnome.org/show_bug.cgi?id=751101
This commit is contained in:
parent
b7a3b54b2a
commit
cff2d74cd4
1 changed files with 47 additions and 53 deletions
|
@ -143,12 +143,12 @@ gst_gl_context_eagl_release_layer (GstGLContext * context)
|
||||||
void
|
void
|
||||||
gst_gl_context_eagl_update_layer (GstGLContext * context)
|
gst_gl_context_eagl_update_layer (GstGLContext * context)
|
||||||
{
|
{
|
||||||
__block GLuint framebuffer;
|
GLuint framebuffer;
|
||||||
__block GLuint color_renderbuffer;
|
GLuint color_renderbuffer;
|
||||||
__block GLuint depth_renderbuffer;
|
GLuint depth_renderbuffer;
|
||||||
__block GLint width;
|
GLint width;
|
||||||
__block GLint height;
|
GLint height;
|
||||||
__block CAEAGLLayer *eagl_layer;
|
CAEAGLLayer *eagl_layer;
|
||||||
GLenum status;
|
GLenum status;
|
||||||
GstGLContextEagl *context_eagl = GST_GL_CONTEXT_EAGL (context);
|
GstGLContextEagl *context_eagl = GST_GL_CONTEXT_EAGL (context);
|
||||||
GstGLContextEaglPrivate *priv = context_eagl->priv;
|
GstGLContextEaglPrivate *priv = context_eagl->priv;
|
||||||
|
@ -168,33 +168,31 @@ gst_gl_context_eagl_update_layer (GstGLContext * context)
|
||||||
if (priv->eagl_layer)
|
if (priv->eagl_layer)
|
||||||
gst_gl_context_eagl_release_layer (context);
|
gst_gl_context_eagl_release_layer (context);
|
||||||
|
|
||||||
dispatch_sync (dispatch_get_main_queue (), ^{
|
eagl_layer = (CAEAGLLayer *)[window_handle layer];
|
||||||
eagl_layer = (CAEAGLLayer *)[window_handle layer];
|
[EAGLContext setCurrentContext:priv->eagl_context];
|
||||||
[EAGLContext setCurrentContext:priv->eagl_context];
|
|
||||||
|
|
||||||
/* Allocate framebuffer */
|
/* Allocate framebuffer */
|
||||||
glGenFramebuffers (1, &framebuffer);
|
glGenFramebuffers (1, &framebuffer);
|
||||||
glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
|
glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
|
||||||
/* Allocate color render buffer */
|
/* Allocate color render buffer */
|
||||||
glGenRenderbuffers (1, &color_renderbuffer);
|
glGenRenderbuffers (1, &color_renderbuffer);
|
||||||
glBindRenderbuffer (GL_RENDERBUFFER, color_renderbuffer);
|
glBindRenderbuffer (GL_RENDERBUFFER, color_renderbuffer);
|
||||||
[priv->eagl_context renderbufferStorage: GL_RENDERBUFFER fromDrawable:eagl_layer];
|
[priv->eagl_context renderbufferStorage: GL_RENDERBUFFER fromDrawable:eagl_layer];
|
||||||
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||||
GL_RENDERBUFFER, color_renderbuffer);
|
GL_RENDERBUFFER, color_renderbuffer);
|
||||||
/* Get renderbuffer width/height */
|
/* Get renderbuffer width/height */
|
||||||
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH,
|
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH,
|
||||||
&width);
|
&width);
|
||||||
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT,
|
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT,
|
||||||
&height);
|
&height);
|
||||||
/* allocate depth render buffer */
|
/* allocate depth render buffer */
|
||||||
glGenRenderbuffers (1, &depth_renderbuffer);
|
glGenRenderbuffers (1, &depth_renderbuffer);
|
||||||
glBindRenderbuffer (GL_RENDERBUFFER, depth_renderbuffer);
|
glBindRenderbuffer (GL_RENDERBUFFER, depth_renderbuffer);
|
||||||
glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width,
|
glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width,
|
||||||
height);
|
height);
|
||||||
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||||
GL_RENDERBUFFER, depth_renderbuffer);
|
GL_RENDERBUFFER, depth_renderbuffer);
|
||||||
[EAGLContext setCurrentContext:nil];
|
[EAGLContext setCurrentContext:nil];
|
||||||
});
|
|
||||||
|
|
||||||
[EAGLContext setCurrentContext:priv->eagl_context];
|
[EAGLContext setCurrentContext:priv->eagl_context];
|
||||||
|
|
||||||
|
@ -224,19 +222,17 @@ gst_gl_context_eagl_create_context (GstGLContext * context, GstGLAPI gl_api,
|
||||||
GstGLContextEagl *context_eagl = GST_GL_CONTEXT_EAGL (context);
|
GstGLContextEagl *context_eagl = GST_GL_CONTEXT_EAGL (context);
|
||||||
GstGLContextEaglPrivate *priv = context_eagl->priv;
|
GstGLContextEaglPrivate *priv = context_eagl->priv;
|
||||||
|
|
||||||
dispatch_sync (dispatch_get_main_queue (), ^{
|
if (other_context) {
|
||||||
if (other_context) {
|
EAGLContext *external_gl_context = (EAGLContext *)
|
||||||
EAGLContext *external_gl_context = (EAGLContext *)
|
gst_gl_context_get_gl_context (other_context);
|
||||||
gst_gl_context_get_gl_context (other_context);
|
EAGLSharegroup *share_group = [external_gl_context sharegroup];
|
||||||
EAGLSharegroup *share_group = [external_gl_context sharegroup];
|
|
||||||
|
priv->eagl_context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2 sharegroup:share_group];
|
||||||
|
[share_group release];
|
||||||
|
} else {
|
||||||
|
priv->eagl_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||||
|
}
|
||||||
|
|
||||||
priv->eagl_context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2 sharegroup:share_group];
|
|
||||||
[share_group release];
|
|
||||||
} else {
|
|
||||||
priv->eagl_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
priv->eagl_layer = NULL;
|
priv->eagl_layer = NULL;
|
||||||
priv->framebuffer = 0;
|
priv->framebuffer = 0;
|
||||||
priv->color_renderbuffer = 0;
|
priv->color_renderbuffer = 0;
|
||||||
|
@ -285,16 +281,14 @@ gst_gl_context_eagl_choose_format (GstGLContext * context, GError ** error)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch_sync (dispatch_get_main_queue (), ^{
|
CAEAGLLayer *eagl_layer;
|
||||||
CAEAGLLayer *eagl_layer;
|
NSDictionary * dict =[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
NSDictionary * dict =[NSDictionary dictionaryWithObjectsAndKeys:
|
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking,
|
||||||
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking,
|
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
|
||||||
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
|
|
||||||
|
|
||||||
eagl_layer = (CAEAGLLayer *)[window_handle layer];
|
eagl_layer = (CAEAGLLayer *)[window_handle layer];
|
||||||
[eagl_layer setOpaque:YES];
|
[eagl_layer setOpaque:YES];
|
||||||
[eagl_layer setDrawableProperties:dict];
|
[eagl_layer setDrawableProperties:dict];
|
||||||
});
|
|
||||||
|
|
||||||
gst_object_unref (window);
|
gst_object_unref (window);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue