From 8f156591e54dfc04d21fa695bb123b200062fac7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 24 Apr 2014 18:33:03 +0200 Subject: [PATCH] gl/x11: Get rid of unneeded second display connection and do everything from the main loop --- gst-libs/gst/gl/x11/gstglwindow_x11.c | 47 ++++++++++++++--------------------- gst-libs/gst/gl/x11/gstglwindow_x11.h | 4 --- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.c b/gst-libs/gst/gl/x11/gstglwindow_x11.c index fd08b7d..9704637 100644 --- a/gst-libs/gst/gl/x11/gstglwindow_x11.c +++ b/gst-libs/gst/gl/x11/gstglwindow_x11.c @@ -85,8 +85,6 @@ gst_gl_window_x11_finalize (GObject * object) window_x11 = GST_GL_WINDOW_X11 (object); - g_mutex_clear (&window_x11->disp_send_lock); - G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -120,8 +118,6 @@ 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 */ @@ -160,13 +156,6 @@ gst_gl_window_x11_open (GstGLWindow * window, GError ** error) GST_LOG ("gl device id: %ld", (gulong) window_x11->device); -// window_x11->disp_send = XOpenDisplay (DisplayString (display_x11->display)); - window_x11->disp_send = XOpenDisplay (display_x11->name); - - XSynchronize (window_x11->disp_send, FALSE); - - GST_LOG ("gl display sender: %ld", (gulong) window_x11->disp_send); - window_x11->screen = DefaultScreenOfDisplay (window_x11->device); window_x11->screen_num = DefaultScreen (window_x11->device); window_x11->visual = @@ -276,8 +265,6 @@ gst_gl_window_x11_close (GstGLWindow * window) GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window); XEvent event; - g_mutex_lock (&window_x11->disp_send_lock); - if (window_x11->device) { if (window_x11->internal_win_id) XUnmapWindow (window_x11->device, window_x11->internal_win_id); @@ -296,9 +283,6 @@ gst_gl_window_x11_close (GstGLWindow * window) XCloseDisplay (window_x11->device); GST_DEBUG ("display receiver closed"); - - XCloseDisplay (window_x11->disp_send); - GST_DEBUG ("display sender closed"); } g_source_destroy (window_x11->x11_source); @@ -310,8 +294,23 @@ gst_gl_window_x11_close (GstGLWindow * window) window_x11->main_context = NULL; window_x11->running = FALSE; +} + +static void +set_window_handle_cb (gpointer data) +{ + GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (data); + XWindowAttributes attr; + + XGetWindowAttributes (window_x11->device, window_x11->parent_win, &attr); + + XResizeWindow (window_x11->device, window_x11->internal_win_id, + attr.width, attr.height); + + XReparentWindow (window_x11->device, window_x11->internal_win_id, + window_x11->parent_win, 0, 0); - g_mutex_unlock (&window_x11->disp_send_lock); + XSync (window_x11->device, FALSE); } /* Not called by the gl thread */ @@ -319,7 +318,6 @@ void gst_gl_window_x11_set_window_handle (GstGLWindow * window, guintptr id) { GstGLWindowX11 *window_x11; - XWindowAttributes attr; window_x11 = GST_GL_WINDOW_X11 (window); @@ -332,17 +330,8 @@ gst_gl_window_x11_set_window_handle (GstGLWindow * window, guintptr id) if (window_x11->loop && g_main_loop_is_running (window_x11->loop)) { GST_LOG ("set parent window id: %" G_GUINTPTR_FORMAT, 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, - attr.width, attr.height); - - XReparentWindow (window_x11->disp_send, window_x11->internal_win_id, - window_x11->parent_win, 0, 0); - - XSync (window_x11->disp_send, FALSE); - g_mutex_unlock (&window_x11->disp_send_lock); + gst_gl_window_send_message (window, (GstGLWindowCB) set_window_handle_cb, + window_x11); } } diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.h b/gst-libs/gst/gl/x11/gstglwindow_x11.h index 26509f1..02a3aaa 100644 --- a/gst-libs/gst/gl/x11/gstglwindow_x11.h +++ b/gst-libs/gst/gl/x11/gstglwindow_x11.h @@ -68,10 +68,6 @@ struct _GstGLWindowX11 XVisualInfo *visual_info; Window parent_win; - /* We use a specific connection to send events */ - Display *disp_send; - GMutex disp_send_lock; - /* X window */ Window internal_win_id; -- 2.7.4