meta: handle multiple implementation registration

First check that we can actually register the implementation before
making a GstMetaInfo. If we can't register we would otherwise end
up with an undefined type and an invalid GstMetaInfo.

It's possible that type registration fails because another metadata
with the same implementation name was already registered.
This commit is contained in:
Wim Taymans 2012-10-03 13:35:20 +02:00
parent cc43752c3c
commit 10c8586902

View file

@ -142,14 +142,20 @@ gst_meta_register (GType api, const gchar * impl, gsize size,
GstMetaTransformFunction transform_func)
{
GstMetaInfo *info;
GType type;
g_return_val_if_fail (api != 0, NULL);
g_return_val_if_fail (impl != NULL, NULL);
g_return_val_if_fail (size != 0, NULL);
/* first try to register the implementation name. It's possible
* that this fails because it was already registered. */
type = g_pointer_type_register_static (impl);
g_return_val_if_fail (type != 0, NULL);
info = g_slice_new (GstMetaInfo);
info->api = api;
info->type = g_pointer_type_register_static (impl);
info->type = type;
info->size = size;
info->init_func = init_func;
info->free_func = free_func;