mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
[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.
This commit is contained in:
parent
6aa6212419
commit
757618a986
1 changed files with 20 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue