Commit 6f87bc23 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller
Browse files

rtsp: make public _get_type() functions thread-safe

parent d59558af
......@@ -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;
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,
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 (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
......
......@@ -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) \
......
......@@ -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;
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);
}
g_once (&once, (GThreadFunc) register_rtsp_url_type, &id);
return id;
return (GType) url_type;
}
static const struct
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment