summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2015-02-24 14:01:04 +0100
committerEdward Hervey <bilboed@bilboed.com>2015-02-24 14:46:10 +0100
commita4699b2b2ad95bcb7ab64d8323089c9112e93fb9 (patch)
tree8fe982e8994b90c2bc41e6dd860ad07fdd59411b
parentd88e599718023c16019662b744ba00e5f4bceac1 (diff)
glwindow: Deactivate window before changing handleandroid-gl
When setting a new window handle, we need to ensure all implementations will detect the change. For that we deactivate the context before setting the window handle, then reactivate the context
-rw-r--r--gst-libs/gst/gl/gstglwindow.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/gst-libs/gst/gl/gstglwindow.c b/gst-libs/gst/gl/gstglwindow.c
index 6916dced7..a42e30a23 100644
--- a/gst-libs/gst/gl/gstglwindow.c
+++ b/gst-libs/gst/gl/gstglwindow.c
@@ -290,6 +290,30 @@ gst_gl_window_finalize (GObject * object)
G_OBJECT_CLASS (gst_gl_window_parent_class)->finalize (object);
}
+typedef struct _GstSetWindowHandleCb
+{
+ GstGLWindow *window;
+ guintptr handle;
+} GstSetWindowHandleCb;
+
+static void
+_set_window_handle_cb (GstSetWindowHandleCb * data)
+{
+ GstGLContext *context = gst_gl_window_get_context (data->window);
+ GstGLWindowClass *window_class = GST_GL_WINDOW_GET_CLASS (data->window);
+
+ gst_gl_context_activate (context, FALSE);
+ window_class->set_window_handle (data->window, data->handle);
+ gst_gl_context_activate (context, TRUE);
+}
+
+static void
+_free_swh_cb (GstSetWindowHandleCb * data)
+{
+ gst_object_unref (data->window);
+ g_slice_free (GstSetWindowHandleCb, data);
+}
+
/**
* gst_gl_window_set_window_handle:
* @window: a #GstGLWindow
@@ -304,13 +328,23 @@ void
gst_gl_window_set_window_handle (GstGLWindow * window, guintptr handle)
{
GstGLWindowClass *window_class;
+ GstSetWindowHandleCb *data;
g_return_if_fail (GST_GL_IS_WINDOW (window));
g_return_if_fail (handle != 0);
window_class = GST_GL_WINDOW_GET_CLASS (window);
g_return_if_fail (window_class->set_window_handle != NULL);
- window_class->set_window_handle (window, handle);
+ data = g_slice_new (GstSetWindowHandleCb);
+ data->window = gst_object_ref (window);
+ data->handle = handle;
+
+ /* FIXME: Move to a message which deactivates, calls implementation, activates */
+ gst_gl_window_send_message_async (window,
+ (GstGLWindowCB) _set_window_handle_cb, data,
+ (GDestroyNotify) _free_swh_cb);
+
+ /* window_class->set_window_handle (window, handle); */
}
/**