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.
This commit is contained in:
Nicolas Dufresne 2017-03-22 13:33:47 -04:00
parent 2c056563bf
commit d486074a9c

View file

@ -123,10 +123,11 @@ _gst_param_fraction_values_cmp (GParamSpec * pspec, const GValue * value1,
GType GType
gst_param_spec_fraction_get_type (void) gst_param_spec_fraction_get_type (void)
{ {
static GType type; /* 0 */ static volatile GType gst_faction_type = 0;
/* register GST_TYPE_PARAM_FRACTION */ /* register GST_TYPE_PARAM_FRACTION */
if (type == 0) { if (g_once_init_enter (&gst_faction_type)) {
GType type;
static GParamSpecTypeInfo pspec_info = { static GParamSpecTypeInfo pspec_info = {
sizeof (GstParamSpecFraction), /* instance_size */ sizeof (GstParamSpecFraction), /* instance_size */
0, /* n_preallocs */ 0, /* n_preallocs */
@ -139,8 +140,10 @@ gst_param_spec_fraction_get_type (void)
}; };
pspec_info.value_type = GST_TYPE_FRACTION; pspec_info.value_type = GST_TYPE_FRACTION;
type = g_param_type_register_static ("GstParamFraction", &pspec_info); 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 GType
gst_param_spec_array_get_type (void) gst_param_spec_array_get_type (void)
{ {
static GType type; /* 0 */ static volatile GType gst_array_type = 0;
/* register GST_TYPE_PARAM_FRACTION */ /* register GST_TYPE_PARAM_FRACTION */
if (type == 0) { if (g_once_init_enter (&gst_array_type)) {
GType type;
static GParamSpecTypeInfo pspec_info = { static GParamSpecTypeInfo pspec_info = {
sizeof (GstParamSpecArray), /* instance_size */ sizeof (GstParamSpecArray), /* instance_size */
0, /* n_preallocs */ 0, /* n_preallocs */
@ -315,8 +319,10 @@ gst_param_spec_array_get_type (void)
}; };
pspec_info.value_type = gst_value_array_get_type (); pspec_info.value_type = gst_value_array_get_type ();
type = g_param_type_register_static ("GstParamArray", &pspec_info); type = g_param_type_register_static ("GstParamArray", &pspec_info);
g_once_init_leave (&gst_array_type, type);
} }
return type;
return gst_array_type;
} }
/** /**