summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2013-07-16 13:28:19 +0200
committerSebastian Dröge <slomo@circular-chaos.org>2013-07-16 13:28:19 +0200
commit8750d2d37b1a25ddd8dc486ca9c940e84a2ee7b0 (patch)
tree79d351f38ab3a86df77d91d598b0ee5cdb95ef22
parent3eeb9ea5976351f72070408b3ea73b96dfd372bf (diff)
x11: Protect event display connection with a mutex
We use it from different threads and need to serialize the accesses to it.
-rw-r--r--gst-libs/gst/gl/x11/gstglwindow_x11.c25
-rw-r--r--gst-libs/gst/gl/x11/gstglwindow_x11.h1
2 files changed, 26 insertions, 0 deletions
diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.c b/gst-libs/gst/gl/x11/gstglwindow_x11.c
index 7dc1cdb..5bcde3e 100644
--- a/gst-libs/gst/gl/x11/gstglwindow_x11.c
+++ b/gst-libs/gst/gl/x11/gstglwindow_x11.c
@@ -121,6 +121,20 @@ gst_gl_window_x11_get_property (GObject * object, guint prop_id,
}
static void
+gst_gl_window_x11_finalize (GObject * object)
+{
+ GstGLWindowX11 *window_x11;
+
+ g_return_if_fail (GST_GL_IS_WINDOW_X11 (object));
+
+ window_x11 = GST_GL_WINDOW_X11 (object);
+
+ g_mutex_clear (&window_x11->disp_send_lock);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
gst_gl_window_x11_class_init (GstGLWindowX11Class * klass)
{
GObjectClass *obj_class = G_OBJECT_CLASS (klass);
@@ -130,6 +144,7 @@ gst_gl_window_x11_class_init (GstGLWindowX11Class * klass)
obj_class->set_property = gst_gl_window_x11_set_property;
obj_class->get_property = gst_gl_window_x11_get_property;
+ obj_class->finalize = gst_gl_window_x11_finalize;
g_object_class_install_property (obj_class, ARG_DISPLAY,
g_param_spec_string ("display", "Display", "X Display name", NULL,
@@ -157,6 +172,8 @@ static void
gst_gl_window_x11_init (GstGLWindowX11 * window)
{
window->priv = GST_GL_WINDOW_X11_GET_PRIVATE (window);
+
+ g_mutex_init (&window->disp_send_lock);
}
/* Must be called in the gl thread */
@@ -398,7 +415,9 @@ gst_gl_window_x11_close (GstGLWindow * window)
//XCloseDisplay (window_x11->device);
GST_DEBUG ("display receiver closed");
+ g_mutex_lock (&window_x11->disp_send_lock);
XCloseDisplay (window_x11->disp_send);
+ g_mutex_unlock (&window_x11->disp_send_lock);
GST_DEBUG ("display sender closed");
}
@@ -468,6 +487,7 @@ gst_gl_window_x11_set_window_handle (GstGLWindow * window, guintptr id)
if (window_x11->running) {
GST_LOG ("set parent window id: %lud", id);
+ g_mutex_lock (&window_x11->disp_send_lock);
XGetWindowAttributes (window_x11->disp_send, window_x11->parent_win, &attr);
XResizeWindow (window_x11->disp_send, window_x11->internal_win_id,
@@ -477,6 +497,7 @@ gst_gl_window_x11_set_window_handle (GstGLWindow * window, guintptr id)
window_x11->parent_win, 0, 0);
XSync (window_x11->disp_send, FALSE);
+ g_mutex_unlock (&window_x11->disp_send_lock);
}
}
@@ -524,6 +545,8 @@ gst_gl_window_x11_draw (GstGLWindow * window, guint width, guint height)
XEvent event;
XWindowAttributes attr;
+ g_mutex_lock (&window_x11->disp_send_lock);
+
XGetWindowAttributes (window_x11->disp_send, window_x11->internal_win_id,
&attr);
@@ -572,6 +595,8 @@ gst_gl_window_x11_draw (GstGLWindow * window, guint width, guint height)
XSendEvent (window_x11->disp_send, window_x11->internal_win_id, FALSE,
ExposureMask, &event);
XSync (window_x11->disp_send, FALSE);
+
+ g_mutex_unlock (&window_x11->disp_send_lock);
}
}
diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.h b/gst-libs/gst/gl/x11/gstglwindow_x11.h
index 54f66b7..9e5f04a 100644
--- a/gst-libs/gst/gl/x11/gstglwindow_x11.h
+++ b/gst-libs/gst/gl/x11/gstglwindow_x11.h
@@ -65,6 +65,7 @@ struct _GstGLWindowX11 {
/* We use a specific connection to send events */
Display *disp_send;
+ GMutex disp_send_lock;
/* X window */
Window internal_win_id;