mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 13:36:39 +00:00
gst: make gst_init() thread-safe
Because we can, and there isn't really any reason not to do so.
This commit is contained in:
parent
82abf56e8e
commit
e0d4eccc1e
1 changed files with 6 additions and 0 deletions
|
@ -318,14 +318,18 @@ gst_init_get_option_group (void)
|
||||||
gboolean
|
gboolean
|
||||||
gst_init_check (int *argc, char **argv[], GError ** err)
|
gst_init_check (int *argc, char **argv[], GError ** err)
|
||||||
{
|
{
|
||||||
|
static GMutex init_lock;
|
||||||
#ifndef GST_DISABLE_OPTION_PARSING
|
#ifndef GST_DISABLE_OPTION_PARSING
|
||||||
GOptionGroup *group;
|
GOptionGroup *group;
|
||||||
GOptionContext *ctx;
|
GOptionContext *ctx;
|
||||||
#endif
|
#endif
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
|
g_mutex_lock (&init_lock);
|
||||||
|
|
||||||
if (gst_initialized) {
|
if (gst_initialized) {
|
||||||
GST_DEBUG ("already initialized gst");
|
GST_DEBUG ("already initialized gst");
|
||||||
|
g_mutex_unlock (&init_lock);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#ifndef GST_DISABLE_OPTION_PARSING
|
#ifndef GST_DISABLE_OPTION_PARSING
|
||||||
|
@ -350,6 +354,8 @@ gst_init_check (int *argc, char **argv[], GError ** err)
|
||||||
GST_INFO ("failed to initialize GStreamer");
|
GST_INFO ("failed to initialize GStreamer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_mutex_unlock (&init_lock);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue