summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2010-10-08 09:34:47 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2010-10-08 09:34:47 +0100
commit9bd4432d08a3452c704da01ddf0d5525320bff48 (patch)
tree16d126be2bf6188237eed81c079246cabd1f9351
parentc7e3bab65d143dc62f21218917bf447f248a8758 (diff)
controller, dataprotocol: make public enum _get_type() functions thread-safe
Not that it is likely to matter in practice, but since these are public API they should probably be thread-safe.
-rw-r--r--libs/gst/controller/gstlfocontrolsource.c39
-rw-r--r--libs/gst/dataprotocol/dataprotocol.c11
2 files changed, 26 insertions, 24 deletions
diff --git a/libs/gst/controller/gstlfocontrolsource.c b/libs/gst/controller/gstlfocontrolsource.c
index 97e1ba7ba..f2c6d6b2b 100644
--- a/libs/gst/controller/gstlfocontrolsource.c
+++ b/libs/gst/controller/gstlfocontrolsource.c
@@ -580,26 +580,27 @@ enum
GType
gst_lfo_waveform_get_type (void)
{
- static GType gtype = 0;
-
- if (gtype == 0) {
- static const GEnumValue values[] = {
- {GST_LFO_WAVEFORM_SINE, "GST_LFO_WAVEFORM_SINE",
- "sine"},
- {GST_LFO_WAVEFORM_SQUARE, "GST_LFO_WAVEFORM_SQUARE",
- "square"},
- {GST_LFO_WAVEFORM_SAW, "GST_LFO_WAVEFORM_SAW",
- "saw"},
- {GST_LFO_WAVEFORM_REVERSE_SAW, "GST_LFO_WAVEFORM_REVERSE_SAW",
- "reverse-saw"},
- {GST_LFO_WAVEFORM_TRIANGLE, "GST_LFO_WAVEFORM_TRIANGLE",
- "triangle"},
- {0, NULL, NULL}
- };
-
- gtype = g_enum_register_static ("GstLFOWaveform", values);
+ static gsize gtype = 0;
+ static const GEnumValue values[] = {
+ {GST_LFO_WAVEFORM_SINE, "GST_LFO_WAVEFORM_SINE",
+ "sine"},
+ {GST_LFO_WAVEFORM_SQUARE, "GST_LFO_WAVEFORM_SQUARE",
+ "square"},
+ {GST_LFO_WAVEFORM_SAW, "GST_LFO_WAVEFORM_SAW",
+ "saw"},
+ {GST_LFO_WAVEFORM_REVERSE_SAW, "GST_LFO_WAVEFORM_REVERSE_SAW",
+ "reverse-saw"},
+ {GST_LFO_WAVEFORM_TRIANGLE, "GST_LFO_WAVEFORM_TRIANGLE",
+ "triangle"},
+ {0, NULL, NULL}
+ };
+
+ if (g_once_init_enter (&gtype)) {
+ GType tmp = g_enum_register_static ("GstLFOWaveform", values);
+ g_once_init_leave (&gtype, tmp);
}
- return gtype;
+
+ return (GType) gtype;
}
G_DEFINE_TYPE (GstLFOControlSource, gst_lfo_control_source,
diff --git a/libs/gst/dataprotocol/dataprotocol.c b/libs/gst/dataprotocol/dataprotocol.c
index 5e413b05a..b57d377d6 100644
--- a/libs/gst/dataprotocol/dataprotocol.c
+++ b/libs/gst/dataprotocol/dataprotocol.c
@@ -292,18 +292,19 @@ gst_dp_dump_byte_array (guint8 * array, guint length)
GType
gst_dp_version_get_type (void)
{
- static GType gst_dp_version_type = 0;
+ static gsize gst_dp_version_type = 0;
static const GEnumValue gst_dp_version[] = {
{GST_DP_VERSION_0_2, "GST_DP_VERSION_0_2", "0.2"},
{GST_DP_VERSION_1_0, "GST_DP_VERSION_1_0", "1.0"},
{0, NULL, NULL},
};
- if (!gst_dp_version_type) {
- gst_dp_version_type =
- g_enum_register_static ("GstDPVersion", gst_dp_version);
+ if (g_once_init_enter (&gst_dp_version_type)) {
+ GType tmp = g_enum_register_static ("GstDPVersion", gst_dp_version);
+ g_once_init_leave (&gst_dp_version_type, tmp);
}
- return gst_dp_version_type;
+
+ return (GType) gst_dp_version_type;
};
/**