[751/906] gldisplay: Don't hold lock while sending a message to the GL thread

https://bugzilla.gnome.org/show_bug.cgi?id=704247
This commit is contained in:
Sebastian Dröge 2013-07-15 15:25:57 +02:00 committed by Matthew Waters
parent 60aefacd32
commit 7dba9d0dce

View file

@ -41,12 +41,10 @@ G_DEFINE_TYPE_WITH_CODE (GstGLDisplay, gst_gl_display, G_TYPE_OBJECT,
(G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_DISPLAY, GstGLDisplayPrivate)) (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_DISPLAY, GstGLDisplayPrivate))
static void gst_gl_display_finalize (GObject * object); static void gst_gl_display_finalize (GObject * object);
static void _gst_gl_display_thread_run_generic (GstGLDisplay * display);
struct _GstGLDisplayPrivate struct _GstGLDisplayPrivate
{ {
GstGLDisplayThreadFunc func; gint dummy;
gpointer data;
}; };
/*------------------------------------------------------------ /*------------------------------------------------------------
@ -91,13 +89,21 @@ gst_gl_display_finalize (GObject * object)
G_OBJECT_CLASS (gst_gl_display_parent_class)->finalize (object); G_OBJECT_CLASS (gst_gl_display_parent_class)->finalize (object);
} }
static void typedef struct
_gst_gl_display_thread_run_generic (GstGLDisplay * display)
{ {
GST_TRACE ("running function:%p data:%p", GstGLDisplay *display;
display->priv->func, display->priv->data); GstGLDisplayThreadFunc func;
gpointer data;
} RunGenericData;
display->priv->func (display, display->priv->data); static void
_gst_gl_display_thread_run_generic (RunGenericData * data)
{
GST_TRACE ("running function:%p data:%p", data->func, data->data);
data->func (data->display, data->data);
g_object_unref (data->display);
g_slice_free (RunGenericData, data);
} }
GstGLDisplay * GstGLDisplay *
@ -110,19 +116,19 @@ void
gst_gl_display_thread_add (GstGLDisplay * display, gst_gl_display_thread_add (GstGLDisplay * display,
GstGLDisplayThreadFunc func, gpointer data) GstGLDisplayThreadFunc func, gpointer data)
{ {
RunGenericData *rdata;
g_return_if_fail (GST_IS_GL_DISPLAY (display)); g_return_if_fail (GST_IS_GL_DISPLAY (display));
g_return_if_fail (GST_GL_IS_WINDOW (display->window)); g_return_if_fail (GST_GL_IS_WINDOW (display->window));
g_return_if_fail (func != NULL); g_return_if_fail (func != NULL);
gst_gl_display_lock (display); rdata = g_slice_new (RunGenericData);
rdata->display = g_object_ref (display);
display->priv->data = data; rdata->data = data;
display->priv->func = func; rdata->func = func;
gst_gl_window_send_message (display->window, gst_gl_window_send_message (display->window,
GST_GL_WINDOW_CB (_gst_gl_display_thread_run_generic), display); GST_GL_WINDOW_CB (_gst_gl_display_thread_run_generic), rdata);
gst_gl_display_unlock (display);
} }
GstGLAPI GstGLAPI