mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
[357/906] x11: Don't crash when the X11 display is not available.
Error out cleanly instead of crashing when the X11 display can't be contacted.
This commit is contained in:
parent
09a2e19512
commit
b1dccdb13c
1 changed files with 33 additions and 30 deletions
|
@ -102,45 +102,42 @@ gst_gl_window_finalize (GObject * object)
|
||||||
g_mutex_lock (priv->x_lock);
|
g_mutex_lock (priv->x_lock);
|
||||||
|
|
||||||
priv->parent = 0;
|
priv->parent = 0;
|
||||||
|
if (priv->device) {
|
||||||
|
XUnmapWindow (priv->device, priv->internal_win_id);
|
||||||
|
|
||||||
XUnmapWindow (priv->device, priv->internal_win_id);
|
ret = glXMakeCurrent (priv->device, None, NULL);
|
||||||
|
if (!ret)
|
||||||
|
g_debug ("failed to release opengl context\n");
|
||||||
|
|
||||||
ret = glXMakeCurrent (priv->device, None, NULL);
|
glXDestroyContext (priv->device, priv->gl_context);
|
||||||
if (!ret)
|
|
||||||
g_debug ("failed to release opengl context\n");
|
|
||||||
|
|
||||||
glXDestroyContext (priv->device, priv->gl_context);
|
XFree (priv->visual_info);
|
||||||
|
|
||||||
XFree (priv->visual_info);
|
XReparentWindow (priv->device, priv->internal_win_id, priv->root, 0, 0);
|
||||||
|
XDestroyWindow (priv->device, priv->internal_win_id);
|
||||||
|
XSync (priv->device, FALSE);
|
||||||
|
|
||||||
XReparentWindow (priv->device, priv->internal_win_id, priv->root, 0, 0);
|
while (XPending (priv->device))
|
||||||
|
XNextEvent (priv->device, &event);
|
||||||
|
|
||||||
XDestroyWindow (priv->device, priv->internal_win_id);
|
XSetCloseDownMode (priv->device, DestroyAll);
|
||||||
|
|
||||||
XSync (priv->device, FALSE);
|
/*XAddToSaveSet (display, w)
|
||||||
|
Display *display;
|
||||||
|
Window w; */
|
||||||
|
|
||||||
while (XPending (priv->device))
|
//FIXME: it seems it causes destroy all created windows, even by other display connection:
|
||||||
XNextEvent (priv->device, &event);
|
//This is case in: gst-launch-0.10 videotestsrc ! tee name=t t. ! queue ! glimagesink t. ! queue ! glimagesink
|
||||||
|
//When the first window is closed and so its display is closed by the following line, then the other Window managed by the
|
||||||
|
//other glimagesink, is not useable and so each opengl call causes a segmentation fault.
|
||||||
|
//Maybe the solution is to use: XAddToSaveSet
|
||||||
|
//The following line is commented to avoid the disagreement explained before.
|
||||||
|
//XCloseDisplay (priv->device);
|
||||||
|
|
||||||
XSetCloseDownMode (priv->device, DestroyAll);
|
g_debug ("display receiver closed\n");
|
||||||
|
XCloseDisplay (priv->disp_send);
|
||||||
/*XAddToSaveSet (display, w)
|
g_debug ("display sender closed\n");
|
||||||
Display *display;
|
}
|
||||||
Window w; */
|
|
||||||
|
|
||||||
//FIXME: it seems it causes destroy all created windows, even by other display connection:
|
|
||||||
//This is case in: gst-launch-0.10 videotestsrc ! tee name=t t. ! queue ! glimagesink t. ! queue ! glimagesink
|
|
||||||
//When the first window is closed and so its display is closed by the following line, then the other Window managed by the
|
|
||||||
//other glimagesink, is not useable and so each opengl call causes a segmentation fault.
|
|
||||||
//Maybe the solution is to use: XAddToSaveSet
|
|
||||||
//The following line is commented to avoid the disagreement explained before.
|
|
||||||
//XCloseDisplay (priv->device);
|
|
||||||
|
|
||||||
g_debug ("display receiver closed\n");
|
|
||||||
|
|
||||||
XCloseDisplay (priv->disp_send);
|
|
||||||
|
|
||||||
g_debug ("display sender closed\n");
|
|
||||||
|
|
||||||
if (priv->cond_send_message) {
|
if (priv->cond_send_message) {
|
||||||
g_cond_free (priv->cond_send_message);
|
g_cond_free (priv->cond_send_message);
|
||||||
|
@ -280,6 +277,8 @@ gst_gl_window_new (gint width, gint height, gulong external_gl_context)
|
||||||
g_mutex_lock (priv->x_lock);
|
g_mutex_lock (priv->x_lock);
|
||||||
|
|
||||||
priv->device = XOpenDisplay (priv->display_name);
|
priv->device = XOpenDisplay (priv->display_name);
|
||||||
|
if (priv->device == NULL)
|
||||||
|
goto no_display;
|
||||||
|
|
||||||
XSynchronize (priv->device, FALSE);
|
XSynchronize (priv->device, FALSE);
|
||||||
|
|
||||||
|
@ -410,6 +409,10 @@ gst_gl_window_new (gint width, gint height, gulong external_gl_context)
|
||||||
g_mutex_unlock (priv->x_lock);
|
g_mutex_unlock (priv->x_lock);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
|
no_display:
|
||||||
|
g_mutex_unlock (priv->x_lock);
|
||||||
|
g_object_unref (window);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GQuark
|
GQuark
|
||||||
|
|
Loading…
Reference in a new issue