eglglessink: Don't set the EAGLContext of the main thread and don't reuse it either

... instead create a new context for every sink instance.

https://bugzilla.gnome.org/show_bug.cgi?id=720421
This commit is contained in:
Sebastian Dröge 2013-12-19 21:36:50 +01:00
parent cf2cf20cc3
commit d9525c134b

View file

@ -107,14 +107,9 @@ gst_egl_adaptation_create_egl_context (GstEglAdaptationContext * ctx)
__block EAGLContext *context;
dispatch_sync(dispatch_get_main_queue(), ^{
EAGLContext *cur_ctx = [EAGLContext currentContext];
if (cur_ctx) {
context = cur_ctx;
} else {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if (context == nil) {
GST_ERROR_OBJECT (ctx->element, "Failed to create EAGL GLES2 context");
}
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if (context == nil) {
GST_ERROR_OBJECT (ctx->element, "Failed to create EAGL GLES2 context");
}
});
@ -148,10 +143,6 @@ gst_egl_adaptation_context_make_current (GstEglAdaptationContext * ctx,
return FALSE;
}
ctx_to_set = ctx->eaglctx->eagl_context;
dispatch_sync(dispatch_get_main_queue(), ^{
[EAGLContext setCurrentContext: ctx_to_set];
});
} else {
GST_DEBUG_OBJECT (ctx->element, "Detaching context from thread %p",
g_thread_self ());
@ -178,6 +169,8 @@ gst_egl_adaptation_create_surface (GstEglAdaptationContext * ctx)
dispatch_sync(dispatch_get_main_queue(), ^{
gst_egl_adaptation_context_make_current (ctx, TRUE);
if (ctx->eaglctx->framebuffer) {
framebuffer = ctx->eaglctx->framebuffer;
} else {
@ -203,6 +196,8 @@ gst_egl_adaptation_create_surface (GstEglAdaptationContext * ctx)
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER, depthRenderbuffer);
gst_egl_adaptation_context_make_current (ctx, FALSE);
});
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);