[gst-cvs] gstreamer: controller, dataprotocol: make public enum _get_type() functions thread-safe
Tim Müller
tpm at kemper.freedesktop.org
Fri Oct 8 01:35:54 PDT 2010
Module: gstreamer
Branch: master
Commit: 9bd4432d08a3452c704da01ddf0d5525320bff48
URL: http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=9bd4432d08a3452c704da01ddf0d5525320bff48
Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date: Fri Oct 8 09:34:47 2010 +0100
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.
---
libs/gst/controller/gstlfocontrolsource.c | 39 +++++++++++++++--------------
libs/gst/dataprotocol/dataprotocol.c | 11 ++++---
2 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/libs/gst/controller/gstlfocontrolsource.c b/libs/gst/controller/gstlfocontrolsource.c
index 97e1ba7..f2c6d6b 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 (>ype)) {
+ GType tmp = g_enum_register_static ("GstLFOWaveform", values);
+ g_once_init_leave (>ype, 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 5e413b0..b57d377 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;
};
/**
More information about the Gstreamer-commits
mailing list