GstGLContextGLX *context_glx;
GstGLWindow *window;
GstGLWindowX11 *window_x11;
- GstGLDisplay *display;
+ GstGLDisplay *display = NULL;
gboolean create_context;
const char *glx_exts;
Display *device;
context_glx = GST_GL_CONTEXT_GLX (context);
window = gst_gl_context_get_window (context);
+
+ if (!GST_IS_GL_WINDOW_X11 (window)) {
+ g_set_error (error, GST_GL_CONTEXT_ERROR,
+ GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
+ "Cannot create an GLX context from a non-X11 window");
+ goto failure;
+ }
+
window_x11 = GST_GL_WINDOW_X11 (window);
display = gst_gl_context_get_display (context);
}
device = (Display *) gst_gl_display_get_handle (display);
+ if (!device) {
+ g_set_error (error, GST_GL_CONTEXT_ERROR,
+ GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE, "Invalid Display handle");
+ goto failure;
+ }
+
glx_exts = glXQueryExtensionsString (device, DefaultScreen (device));
create_context = gst_gl_check_extension ("GLX_ARB_create_context", glx_exts);
failure:
if (window)
gst_object_unref (window);
- gst_object_unref (display);
+ if (display)
+ gst_object_unref (display);
return FALSE;
}
context_glx = GST_GL_CONTEXT_GLX (context);
window = gst_gl_context_get_window (context);
+
+ if (!GST_IS_GL_WINDOW_X11 (window)) {
+ g_set_error (error, GST_GL_CONTEXT_ERROR,
+ GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
+ "Cannot create an GLX context from a non-X11 window");
+ goto failure;
+ }
window_x11 = GST_GL_WINDOW_X11 (window);
+
device = (Display *) gst_gl_display_get_handle (window->display);
+ if (!device) {
+ g_set_error (error, GST_GL_CONTEXT_ERROR,
+ GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE, "Invalid Display handle");
+ goto failure;
+ }
if (!glXQueryExtension (device, &error_base, &event_base)) {
g_set_error (error, GST_GL_CONTEXT_ERROR,