From: Matthew Waters Date: Wed, 19 Dec 2012 03:32:20 +0000 (+1100) Subject: [633/906] display: fail properly in context creation in order to minimize a race... X-Git-Tag: 1.19.3~511^2~1989^2~1886 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db236c510fbac6c43d29b61657ec5fe22deb8e74;p=platform%2Fupstream%2Fgstreamer.git [633/906] display: fail properly in context creation in order to minimize a race condition previously, on context creation, when we failed to get a valid context we would still atempt to run the window mainloop as well as setting an error on the display. This would cause the calling element to finalize the display and therefore attempt to quit the window mainloop. However the mainloop may not have started running. Thus when the window mainloop ran it would never a get a quit message and never end. --- diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c index fb01dfd..8a1c4b7 100644 --- a/gst-libs/gst/gl/gstgldisplay.c +++ b/gst-libs/gst/gl/gstgldisplay.c @@ -402,7 +402,7 @@ _create_context_opengl (GstGLDisplay * display, gint * gl_major, gint * gl_minor GST_INFO ("GL_SHADING_LANGUAGE_VERSION: %s", glGetString (GL_SHADING_LANGUAGE_VERSION)); else - GST_INFO ("Your driver does not support GLSL (OpenGL Shading Language)"); + GST_WARNING ("Your driver does not support GLSL (OpenGL Shading Language)"); if (glGetString (GL_VENDOR)) GST_INFO ("GL_VENDOR: %s", glGetString (GL_VENDOR)); @@ -478,9 +478,7 @@ gst_gl_display_thread_create_context (GstGLDisplay * display) if (!display->gl_window || error) { gst_gl_display_set_error (display, error ? error->message : "Failed to create gl window"); - g_cond_signal (display->cond_create_context); - gst_gl_display_unlock (display); - return NULL; + goto failure; } GST_INFO ("gl window created"); @@ -494,10 +492,12 @@ gst_gl_display_thread_create_context (GstGLDisplay * display) compiled_api_s = gst_gl_api_string (compiled_api); GST_INFO ("compiled api support: %s", compiled_api_s); - if ((compiled_api & display->gl_api) == GST_GL_API_NONE) + if ((compiled_api & display->gl_api) == GST_GL_API_NONE) { gst_gl_display_set_error (display, "failed to create_context, window " "could not provide correct api. compiled api supports:%s, window " "supports:%s", compiled_api_s, api_string); + goto failure; + } g_free (api_string); g_free (compiled_api_s); @@ -512,8 +512,10 @@ gst_gl_display_thread_create_context (GstGLDisplay * display) ret = _create_context_gles2 (display, &gl_major, &gl_minor); #endif - if (!ret || !gl_major) + if (!ret || !gl_major) { gst_gl_display_set_error (display, "failed to create context, unknown reason"); + goto failure; + } /* setup callbacks */ gst_gl_window_set_resize_callback (display->gl_window, @@ -544,6 +546,18 @@ gst_gl_display_thread_create_context (GstGLDisplay * display) gst_gl_display_unlock (display); return NULL; + +failure: + { + if (display->gl_window) { + g_object_unref (display->gl_window); + display->gl_window = NULL; + } + + g_cond_signal (display->cond_create_context); + gst_gl_display_unlock (display); + return NULL; + } }