[638/906] window: add get_proc_address + stub for retrieving gl functions
authorMatthew Waters <ystreet00@gmail.com>
Tue, 8 Jan 2013 06:40:39 +0000 (17:40 +1100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:26 +0000 (19:31 +0000)
gst-libs/gst/gl/gstglwindow.c
gst-libs/gst/gl/gstglwindow.h

index d323cca..c51e333 100644 (file)
@@ -22,6 +22,8 @@
 # include "config.h"
 #endif
 
+#include <gmodule.h>
+
 #include "gstglwindow.h"
 
 #ifdef HAVE_WINDOW_X11
@@ -59,6 +61,8 @@ gst_gl_window_init (GstGLWindow * window)
 static void
 gst_gl_window_class_init (GstGLWindowClass * klass)
 {
+  klass->get_proc_address =
+      GST_DEBUG_FUNCPTR (gst_gl_window_default_get_proc_address);
 }
 
 GstGLWindow *
@@ -322,3 +326,40 @@ gst_gl_window_get_gl_api (GstGLWindow * window)
 
   return ret;
 }
+
+gpointer
+gst_gl_window_get_proc_address (GstGLWindow * window, const gchar * name)
+{
+  gpointer ret;
+  GstGLWindowClass *window_class;
+
+  g_return_val_if_fail (GST_GL_IS_WINDOW (window), NULL);
+  window_class = GST_GL_WINDOW_GET_CLASS (window);
+  g_return_val_if_fail (window_class->get_proc_address != NULL, NULL);
+
+  GST_GL_WINDOW_LOCK (window);
+
+  ret = window_class->get_proc_address (window, name);
+
+  GST_GL_WINDOW_UNLOCK (window);
+
+  return ret;
+}
+
+gpointer
+gst_gl_window_default_get_proc_address (GstGLWindow * window,
+    const gchar * name)
+{
+  static GModule *module = NULL;
+  gpointer ret = NULL;
+
+  if (!module)
+    module = g_module_open (NULL, G_MODULE_BIND_LAZY);
+
+  if (module) {
+    if (!g_module_symbol (module, name, &ret))
+      return NULL;
+  }
+
+  return ret;
+}
index f396960..7c6cd9d 100644 (file)
@@ -55,6 +55,8 @@ typedef enum
 {
   GST_GL_WINDOW_ERROR_FAILED,
   GST_GL_WINDOW_ERROR_WRONG_CONFIG,
+  GST_GL_WINDOW_ERROR_WRONG_API,
+  GST_GL_WINDOW_ERROR_OLD_LIBS,
   GST_GL_WINDOW_ERROR_CREATE_CONTEXT,
   GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
 } GstGLWindowError;
@@ -96,6 +98,7 @@ struct _GstGLWindowClass {
 
   guintptr (*get_gl_context)     (GstGLWindow *window);
   GstGLAPI (*get_gl_api)         (GstGLWindow *window);
+  gpointer (*get_proc_address)   (GstGLWindow *window, const gchar *name);
   gboolean (*activate)           (GstGLWindow *window, gboolean activate);
   void     (*set_window_handle)  (GstGLWindow *window, guintptr id);
   gboolean (*share_context)      (GstGLWindow *window, guintptr external_gl_context);
@@ -131,8 +134,11 @@ void     gst_gl_window_run                  (GstGLWindow *window);
 void     gst_gl_window_quit                 (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
 void     gst_gl_window_send_message         (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
 
-GstGLPlatform gst_gl_window_get_platform (GstGLWindow *window);
-GstGLAPI      gst_gl_window_get_gl_api   (GstGLWindow *window);
+gpointer      gst_gl_window_get_proc_address (GstGLWindow *window, const gchar *name);
+GstGLPlatform gst_gl_window_get_platform     (GstGLWindow *window);
+GstGLAPI      gst_gl_window_get_gl_api       (GstGLWindow *window);
+
+gpointer gst_gl_window_default_get_proc_address (GstGLWindow *window, const gchar *name);
 
 GST_DEBUG_CATEGORY_EXTERN (gst_gl_window_debug);