mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 03:29:50 +00:00
tests: make *_get_type() in tests thread safe
Even if it shouldn't be needed here. See #623491.
This commit is contained in:
parent
9d4caf8d8c
commit
f6b0200026
3 changed files with 17 additions and 11 deletions
|
@ -42,15 +42,16 @@ struct _GstFakeObjectClass
|
|||
GstObjectClass parent_class;
|
||||
};
|
||||
|
||||
static GType _gst_fake_object_type = 0;
|
||||
|
||||
//static GstObjectClass *parent_class = NULL;
|
||||
//static guint gst_fake_object_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GType
|
||||
gst_fake_object_get_type (void)
|
||||
{
|
||||
if (!_gst_fake_object_type) {
|
||||
static volatile gsize fake_object_type = 0;
|
||||
|
||||
if (g_once_init_enter (&fake_object_type)) {
|
||||
GType type;
|
||||
static const GTypeInfo fake_object_info = {
|
||||
sizeof (GstFakeObjectClass),
|
||||
NULL, //gst_fake_object_base_class_init,
|
||||
|
@ -64,10 +65,11 @@ gst_fake_object_get_type (void)
|
|||
NULL
|
||||
};
|
||||
|
||||
_gst_fake_object_type = g_type_register_static (GST_TYPE_OBJECT,
|
||||
type = g_type_register_static (GST_TYPE_OBJECT,
|
||||
"GstFakeObject", &fake_object_info, 0);
|
||||
g_once_init_leave (&fake_object_type, type);
|
||||
}
|
||||
return _gst_fake_object_type;
|
||||
return fake_object_type;
|
||||
}
|
||||
|
||||
#ifndef HAVE_OSX
|
||||
|
|
|
@ -112,9 +112,10 @@ gst_preset_test_base_init (GstPresetTestClass * klass)
|
|||
static GType
|
||||
gst_preset_test_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
static volatile gsize preset_test_type = 0;
|
||||
|
||||
if (type == 0) {
|
||||
if (g_once_init_enter (&preset_test_type)) {
|
||||
GType type;
|
||||
const GTypeInfo info = {
|
||||
sizeof (GstPresetTestClass),
|
||||
(GBaseInitFunc) gst_preset_test_base_init, /* base_init */
|
||||
|
@ -134,8 +135,9 @@ gst_preset_test_get_type (void)
|
|||
};
|
||||
type = g_type_register_static (GST_TYPE_ELEMENT, "GstPresetTest", &info, 0);
|
||||
g_type_add_interface_static (type, GST_TYPE_PRESET, &preset_interface_info);
|
||||
g_once_init_leave (&preset_test_type, type);
|
||||
}
|
||||
return type;
|
||||
return preset_test_type;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -191,9 +191,10 @@ gst_test_mono_source_base_init (GstTestMonoSourceClass * klass)
|
|||
static GType
|
||||
gst_test_mono_source_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
static volatile gsize test_mono_source_type = 0;
|
||||
|
||||
if (type == 0) {
|
||||
if (g_once_init_enter (&test_mono_source_type)) {
|
||||
GType type;
|
||||
static const GTypeInfo info = {
|
||||
(guint16) sizeof (GstTestMonoSourceClass),
|
||||
(GBaseInitFunc) gst_test_mono_source_base_init, // base_init
|
||||
|
@ -209,8 +210,9 @@ gst_test_mono_source_get_type (void)
|
|||
type =
|
||||
g_type_register_static (GST_TYPE_ELEMENT, "GstTestMonoSource", &info,
|
||||
0);
|
||||
g_once_init_leave (&test_mono_source_type, type);
|
||||
}
|
||||
return type;
|
||||
return test_mono_source_type;
|
||||
}
|
||||
|
||||
/* so we don't have to paste the gst_element_register into 50 places below */
|
||||
|
|
Loading…
Reference in a new issue