And actually call the close callback when the window is closed.
guint height);
void gst_gl_window_cocoa_draw (GstGLWindow * window, guint width, guint height);
void gst_gl_window_cocoa_run (GstGLWindow * window);
-void gst_gl_window_cocoa_quit (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data);
+void gst_gl_window_cocoa_quit (GstGLWindow * window);
void gst_gl_window_cocoa_send_message (GstGLWindow * window,
GstGLWindowCB callback, gpointer data);
GstGLAPI gst_gl_window_cocoa_get_gl_api (GstGLWindow * window);
/* Thread safe */
void
-gst_gl_window_cocoa_quit (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data)
+gst_gl_window_cocoa_quit (GstGLWindow * window)
{
GstGLWindowCocoa *window_cocoa;
GstGLWindowCocoaPrivate *priv;
if (GSRegisterCurrentThread() || 1) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- AppThreadPerformer* app_thread_performer = [[AppThreadPerformer alloc]
- initWithAll:window_cocoa callback:callback userData:data];
-
[app_thread_performer performSelector:@selector(stopApp) onThread:priv->thread
withObject:nil waitUntilDone:YES];
{
GstGLWindow *window = GST_GL_WINDOW (object);
- if (window) {
- gst_gl_window_set_resize_callback (window, NULL, NULL);
- gst_gl_window_set_draw_callback (window, NULL, NULL);
- gst_gl_window_set_close_callback (window, NULL, NULL);
-
- if (window->priv->alive) {
- GST_INFO ("send quit gl window loop");
- gst_gl_window_quit (window, NULL, NULL);
- }
+ gst_gl_window_set_resize_callback (window, NULL, NULL, NULL);
+ gst_gl_window_set_draw_callback (window, NULL, NULL, NULL);
+
+ if (window->priv->alive) {
+ GST_INFO ("send quit gl window loop");
+ gst_gl_window_quit (window);
}
+ gst_gl_window_set_close_callback (window, NULL, NULL, NULL);
+
if (window->priv->gl_thread) {
gpointer ret = g_thread_join (window->priv->gl_thread);
GST_INFO ("gl thread joined");
}
void
-gst_gl_window_quit (GstGLWindow * window, GstGLWindowCB callback, gpointer data)
+gst_gl_window_quit (GstGLWindow * window)
{
GstGLWindowClass *window_class;
window->priv->alive = FALSE;
- window->close = callback;
- window->close_data = data;
- window_class->quit (window, callback, data);
+ window_class->quit (window);
GST_INFO ("quit sent to gl window loop");
void
gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data)
+ gpointer data, GDestroyNotify destroy_notify)
{
g_return_if_fail (GST_GL_IS_WINDOW (window));
GST_GL_WINDOW_LOCK (window);
+ if (window->draw_notify)
+ window->draw_notify (window->draw_data);
+
window->draw = callback;
window->draw_data = data;
+ window->draw_notify = destroy_notify;
GST_GL_WINDOW_UNLOCK (window);
}
void
gst_gl_window_set_resize_callback (GstGLWindow * window,
- GstGLWindowResizeCB callback, gpointer data)
+ GstGLWindowResizeCB callback, gpointer data, GDestroyNotify destroy_notify)
{
g_return_if_fail (GST_GL_IS_WINDOW (window));
GST_GL_WINDOW_LOCK (window);
+ if (window->resize_notify)
+ window->resize_notify (window->resize_data);
+
window->resize = callback;
window->resize_data = data;
+ window->resize_notify = destroy_notify;
GST_GL_WINDOW_UNLOCK (window);
}
void
gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data)
+ gpointer data, GDestroyNotify destroy_notify)
{
g_return_if_fail (GST_GL_IS_WINDOW (window));
GST_GL_WINDOW_LOCK (window);
+ if (window->close_notify)
+ window->close_notify (window->close_data);
+
window->close = callback;
window->close_data = data;
+ window->close_notify = destroy_notify;
GST_GL_WINDOW_UNLOCK (window);
}
if (window_class->close) {
window_class->close (window);
+ if (window->close)
+ window->close (window->close_data);
}
g_cond_signal (&window->priv->cond_destroy_context);
GstGLWindowCB draw;
gpointer draw_data;
+ GDestroyNotify draw_notify;
GstGLWindowCB close;
gpointer close_data;
+ GDestroyNotify close_notify;
GstGLWindowResizeCB resize;
gpointer resize_data;
+ GDestroyNotify resize_notify;
/*< private >*/
gpointer _reserved[GST_PADDING];
void (*draw_unlocked) (GstGLWindow *window, guint width, guint height);
void (*draw) (GstGLWindow *window, guint width, guint height);
void (*run) (GstGLWindow *window);
- void (*quit) (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
+ void (*quit) (GstGLWindow *window);
void (*send_message) (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
gboolean (*open) (GstGLWindow *window, GError **error);
GstGLWindow * gst_gl_window_new (GstGLDisplay *display);
-void gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
-void gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowResizeCB callback, gpointer data);
-void gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
+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);
guintptr gst_gl_window_get_gl_context (GstGLWindow *window);
void gst_gl_window_draw_unlocked (GstGLWindow *window, guint width, guint height);
void gst_gl_window_draw (GstGLWindow *window, guint width, guint height);
void gst_gl_window_run (GstGLWindow *window);
-void gst_gl_window_quit (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
+void gst_gl_window_quit (GstGLWindow *window);
void gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointer data);
gpointer gst_gl_window_get_proc_address (GstGLWindow *window, const gchar *name);
static void gst_gl_window_wayland_egl_draw (GstGLWindow * window, guint width,
guint height);
static void gst_gl_window_wayland_egl_run (GstGLWindow * window);
-static void gst_gl_window_wayland_egl_quit (GstGLWindow * window,
- GstGLWindowCB callback, gpointer data);
+static void gst_gl_window_wayland_egl_quit (GstGLWindow * window);
static void gst_gl_window_wayland_egl_send_message (GstGLWindow * window,
GstGLWindowCB callback, gpointer data);
static void gst_gl_window_wayland_egl_destroy_context (GstGLWindowWaylandEGL *
}
static void
-gst_gl_window_wayland_egl_quit (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data)
+gst_gl_window_wayland_egl_quit (GstGLWindow * window)
{
GstGLWindowWaylandEGL *window_egl;
window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
- if (callback)
- gst_gl_window_wayland_egl_send_message (window, callback, data);
-
GST_LOG ("sending quit");
g_main_loop_quit (window_egl->loop);
guint height);
void gst_gl_window_win32_draw (GstGLWindow * window, guint width, guint height);
void gst_gl_window_win32_run (GstGLWindow * window);
-void gst_gl_window_win32_quit (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data);
+void gst_gl_window_win32_quit (GstGLWindow * window);
void gst_gl_window_win32_send_message (GstGLWindow * window,
GstGLWindowCB callback, gpointer data);
/* Thread safe */
void
-gst_gl_window_win32_quit (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data)
+gst_gl_window_win32_quit (GstGLWindow * window)
{
GstGLWindowWin32 *window_win32;
if (window_win32 && window_win32->internal_win_id) {
LRESULT res =
PostMessage (window_win32->internal_win_id, WM_GST_GL_WINDOW_QUIT,
- (WPARAM) data, (LPARAM) callback);
+ (WPARAM) 0, (LPARAM) 0);
GST_DEBUG ("end loop requested");
g_return_if_fail (SUCCEEDED (res));
}
case WM_GST_GL_WINDOW_QUIT:
{
HWND parent_id = 0;
- GstGLWindowCB destroy_cb = (GstGLWindowCB) lParam;
GST_DEBUG ("WM_GST_GL_WINDOW_QUIT\n");
- if (destroy_cb)
- destroy_cb ((gpointer) wParam);
-
parent_id = window_win32->parent_win_id;
if (parent_id) {
WNDPROC parent_proc = GetProp (parent_id, "gl_window_parent_proc");
guint height);
void gst_gl_window_x11_draw (GstGLWindow * window, guint width, guint height);
void gst_gl_window_x11_run (GstGLWindow * window);
-void gst_gl_window_x11_quit (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data);
+void gst_gl_window_x11_quit (GstGLWindow * window);
void gst_gl_window_x11_send_message (GstGLWindow * window,
GstGLWindowCB callback, gpointer data);
gboolean gst_gl_window_x11_create_context (GstGLWindow * window,
/* Not called by the gl thread */
void
-gst_gl_window_x11_quit (GstGLWindow * window, GstGLWindowCB callback,
- gpointer data)
+gst_gl_window_x11_quit (GstGLWindow * window)
{
GstGLWindowX11 *window_x11;
window_x11 = GST_GL_WINDOW_X11 (window);
- if (callback)
- gst_gl_window_x11_send_message (window, callback, data);
-
GST_LOG ("sending quit");
g_main_loop_quit (window_x11->loop);
/* setup callbacks */
gst_gl_window_set_resize_callback (window,
- GST_GL_WINDOW_RESIZE_CB (gst_glimage_sink_on_resize), glimage_sink);
+ GST_GL_WINDOW_RESIZE_CB (gst_glimage_sink_on_resize),
+ gst_object_ref (glimage_sink), (GDestroyNotify) gst_object_unref);
gst_gl_window_set_draw_callback (window,
- GST_GL_WINDOW_CB (gst_glimage_sink_on_draw), glimage_sink);
+ GST_GL_WINDOW_CB (gst_glimage_sink_on_draw),
+ gst_object_ref (glimage_sink), (GDestroyNotify) gst_object_unref);
gst_gl_window_set_close_callback (window,
- GST_GL_WINDOW_CB (gst_glimage_sink_on_close), glimage_sink);
+ GST_GL_WINDOW_CB (gst_glimage_sink_on_close),
+ gst_object_ref (glimage_sink), (GDestroyNotify) gst_object_unref);
gst_object_unref (window);
}
if (glimage_sink->display) {
GstGLWindow *window = gst_gl_display_get_window (glimage_sink->display);
- gst_gl_window_set_resize_callback (window, NULL, NULL);
- gst_gl_window_set_draw_callback (window, NULL, NULL);
- gst_gl_window_set_close_callback (window, NULL, NULL);
+ gst_gl_window_set_resize_callback (window, NULL, NULL, NULL);
+ gst_gl_window_set_draw_callback (window, NULL, NULL, NULL);
+ gst_gl_window_set_close_callback (window, NULL, NULL, NULL);
gst_object_unref (window);
gst_object_unref (glimage_sink->display);