X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=gst%2Fgstelementfactory.c;h=cf3b10077449d007ac2bc533a474dddb51779953;hb=5470f6df00595f4ab44871e0e633bf15006abc5c;hp=39d43ab93344abce848a63e99b16c6f38d044963;hpb=e8d0b019b33284eba03e737154f6c526bc7e6b66;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 39d43ab..cf3b100 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -23,6 +23,7 @@ /** * SECTION:gstelementfactory + * @title: GstElementFactory * @short_description: Create GstElements from a factory * @see_also: #GstElement, #GstPlugin, #GstPluginFeature, #GstPadTemplate. * @@ -36,9 +37,8 @@ * * The following code example shows you how to create a GstFileSrc element. * - * - * Using an element factory - * + * ## Using an element factory + * |[ * #include <gst/gst.h> * * GstElement *src; @@ -51,8 +51,7 @@ * src = gst_element_factory_create (srcfactory, "src"); * g_return_if_fail (src != NULL); * ... - * - * + * ]| */ #include "gst_private.h" @@ -231,9 +230,7 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank, return TRUE; } - factory = - GST_ELEMENT_FACTORY_CAST (g_object_newv (GST_TYPE_ELEMENT_FACTORY, 0, - NULL)); + factory = g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL); gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name); GST_LOG_OBJECT (factory, "Created new elementfactory for type %s", g_type_name (type)); @@ -370,10 +367,9 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name) * also set name as early as we can */ if (name) - element = - GST_ELEMENT_CAST (g_object_new (factory->type, "name", name, NULL)); + element = g_object_new (factory->type, "name", name, NULL); else - element = GST_ELEMENT_CAST (g_object_newv (factory->type, 0, NULL)); + element = g_object_new (factory->type, NULL); if (G_UNLIKELY (element == NULL)) goto no_element; @@ -386,6 +382,9 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name) if (!g_atomic_pointer_compare_and_exchange (&oclass->elementfactory, NULL, factory)) gst_object_unref (factory); + else + /* This ref will never be dropped as the class is never destroyed */ + GST_OBJECT_FLAG_SET (factory, GST_OBJECT_FLAG_MAY_BE_LEAKED); GST_DEBUG ("created element \"%s\"", GST_OBJECT_NAME (factory)); @@ -449,14 +448,12 @@ gst_element_factory_make (const gchar * factoryname, const gchar * name) gst_object_unref (factory); - GST_TRACER_ELEMENT_NEW (element); - return element; /* ERRORS */ no_factory: { - GST_INFO ("no such element factory \"%s\"!", factoryname); + GST_WARNING ("no such element factory \"%s\"!", factoryname); return NULL; } create_failed: @@ -512,6 +509,8 @@ const gchar * gst_element_factory_get_metadata (GstElementFactory * factory, const gchar * key) { + g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); + return gst_structure_get_string ((GstStructure *) factory->metadata, key); }