window: fix GLX window initialization.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 27 May 2013 13:59:08 +0000 (15:59 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 27 May 2013 15:21:10 +0000 (17:21 +0200)
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

index 1c84250b763a6b699ba57a0028cc71ce43d269a0..d725178dee9edfc488cbfadb20661c1f268bc2a2 100644 (file)
@@ -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;
 }
 
 /**