rtsp: make public _get_type() functions thread-safe

This commit is contained in:
Tim-Philipp Müller 2010-10-08 11:23:33 +01:00
parent d59558af87
commit 6f87bc2307
3 changed files with 30 additions and 32 deletions

View file

@ -54,25 +54,25 @@ static guint gst_rtsp_extension_signals[LAST_SIGNAL] = { 0 };
GType
gst_rtsp_extension_get_type (void)
{
static GType gst_rtsp_extension_type = 0;
static volatile gsize gst_rtsp_extension_type = 0;
static const GTypeInfo gst_rtsp_extension_info = {
sizeof (GstRTSPExtensionInterface),
(GBaseInitFunc) gst_rtsp_extension_iface_init,
NULL,
NULL,
NULL,
NULL,
0,
0,
NULL,
};
if (!gst_rtsp_extension_type) {
static const GTypeInfo gst_rtsp_extension_info = {
sizeof (GstRTSPExtensionInterface),
(GBaseInitFunc) gst_rtsp_extension_iface_init,
NULL,
NULL,
NULL,
NULL,
0,
0,
NULL,
};
gst_rtsp_extension_type = g_type_register_static (G_TYPE_INTERFACE,
if (g_once_init_enter (&gst_rtsp_extension_type)) {
GType tmp = g_type_register_static (G_TYPE_INTERFACE,
"GstRTSPExtension", &gst_rtsp_extension_info, 0);
g_once_init_leave (&gst_rtsp_extension_type, tmp);
}
return gst_rtsp_extension_type;
return (GType) gst_rtsp_extension_type;
}
static void

View file

@ -117,7 +117,7 @@ static const RTSPLTransMap ltrans[] = {
GType
gst_rtsp_lower_trans_get_type (void)
{
static GType rtsp_lower_trans_type = 0;
static volatile gsize rtsp_lower_trans_type = 0;
static const GFlagsValue rtsp_lower_trans[] = {
{GST_RTSP_LOWER_TRANS_UDP, "GST_RTSP_LOWER_TRANS_UDP", "udp-unicast"},
{GST_RTSP_LOWER_TRANS_UDP_MCAST, "GST_RTSP_LOWER_TRANS_UDP_MCAST",
@ -127,11 +127,12 @@ gst_rtsp_lower_trans_get_type (void)
{0, NULL, NULL},
};
if (!rtsp_lower_trans_type) {
rtsp_lower_trans_type =
g_flags_register_static ("GstRTSPLowerTrans", rtsp_lower_trans);
if (g_once_init_enter (&rtsp_lower_trans_type)) {
GType tmp = g_flags_register_static ("GstRTSPLowerTrans", rtsp_lower_trans);
g_once_init_leave (&rtsp_lower_trans_type, tmp);
}
return rtsp_lower_trans_type;
return (GType) rtsp_lower_trans_type;
}
#define RTSP_TRANSPORT_PARAMETER_IS_UNIQUE(param) \

View file

@ -54,21 +54,18 @@
#include "gstrtspurl.h"
static void
register_rtsp_url_type (GType * id)
{
*id = g_boxed_type_register_static ("GstRTSPUrl",
(GBoxedCopyFunc) gst_rtsp_url_copy, (GBoxedFreeFunc) gst_rtsp_url_free);
}
GType
gst_rtsp_url_get_type (void)
{
static GType id;
static GOnce once = G_ONCE_INIT;
static volatile gsize url_type = 0;
g_once (&once, (GThreadFunc) register_rtsp_url_type, &id);
return id;
if (g_once_init_enter (&url_type)) {
GType tmp = g_boxed_type_register_static ("GstRTSPUrl",
(GBoxedCopyFunc) gst_rtsp_url_copy, (GBoxedFreeFunc) gst_rtsp_url_free);
g_once_init_leave (&url_type, tmp);
}
return (GType) url_type;
}
static const struct