summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2017-03-22 17:33:47 (GMT)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2017-03-24 17:30:45 (GMT)
commitd486074a9c6d0215586582c31f5223313797668f (patch)
tree7d2b97c13f22594b865add775ab076bccc6eb710
parent2c056563bf0b82e52cc38629accf7fe7d855a73c (diff)
downloadgstreamer-d486074a9c6d0215586582c31f5223313797668f.tar.gz
gstreamer-d486074a9c6d0215586582c31f5223313797668f.tar.xz
fraction/array: Make get_type() thread safe
Those aren't suppose to be called from multiple thread, but all fundamental get_type() function are thread safe. Fix it to be consistent and it may help if we change the typing mechanism in GStreamer come day.
-rw-r--r--gst/gstparamspecs.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/gst/gstparamspecs.c b/gst/gstparamspecs.c
index 61acc7a..8882062 100644
--- a/gst/gstparamspecs.c
+++ b/gst/gstparamspecs.c
@@ -123,10 +123,11 @@ _gst_param_fraction_values_cmp (GParamSpec * pspec, const GValue * value1,
GType
gst_param_spec_fraction_get_type (void)
{
- static GType type; /* 0 */
+ static volatile GType gst_faction_type = 0;
/* register GST_TYPE_PARAM_FRACTION */
- if (type == 0) {
+ if (g_once_init_enter (&gst_faction_type)) {
+ GType type;
static GParamSpecTypeInfo pspec_info = {
sizeof (GstParamSpecFraction), /* instance_size */
0, /* n_preallocs */
@@ -139,8 +140,10 @@ gst_param_spec_fraction_get_type (void)
};
pspec_info.value_type = GST_TYPE_FRACTION;
type = g_param_type_register_static ("GstParamFraction", &pspec_info);
+ g_once_init_leave (&gst_faction_type, type);
}
- return type;
+
+ return gst_faction_type;
}
/**
@@ -299,10 +302,11 @@ _gst_param_array_values_cmp (GParamSpec * pspec, const GValue * value1,
GType
gst_param_spec_array_get_type (void)
{
- static GType type; /* 0 */
+ static volatile GType gst_array_type = 0;
/* register GST_TYPE_PARAM_FRACTION */
- if (type == 0) {
+ if (g_once_init_enter (&gst_array_type)) {
+ GType type;
static GParamSpecTypeInfo pspec_info = {
sizeof (GstParamSpecArray), /* instance_size */
0, /* n_preallocs */
@@ -315,8 +319,10 @@ gst_param_spec_array_get_type (void)
};
pspec_info.value_type = gst_value_array_get_type ();
type = g_param_type_register_static ("GstParamArray", &pspec_info);
+ g_once_init_leave (&gst_array_type, type);
}
- return type;
+
+ return gst_array_type;
}
/**