mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +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) {
|
||||
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->have_window = FALSE;
|
||||
}
|
||||
|
@ -866,7 +866,7 @@ gst_eglglessink_create_window (GstEglGlesSink * eglglessink, gint width,
|
|||
} else
|
||||
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) {
|
||||
GST_ERROR_OBJECT (eglglessink, "Could not create window");
|
||||
return window;
|
||||
|
|
|
@ -204,6 +204,8 @@ struct _GstEglGlesSink
|
|||
gboolean have_texture;
|
||||
gboolean egl_started;
|
||||
|
||||
gpointer own_window_data;
|
||||
|
||||
GThread *thread;
|
||||
gboolean thread_running;
|
||||
GstDataQueue *queue;
|
||||
|
|
|
@ -73,13 +73,17 @@ platform_wrapper_init (void)
|
|||
}
|
||||
|
||||
#ifdef HAVE_X11
|
||||
typedef struct {
|
||||
Display *display;
|
||||
} X11WindowData;
|
||||
|
||||
EGLNativeWindowType
|
||||
platform_create_native_window (gint width, gint height)
|
||||
platform_create_native_window (gint width, gint height, gpointer * window_data)
|
||||
{
|
||||
Display *d;
|
||||
Window w;
|
||||
//XEvent e;
|
||||
int s;
|
||||
X11WindowData *data;
|
||||
|
||||
d = XOpenDisplay (NULL);
|
||||
if (d == NULL) {
|
||||
|
@ -93,15 +97,26 @@ platform_create_native_window (gint width, gint height)
|
|||
XStoreName (d, w, "eglglessink");
|
||||
XMapWindow (d, w);
|
||||
XFlush (d);
|
||||
|
||||
*window_data = data = g_slice_new0 (X11WindowData);
|
||||
data->display = d;
|
||||
|
||||
return (EGLNativeWindowType) w;
|
||||
}
|
||||
|
||||
gboolean
|
||||
platform_destroy_native_window (EGLNativeDisplayType display,
|
||||
EGLNativeWindowType window)
|
||||
EGLNativeWindowType window, gpointer * window_data)
|
||||
{
|
||||
X11WindowData *data = *window_data;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
#endif
|
||||
|
@ -109,7 +124,7 @@ platform_destroy_native_window (EGLNativeDisplayType display,
|
|||
#if !defined(HAVE_X11)
|
||||
/* Dummy functions for creating a native Window */
|
||||
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");
|
||||
return (EGLNativeWindowType) 0;
|
||||
|
@ -117,7 +132,7 @@ platform_create_native_window (gint width, gint height)
|
|||
|
||||
gboolean
|
||||
platform_destroy_native_window (EGLNativeDisplayType display,
|
||||
EGLNativeWindowType window)
|
||||
EGLNativeWindowType window, gpointer * window_data)
|
||||
{
|
||||
GST_ERROR ("Can't destroy native window");
|
||||
return TRUE;
|
||||
|
|
|
@ -54,11 +54,9 @@
|
|||
#include <EGL/egl.h>
|
||||
|
||||
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,
|
||||
EGLNativeWindowType w);
|
||||
EGLint *platform_crate_native_image_buffer (EGLNativeWindowType win,
|
||||
EGLConfig config, EGLNativeDisplayType display, const EGLint * egl_attribs);
|
||||
EGLNativeWindowType w, gpointer * window_data);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue