window->priv = GST_GL_WINDOW_GET_PRIVATE (window);
g_mutex_init (&window->lock);
- window->need_lock = TRUE;
window->is_drawing = FALSE;
g_weak_ref_init (&window->context_ref, NULL);
window_class = GST_GL_WINDOW_GET_CLASS (window);
g_return_if_fail (window_class->set_window_handle != NULL);
- GST_GL_WINDOW_LOCK (window);
window_class->set_window_handle (window, handle);
- GST_GL_WINDOW_UNLOCK (window);
}
/**
window_class = GST_GL_WINDOW_GET_CLASS (window);
g_return_if_fail (window_class->draw != NULL);
- GST_GL_WINDOW_LOCK (window);
-
/* avoid to overload the drawer */
if (window->is_drawing) {
- GST_GL_WINDOW_UNLOCK (window);
return;
}
window_class->draw (window, width, height);
- GST_GL_WINDOW_UNLOCK (window);
}
/**
window_class = GST_GL_WINDOW_GET_CLASS (window);
g_return_if_fail (window_class->run != NULL);
- GST_GL_WINDOW_LOCK (window);
window->priv->alive = TRUE;
window_class->run (window);
- GST_GL_WINDOW_UNLOCK (window);
}
/**
GST_INFO ("quit sent to gl window loop");
GST_GL_WINDOW_UNLOCK (window);
-
- GST_INFO ("quit received from gl window");
}
typedef struct _GstGLSyncMessage
window_class = GST_GL_WINDOW_GET_CLASS (window);
g_return_if_fail (window_class->send_message != NULL);
- GST_GL_WINDOW_LOCK (window);
window_class->send_message (window, callback, data);
- GST_GL_WINDOW_UNLOCK (window);
}
/**
}
/**
- * gst_gl_window_set_need_lock:
- * @window: a #GstGLWindow
- * @need_lock: whether the @window needs to lock for concurrent access
- *
- * This API is intended only for subclasses of #GstGLWindow in order to ensure
- * correct interaction with the underlying window system.
- */
-void
-gst_gl_window_set_need_lock (GstGLWindow * window, gboolean need_lock)
-{
- g_return_if_fail (GST_GL_IS_WINDOW (window));
-
- window->need_lock = need_lock;
-}
-
-/**
* gst_gl_window_set_draw_callback:
* @window: a #GstGLWindow
* @callback: (scope notified): function to invoke
guintptr
gst_gl_window_get_display (GstGLWindow * window)
{
- guintptr ret;
GstGLWindowClass *window_class;
g_return_val_if_fail (GST_GL_IS_WINDOW (window), 0);
window_class = GST_GL_WINDOW_GET_CLASS (window);
g_return_val_if_fail (window_class->get_display != NULL, 0);
- GST_GL_WINDOW_LOCK (window);
-
- ret = window_class->get_display (window);
-
- GST_GL_WINDOW_UNLOCK (window);
-
- return ret;
+ return window_class->get_display (window);
}
/**
guintptr
gst_gl_window_get_window_handle (GstGLWindow * window)
{
- guintptr ret;
GstGLWindowClass *window_class;
g_return_val_if_fail (GST_GL_IS_WINDOW (window), 0);
window_class = GST_GL_WINDOW_GET_CLASS (window);
g_return_val_if_fail (window_class->get_window_handle != NULL, 0);
- GST_GL_WINDOW_LOCK (window);
-
- ret = window_class->get_window_handle (window);
-
- GST_GL_WINDOW_UNLOCK (window);
-
- return ret;
+ return window_class->get_window_handle (window);
}
/**
#define GST_GL_IS_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_GL_TYPE_WINDOW))
#define GST_GL_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_GL_TYPE_WINDOW, GstGLWindowClass))
-#define GST_GL_WINDOW_LOCK(w) \
- do { \
- if (GST_GL_WINDOW(w)->need_lock) \
- g_mutex_lock (&GST_GL_WINDOW(w)->lock); \
- } while (0)
-
-#define GST_GL_WINDOW_UNLOCK(w) \
- do { \
- if (GST_GL_WINDOW(w)->need_lock) \
- g_mutex_unlock (&GST_GL_WINDOW(w)->lock); \
- } while (0)
-
+#define GST_GL_WINDOW_LOCK(w) g_mutex_lock(&GST_GL_WINDOW(w)->lock)
+#define GST_GL_WINDOW_UNLOCK(w) g_mutex_unlock(&GST_GL_WINDOW(w)->lock)
#define GST_GL_WINDOW_GET_LOCK(w) (&GST_GL_WINDOW(w)->lock)
#define GST_GL_WINDOW_ERROR (gst_gl_window_error_quark ())
GObject parent;
GMutex lock;
- gboolean need_lock;
GWeakRef context_ref;
void gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data, GDestroyNotify destroy_notify);
void gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowResizeCB callback, gpointer data, GDestroyNotify destroy_notify);
void gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data, GDestroyNotify destroy_notify);
-void gst_gl_window_set_need_lock (GstGLWindow *window, gboolean need_lock);
void gst_gl_window_set_window_handle (GstGLWindow *window, guintptr handle);
guintptr gst_gl_window_get_window_handle (GstGLWindow *window);