mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
eglglessink: Fix crash when closing internal X11 window
This commit is contained in:
parent
7efa7b9698
commit
3c2574998b
4 changed files with 27 additions and 12 deletions
|
@ -810,7 +810,7 @@ gst_eglglessink_stop (GstEglGlesSink * eglglessink)
|
||||||
|
|
||||||
if (eglglessink->using_own_window) {
|
if (eglglessink->using_own_window) {
|
||||||
platform_destroy_native_window (eglglessink->eglglesctx.display,
|
platform_destroy_native_window (eglglessink->eglglesctx.display,
|
||||||
eglglessink->eglglesctx.used_window);
|
eglglessink->eglglesctx.used_window, &eglglessink->own_window_data);
|
||||||
eglglessink->eglglesctx.used_window = 0;
|
eglglessink->eglglesctx.used_window = 0;
|
||||||
eglglessink->have_window = FALSE;
|
eglglessink->have_window = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -866,7 +866,7 @@ gst_eglglessink_create_window (GstEglGlesSink * eglglessink, gint width,
|
||||||
} else
|
} else
|
||||||
GST_INFO_OBJECT (eglglessink, "Attempting internal window creation");
|
GST_INFO_OBJECT (eglglessink, "Attempting internal window creation");
|
||||||
|
|
||||||
window = platform_create_native_window (width, height);
|
window = platform_create_native_window (width, height, &eglglessink->own_window_data);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
GST_ERROR_OBJECT (eglglessink, "Could not create window");
|
GST_ERROR_OBJECT (eglglessink, "Could not create window");
|
||||||
return window;
|
return window;
|
||||||
|
|
|
@ -204,6 +204,8 @@ struct _GstEglGlesSink
|
||||||
gboolean have_texture;
|
gboolean have_texture;
|
||||||
gboolean egl_started;
|
gboolean egl_started;
|
||||||
|
|
||||||
|
gpointer own_window_data;
|
||||||
|
|
||||||
GThread *thread;
|
GThread *thread;
|
||||||
gboolean thread_running;
|
gboolean thread_running;
|
||||||
GstDataQueue *queue;
|
GstDataQueue *queue;
|
||||||
|
|
|
@ -73,13 +73,17 @@ platform_wrapper_init (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_X11
|
#ifdef HAVE_X11
|
||||||
|
typedef struct {
|
||||||
|
Display *display;
|
||||||
|
} X11WindowData;
|
||||||
|
|
||||||
EGLNativeWindowType
|
EGLNativeWindowType
|
||||||
platform_create_native_window (gint width, gint height)
|
platform_create_native_window (gint width, gint height, gpointer * window_data)
|
||||||
{
|
{
|
||||||
Display *d;
|
Display *d;
|
||||||
Window w;
|
Window w;
|
||||||
//XEvent e;
|
|
||||||
int s;
|
int s;
|
||||||
|
X11WindowData *data;
|
||||||
|
|
||||||
d = XOpenDisplay (NULL);
|
d = XOpenDisplay (NULL);
|
||||||
if (d == NULL) {
|
if (d == NULL) {
|
||||||
|
@ -93,15 +97,26 @@ platform_create_native_window (gint width, gint height)
|
||||||
XStoreName (d, w, "eglglessink");
|
XStoreName (d, w, "eglglessink");
|
||||||
XMapWindow (d, w);
|
XMapWindow (d, w);
|
||||||
XFlush (d);
|
XFlush (d);
|
||||||
|
|
||||||
|
*window_data = data = g_slice_new0 (X11WindowData);
|
||||||
|
data->display = d;
|
||||||
|
|
||||||
return (EGLNativeWindowType) w;
|
return (EGLNativeWindowType) w;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
platform_destroy_native_window (EGLNativeDisplayType display,
|
platform_destroy_native_window (EGLNativeDisplayType display,
|
||||||
EGLNativeWindowType window)
|
EGLNativeWindowType window, gpointer * window_data)
|
||||||
{
|
{
|
||||||
|
X11WindowData *data = *window_data;
|
||||||
|
|
||||||
/* XXX: Should proly catch BadWindow */
|
/* XXX: Should proly catch BadWindow */
|
||||||
XDestroyWindow (display, window);
|
XDestroyWindow (data->display, window);
|
||||||
|
XSync (data->display, FALSE);
|
||||||
|
XCloseDisplay (data->display);
|
||||||
|
|
||||||
|
g_slice_free (X11WindowData, data);
|
||||||
|
*window_data = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -109,7 +124,7 @@ platform_destroy_native_window (EGLNativeDisplayType display,
|
||||||
#if !defined(HAVE_X11)
|
#if !defined(HAVE_X11)
|
||||||
/* Dummy functions for creating a native Window */
|
/* Dummy functions for creating a native Window */
|
||||||
EGLNativeWindowType
|
EGLNativeWindowType
|
||||||
platform_create_native_window (gint width, gint height)
|
platform_create_native_window (gint width, gint height, gpointer * window_data)
|
||||||
{
|
{
|
||||||
GST_ERROR ("Can't create native window");
|
GST_ERROR ("Can't create native window");
|
||||||
return (EGLNativeWindowType) 0;
|
return (EGLNativeWindowType) 0;
|
||||||
|
@ -117,7 +132,7 @@ platform_create_native_window (gint width, gint height)
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
platform_destroy_native_window (EGLNativeDisplayType display,
|
platform_destroy_native_window (EGLNativeDisplayType display,
|
||||||
EGLNativeWindowType window)
|
EGLNativeWindowType window, gpointer * window_data)
|
||||||
{
|
{
|
||||||
GST_ERROR ("Can't destroy native window");
|
GST_ERROR ("Can't destroy native window");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -54,11 +54,9 @@
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
|
|
||||||
gboolean platform_wrapper_init (void);
|
gboolean platform_wrapper_init (void);
|
||||||
EGLNativeWindowType platform_create_native_window (gint width, gint height);
|
EGLNativeWindowType platform_create_native_window (gint width, gint height, gpointer * window_data);
|
||||||
gboolean platform_destroy_native_window (EGLNativeDisplayType display,
|
gboolean platform_destroy_native_window (EGLNativeDisplayType display,
|
||||||
EGLNativeWindowType w);
|
EGLNativeWindowType w, gpointer * window_data);
|
||||||
EGLint *platform_crate_native_image_buffer (EGLNativeWindowType win,
|
|
||||||
EGLConfig config, EGLNativeDisplayType display, const EGLint * egl_attribs);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue