3 * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
4 * Copyright (C) 2015 Thibault Saunier <tsaunier@gnome.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #include "gstgtkutils.h"
36 gst_gtk_invoke_func (struct invoke_context *info)
38 g_mutex_lock (&info->lock);
39 info->res = info->func (info->data);
41 g_cond_signal (&info->cond);
42 g_mutex_unlock (&info->lock);
44 return G_SOURCE_REMOVE;
48 gst_gtk_invoke_on_main (GThreadFunc func, gpointer data)
50 GMainContext *main_context = g_main_context_default ();
51 struct invoke_context info;
53 g_mutex_init (&info.lock);
54 g_cond_init (&info.cond);
59 g_main_context_invoke (main_context, (GSourceFunc) gst_gtk_invoke_func,
62 g_mutex_lock (&info.lock);
64 g_cond_wait (&info.cond, &info.lock);
65 g_mutex_unlock (&info.lock);
67 g_mutex_clear (&info.lock);
68 g_cond_clear (&info.cond);