From 2bd5f3ad46469cf7b5b88b65dce9b2653306586b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 29 Jul 2004 15:29:37 +0000 Subject: [PATCH] gst/gstpad.c: check that caps are fixed Original commit message from CVS: * gst/gstpad.c: (gst_pad_set_explicit_caps): check that caps are fixed * gst/gstpad.c: (gst_pad_template_new): don't try to simplify caps, costs too much time on gst_init * gst/gstplugin.c: (gst_plugin_add_feature): G_ERROR if features are added twice * gst/gsttypefind.c: (gst_type_find_register): * gst/gstelementfactory.c: (gst_element_register): don't add features twice * docs/random/ds/0.9-suggested-changes: add note about possible gst_init optimization --- ChangeLog | 14 ++++++++++++++ docs/random/ds/0.9-suggested-changes | 4 ++++ gst/gstelementfactory.c | 5 ++--- gst/gstpad.c | 6 +++++- gst/gstplugin.c | 12 +++++++++++- gst/gsttypefind.c | 3 +-- 6 files changed, 37 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7dcf66df24..40984f0021 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-07-29 Benjamin Otte + + * gst/gstpad.c: (gst_pad_set_explicit_caps): + check that caps are fixed + * gst/gstpad.c: (gst_pad_template_new): + don't try to simplify caps, costs too much time on gst_init + * gst/gstplugin.c: (gst_plugin_add_feature): + G_ERROR if features are added twice + * gst/gsttypefind.c: (gst_type_find_register): + * gst/gstelementfactory.c: (gst_element_register): + don't add features twice + * docs/random/ds/0.9-suggested-changes: + add note about possible gst_init optimization + 2004-07-28 David Schleef * testsuite/elements/Makefile.am: diff --git a/docs/random/ds/0.9-suggested-changes b/docs/random/ds/0.9-suggested-changes index c5eb3370d7..40fcf64272 100644 --- a/docs/random/ds/0.9-suggested-changes +++ b/docs/random/ds/0.9-suggested-changes @@ -140,3 +140,7 @@ object hierarchy: - make this explicit by having a list of keywords instead of a fixed string with slashes - fix the editor/el browser to display this nicely + +- optimization: + - delay parsing caps from the registry until after startup (until they're + first requested or maybe an idle handler for the main loop) diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 7e7a547b3b..32fefb51e6 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -214,20 +214,20 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank, factory = gst_element_factory_find (name); if (!factory) { - klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); factory = GST_ELEMENT_FACTORY (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL)); gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name); GST_LOG_OBJECT (factory, "Created new elementfactory for type %s", g_type_name (type)); + gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); } else { g_return_val_if_fail (factory->type == 0, FALSE); - klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); gst_element_factory_cleanup (factory); GST_LOG_OBJECT (factory, "Reuse existing elementfactory for type %s", g_type_name (type)); } + klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); factory->type = type; __gst_element_details_copy (&factory->details, &klass->details); factory->padtemplates = g_list_copy (klass->padtemplates); @@ -257,7 +257,6 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank, g_free (interfaces); gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank); - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); return TRUE; diff --git a/gst/gstpad.c b/gst/gstpad.c index 15a013a7d3..d5badb3bc2 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2463,6 +2463,7 @@ gst_pad_set_explicit_caps (GstPad * pad, const GstCaps * caps) GstPadLinkReturn link_ret; g_return_val_if_fail (GST_IS_PAD (pad), FALSE); + g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE); GST_CAT_DEBUG (GST_CAT_PADS, "setting explicit caps on %s:%s to %" GST_PTR_FORMAT, @@ -3652,6 +3653,10 @@ gst_pad_template_new (const gchar * name_template, g_return_val_if_fail (name_template != NULL, NULL); g_return_val_if_fail (caps != NULL, NULL); + g_return_val_if_fail (direction == GST_PAD_SRC + || direction == GST_PAD_SINK, NULL); + g_return_val_if_fail (presence == GST_PAD_ALWAYS + || presence == GST_PAD_SOMETIMES || presence == GST_PAD_REQUEST, NULL); if (!name_is_valid (name_template, presence)) return NULL; @@ -3672,7 +3677,6 @@ gst_pad_template_new (const gchar * name_template, GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (name_template); GST_PAD_TEMPLATE_DIRECTION (new) = direction; GST_PAD_TEMPLATE_PRESENCE (new) = presence; - gst_caps_do_simplify (caps); GST_PAD_TEMPLATE_CAPS (new) = caps; return new; diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 3eed73bf97..209ad3f327 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -790,6 +790,8 @@ gst_plugin_add_feature (GstPlugin * plugin, GstPluginFeature * feature) { GstPluginFeature *oldfeature; + /* FIXME 0.9: get reference counting somewhat right in here, GstPluginFeatures + * should probably be GstObjects that are sinked when adding them to a plugin */ g_return_if_fail (plugin != NULL); g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature)); g_return_if_fail (feature != NULL); @@ -797,7 +799,15 @@ gst_plugin_add_feature (GstPlugin * plugin, GstPluginFeature * feature) oldfeature = gst_plugin_find_feature (plugin, GST_PLUGIN_FEATURE_NAME (feature), G_OBJECT_TYPE (feature)); - if (!oldfeature) { + if (oldfeature == feature) { + GST_ERROR ("feature %s has already been added", + GST_PLUGIN_FEATURE_NAME (feature)); + /* g_object_unref (feature); */ + } else if (oldfeature) { + GST_ERROR ("feature %s already present in plugin", + GST_PLUGIN_FEATURE_NAME (feature)); + /* g_object_unref (feature); */ + } else { feature->manager = plugin; plugin->features = g_list_prepend (plugin->features, feature); plugin->numfeatures++; diff --git a/gst/gsttypefind.c b/gst/gsttypefind.c index 578175d51e..e6ae25f7af 100644 --- a/gst/gsttypefind.c +++ b/gst/gsttypefind.c @@ -239,6 +239,7 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank, GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name); g_assert (GST_IS_TYPE_FIND_FACTORY (factory)); gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name); + gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); } else { GST_DEBUG_OBJECT (factory, "using old typefind factory for %s", name); } @@ -252,8 +253,6 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank, factory->function = func; factory->user_data = data; - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - return TRUE; }