inputselector: make pad's get_type function thread-safe

This commit is contained in:
Tim-Philipp Müller 2010-12-31 12:08:19 +00:00
parent 07e2428afd
commit 7f7721511c

View file

@ -157,9 +157,7 @@ static GstFlowReturn gst_selector_pad_bufferalloc (GstPad * pad,
static GType static GType
gst_selector_pad_get_type (void) gst_selector_pad_get_type (void)
{ {
static GType selector_pad_type = 0; static volatile gsize selector_pad_type = 0;
if (!selector_pad_type) {
static const GTypeInfo selector_pad_info = { static const GTypeInfo selector_pad_info = {
sizeof (GstSelectorPadClass), sizeof (GstSelectorPadClass),
NULL, NULL,
@ -172,11 +170,13 @@ gst_selector_pad_get_type (void)
(GInstanceInitFunc) gst_selector_pad_init, (GInstanceInitFunc) gst_selector_pad_init,
}; };
selector_pad_type = if (g_once_init_enter (&selector_pad_type)) {
g_type_register_static (GST_TYPE_PAD, "GstSelectorPad", GType tmp = g_type_register_static (GST_TYPE_PAD, "GstSelectorPad",
&selector_pad_info, 0); &selector_pad_info, 0);
g_once_init_leave (&selector_pad_type, tmp);
} }
return selector_pad_type;
return (GType) selector_pad_type;
} }
static void static void