mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
[761/906] x11: Protect event display connection with a mutex
We use it from different threads and need to serialize the accesses to it.
This commit is contained in:
parent
9810469db0
commit
4f23429abb
2 changed files with 26 additions and 0 deletions
|
@ -120,6 +120,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
|
static void
|
||||||
gst_gl_window_x11_class_init (GstGLWindowX11Class * klass)
|
gst_gl_window_x11_class_init (GstGLWindowX11Class * 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->set_property = gst_gl_window_x11_set_property;
|
||||||
obj_class->get_property = gst_gl_window_x11_get_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_object_class_install_property (obj_class, ARG_DISPLAY,
|
||||||
g_param_spec_string ("display", "Display", "X Display name", NULL,
|
g_param_spec_string ("display", "Display", "X Display name", NULL,
|
||||||
|
@ -157,6 +172,8 @@ static void
|
||||||
gst_gl_window_x11_init (GstGLWindowX11 * window)
|
gst_gl_window_x11_init (GstGLWindowX11 * window)
|
||||||
{
|
{
|
||||||
window->priv = GST_GL_WINDOW_X11_GET_PRIVATE (window);
|
window->priv = GST_GL_WINDOW_X11_GET_PRIVATE (window);
|
||||||
|
|
||||||
|
g_mutex_init (&window->disp_send_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Must be called in the gl thread */
|
/* Must be called in the gl thread */
|
||||||
|
@ -398,7 +415,9 @@ gst_gl_window_x11_close (GstGLWindow * window)
|
||||||
//XCloseDisplay (window_x11->device);
|
//XCloseDisplay (window_x11->device);
|
||||||
|
|
||||||
GST_DEBUG ("display receiver closed");
|
GST_DEBUG ("display receiver closed");
|
||||||
|
g_mutex_lock (&window_x11->disp_send_lock);
|
||||||
XCloseDisplay (window_x11->disp_send);
|
XCloseDisplay (window_x11->disp_send);
|
||||||
|
g_mutex_unlock (&window_x11->disp_send_lock);
|
||||||
GST_DEBUG ("display sender closed");
|
GST_DEBUG ("display sender closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,6 +487,7 @@ gst_gl_window_x11_set_window_handle (GstGLWindow * window, guintptr id)
|
||||||
if (window_x11->running) {
|
if (window_x11->running) {
|
||||||
GST_LOG ("set parent window id: %lud", id);
|
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);
|
XGetWindowAttributes (window_x11->disp_send, window_x11->parent_win, &attr);
|
||||||
|
|
||||||
XResizeWindow (window_x11->disp_send, window_x11->internal_win_id,
|
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);
|
window_x11->parent_win, 0, 0);
|
||||||
|
|
||||||
XSync (window_x11->disp_send, FALSE);
|
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;
|
XEvent event;
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
|
|
||||||
|
g_mutex_lock (&window_x11->disp_send_lock);
|
||||||
|
|
||||||
XGetWindowAttributes (window_x11->disp_send, window_x11->internal_win_id,
|
XGetWindowAttributes (window_x11->disp_send, window_x11->internal_win_id,
|
||||||
&attr);
|
&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,
|
XSendEvent (window_x11->disp_send, window_x11->internal_win_id, FALSE,
|
||||||
ExposureMask, &event);
|
ExposureMask, &event);
|
||||||
XSync (window_x11->disp_send, FALSE);
|
XSync (window_x11->disp_send, FALSE);
|
||||||
|
|
||||||
|
g_mutex_unlock (&window_x11->disp_send_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ struct _GstGLWindowX11 {
|
||||||
|
|
||||||
/* We use a specific connection to send events */
|
/* We use a specific connection to send events */
|
||||||
Display *disp_send;
|
Display *disp_send;
|
||||||
|
GMutex disp_send_lock;
|
||||||
|
|
||||||
/* X window */
|
/* X window */
|
||||||
Window internal_win_id;
|
Window internal_win_id;
|
||||||
|
|
Loading…
Reference in a new issue