Commit ed19974e authored by Wim Taymans's avatar Wim Taymans
Browse files

meta: do metadata registration threadsafe

We need to use g_once to register the metadata implementations
only once.

See https://bugzilla.gnome.org/show_bug.cgi?id=685332
parent 10c85869
......@@ -453,13 +453,14 @@ my_example_meta_get_info (void)
{
static const GstMetaInfo *meta_info = NULL;
if (meta_info == NULL) {
meta_info = gst_meta_register (MY_EXAMPLE_META_API_TYPE,
if (g_once_init_enter (&meta_info)) {
const GstMetaInfo *mi = gst_meta_register (MY_EXAMPLE_META_API_TYPE,
"MyExampleMeta",
sizeof (MyExampleMeta),
my_example_meta_init,
my_example_meta_free,
my_example_meta_transform);
g_once_init_leave (&meta_info, mi);
}
return meta_info;
}
......
......@@ -82,12 +82,13 @@ gst_net_address_meta_get_info (void)
{
static const GstMetaInfo *meta_info = NULL;
if (meta_info == NULL) {
meta_info = gst_meta_register (GST_NET_ADDRESS_META_API_TYPE,
if (g_once_init_enter (&meta_info)) {
const GstMetaInfo *mi = gst_meta_register (GST_NET_ADDRESS_META_API_TYPE,
"GstNetAddressMeta",
sizeof (GstNetAddressMeta),
net_address_meta_init,
net_address_meta_free, net_address_meta_transform);
g_once_init_leave (&meta_info, mi);
}
return meta_info;
}
......
......@@ -139,11 +139,12 @@ gst_meta_test_get_info (void)
{
static const GstMetaInfo *meta_test_info = NULL;
if (meta_test_info == NULL) {
meta_test_info = gst_meta_register (GST_META_TEST_API_TYPE,
if (g_once_init_enter (&meta_test_info)) {
const GstMetaInfo *mi = gst_meta_register (GST_META_TEST_API_TYPE,
"GstMetaTest",
sizeof (GstMetaTest),
test_init_func, test_free_func, test_transform_func);
g_once_init_leave (&meta_test_info, mi);
}
return meta_test_info;
}
......
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