mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-06 10:42:22 +00:00
egl: Fix racyness in display thread creation
Multiple different scenarios could break the display thread creation and end up blocking waiting for thread o be created. Fix them all by correctly waiting for a new boolean to become valid.
This commit is contained in:
parent
2e8cdac059
commit
499e248d4c
2 changed files with 9 additions and 1 deletions
|
@ -573,6 +573,7 @@ egl_display_thread (gpointer data)
|
||||||
EGLint major_version, minor_version;
|
EGLint major_version, minor_version;
|
||||||
gchar **gl_apis, **gl_api;
|
gchar **gl_apis, **gl_api;
|
||||||
|
|
||||||
|
g_mutex_lock (&display->mutex);
|
||||||
if (!display->base.is_wrapped) {
|
if (!display->base.is_wrapped) {
|
||||||
gl_display = display->base.handle.p =
|
gl_display = display->base.handle.p =
|
||||||
egl_get_display_from_native (display->base.handle.u,
|
egl_get_display_from_native (display->base.handle.u,
|
||||||
|
@ -609,7 +610,9 @@ egl_display_thread (gpointer data)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
display->base.is_valid = TRUE;
|
display->base.is_valid = TRUE;
|
||||||
|
display->created = TRUE;
|
||||||
g_cond_broadcast (&display->gl_thread_ready);
|
g_cond_broadcast (&display->gl_thread_ready);
|
||||||
|
g_mutex_unlock (&display->mutex);
|
||||||
|
|
||||||
while (!display->gl_thread_cancel) {
|
while (!display->gl_thread_cancel) {
|
||||||
EglMessage *const msg =
|
EglMessage *const msg =
|
||||||
|
@ -624,17 +627,20 @@ egl_display_thread (gpointer data)
|
||||||
egl_object_unref (msg);
|
egl_object_unref (msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g_mutex_lock (&display->mutex);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (gl_display != EGL_NO_DISPLAY && !display->base.is_wrapped)
|
if (gl_display != EGL_NO_DISPLAY && !display->base.is_wrapped)
|
||||||
eglTerminate (gl_display);
|
eglTerminate (gl_display);
|
||||||
display->base.handle.p = NULL;
|
display->base.handle.p = NULL;
|
||||||
g_cond_broadcast (&display->gl_thread_ready);
|
g_cond_broadcast (&display->gl_thread_ready);
|
||||||
|
g_mutex_unlock (&display->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
error:
|
error:
|
||||||
{
|
{
|
||||||
|
display->created = TRUE;
|
||||||
display->base.is_valid = FALSE;
|
display->base.is_valid = FALSE;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -656,6 +662,7 @@ egl_display_init (EglDisplay * display)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_mutex_lock (&display->mutex);
|
g_mutex_lock (&display->mutex);
|
||||||
|
while (!display->created)
|
||||||
g_cond_wait (&display->gl_thread_ready, &display->mutex);
|
g_cond_wait (&display->gl_thread_ready, &display->mutex);
|
||||||
g_mutex_unlock (&display->mutex);
|
g_mutex_unlock (&display->mutex);
|
||||||
return display->base.is_valid;
|
return display->base.is_valid;
|
||||||
|
|
|
@ -122,6 +122,7 @@ struct egl_display_s
|
||||||
GCond gl_thread_ready;
|
GCond gl_thread_ready;
|
||||||
volatile gboolean gl_thread_cancel;
|
volatile gboolean gl_thread_cancel;
|
||||||
GAsyncQueue *gl_queue;
|
GAsyncQueue *gl_queue;
|
||||||
|
gboolean created;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct egl_config_s
|
struct egl_config_s
|
||||||
|
|
Loading…
Reference in a new issue