From 382542c74797b52b4c665c0b66a3f36a68fadd7a Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Mon, 27 May 2013 15:59:08 +0200 Subject: [PATCH] window: fix GLX window initialization. Make sure to create the GLX context once the window object has completed its creation. Since gl_resize() relies on the newly created window size, then we cannot simply overload the GstVaapiWindowClass::create() hook. So, we just call into gst_vaapi_window_glx_ensure_context() once the window object is created in the gst_vaapi_window_glx_new*() functions. --- gst-libs/gst/vaapi/gstvaapiwindow_glx.c | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_glx.c b/gst-libs/gst/vaapi/gstvaapiwindow_glx.c index 1c84250b76..d725178dee 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow_glx.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow_glx.c @@ -363,10 +363,22 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE( GstVaapiWindow * gst_vaapi_window_glx_new(GstVaapiDisplay *display, guint width, guint height) { + GstVaapiWindow *window; + g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_GLX(display), NULL); - return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS( + window = gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS( gst_vaapi_window_glx_class()), display, width, height); + if (!window) + return NULL; + + if (!gst_vaapi_window_glx_ensure_context(window, NULL)) + goto error; + return window; + +error: + gst_vaapi_window_unref(window); + return NULL; } /** @@ -384,13 +396,25 @@ gst_vaapi_window_glx_new(GstVaapiDisplay *display, guint width, guint height) GstVaapiWindow * gst_vaapi_window_glx_new_with_xid(GstVaapiDisplay *display, Window xid) { + GstVaapiWindow *window; + GST_DEBUG("new window from xid 0x%08x", xid); g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_GLX(display), NULL); g_return_val_if_fail(xid != None, NULL); - return gst_vaapi_window_new_from_native(GST_VAAPI_WINDOW_CLASS( + window = gst_vaapi_window_new_from_native(GST_VAAPI_WINDOW_CLASS( gst_vaapi_window_glx_class()), display, GINT_TO_POINTER(xid)); + if (!window) + return NULL; + + if (!gst_vaapi_window_glx_ensure_context(window, NULL)) + goto error; + return window; + +error: + gst_vaapi_window_unref(window); + return NULL; } /**