diff options
author | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2011-01-17 23:59:48 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2011-01-17 23:59:48 +0000 |
commit | b311b833c1998bd8694cebe888a4b159b291023d (patch) | |
tree | bbda270ba43e01a3ec79c8e77b9426e54e9b9a72 | |
parent | 6ac2e5d3846b2038113ed2dda7c298e296faa938 (diff) |
app: make GstAppBuffer get_type() function thread-safe
-rw-r--r-- | gst-libs/gst/app/gstappbuffer.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/gst-libs/gst/app/gstappbuffer.c b/gst-libs/gst/app/gstappbuffer.c index 06f354f86..2fa72bb8a 100644 --- a/gst-libs/gst/app/gstappbuffer.c +++ b/gst-libs/gst/app/gstappbuffer.c @@ -37,9 +37,9 @@ static GstBufferClass *parent_class; GType gst_app_buffer_get_type (void) { - static GType _gst_app_buffer_type; + static volatile gsize app_buffer_type = 0; - if (G_UNLIKELY (_gst_app_buffer_type == 0)) { + if (g_once_init_enter (&app_buffer_type)) { static const GTypeInfo app_buffer_info = { sizeof (GstBufferClass), NULL, @@ -52,10 +52,12 @@ gst_app_buffer_get_type (void) (GInstanceInitFunc) gst_app_buffer_init, NULL }; - _gst_app_buffer_type = g_type_register_static (GST_TYPE_BUFFER, - "GstAppBuffer", &app_buffer_info, 0); + GType tmp = g_type_register_static (GST_TYPE_BUFFER, "GstAppBuffer", + &app_buffer_info, 0); + g_once_init_leave (&app_buffer_type, tmp); } - return _gst_app_buffer_type; + + return (GType) app_buffer_type; } static void |