summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2012-12-26 10:34:21 +0100
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2013-01-09 11:38:24 +0100
commitec88c86fb1c50fabff706b6f150f00e333e97038 (patch)
tree5e7a50cc6d15aec2646b808f38caf1b9920ed56f
parent06a260337ce6295749ad3c6c7f81a09151dbd293 (diff)
eglglessink: Fix crash when closing internal X11 window
-rw-r--r--ext/eglgles/gsteglglessink.c4
-rw-r--r--ext/eglgles/gsteglglessink.h2
-rw-r--r--ext/eglgles/video_platform_wrapper.c27
-rw-r--r--ext/eglgles/video_platform_wrapper.h6
4 files changed, 27 insertions, 12 deletions
diff --git a/ext/eglgles/gsteglglessink.c b/ext/eglgles/gsteglglessink.c
index abe9d91ab..74b14384c 100644
--- a/ext/eglgles/gsteglglessink.c
+++ b/ext/eglgles/gsteglglessink.c
@@ -798,7 +798,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;
diff --git a/ext/eglgles/gsteglglessink.h b/ext/eglgles/gsteglglessink.h
index d57a8e116..f1f00c55b 100644
--- a/ext/eglgles/gsteglglessink.h
+++ b/ext/eglgles/gsteglglessink.h
@@ -203,6 +203,8 @@ struct _GstEglGlesSink
gboolean have_texture;
gboolean egl_started;
+ gpointer own_window_data;
+
GThread *thread;
gboolean thread_running;
GstDataQueue *queue;
diff --git a/ext/eglgles/video_platform_wrapper.c b/ext/eglgles/video_platform_wrapper.c
index ca622ed4d..bddb59475 100644
--- a/ext/eglgles/video_platform_wrapper.c
+++ b/ext/eglgles/video_platform_wrapper.c
@@ -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;
diff --git a/ext/eglgles/video_platform_wrapper.h b/ext/eglgles/video_platform_wrapper.h
index db27c572c..452a4cda3 100644
--- a/ext/eglgles/video_platform_wrapper.h
+++ b/ext/eglgles/video_platform_wrapper.h
@@ -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