2006-06-12 Wim Taymans <wim@fluendo.com>
+ * gst/gst.c: (gst_debug_help):
+ * gst/gstplugin.c: (gst_plugin_finalize), (gst_plugin_list_free):
+ * gst/gstpluginfeature.c: (gst_plugin_feature_finalize),
+ (gst_plugin_feature_list_free):
+ * gst/gstregistry.c: (gst_registry_add_plugin),
+ (gst_registry_add_feature), (gst_registry_plugin_filter),
+ (gst_registry_feature_filter), (gst_registry_find_plugin),
+ (gst_registry_find_feature), (gst_registry_get_plugin_list),
+ (gst_registry_lookup_feature_locked), (gst_registry_lookup_locked):
+ * gst/gstregistryxml.c: (load_feature),
+ (gst_registry_xml_read_cache), (gst_registry_xml_write_cache):
+ * gst/gstminiobject.c: (gst_mini_object_unref),
+ (gst_mini_object_replace), (gst_value_mini_object_free),
+ (gst_value_mini_object_copy):
+ Use _CAST macros to avoid unneeded type checking.
+ Added some more G_UNLIKELY.
+
+2006-06-12 Wim Taymans <wim@fluendo.com>
+
* gst/gstbuffer.h:
Avoid unneeded type checking.
API: GST_BUFFER_IS_DISCONT
/* FIXME this is gross. why don't debug have categories PluginFeatures? */
for (g = list2; g; g = g_list_next (g)) {
- GstPlugin *plugin = GST_PLUGIN (g->data);
+ GstPlugin *plugin = GST_PLUGIN_CAST (g->data);
gst_plugin_load (plugin);
}
GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) - 1);
#endif
- if (g_atomic_int_dec_and_test (&mini_object->refcount)) {
+ if (G_UNLIKELY (g_atomic_int_dec_and_test (&mini_object->refcount))) {
gst_mini_object_free (mini_object);
}
}
{
GstMiniObject *olddata_val;
+#ifdef DEBUG_REFCOUNT
+ GST_CAT_LOG (GST_CAT_REFCOUNTING, "replace %p (%d) with %p (%d)",
+ *olddata, *olddata ? (*olddata)->refcount : 0,
+ newdata, newdata ? newdata->refcount : 0);
+#endif
+
if (newdata)
gst_mini_object_ref (newdata);
gst_value_mini_object_free (GValue * value)
{
if (value->data[0].v_pointer) {
- gst_mini_object_unref (GST_MINI_OBJECT (value->data[0].v_pointer));
+ gst_mini_object_unref (GST_MINI_OBJECT_CAST (value->data[0].v_pointer));
}
}
{
if (src_value->data[0].v_pointer) {
dest_value->data[0].v_pointer =
- gst_mini_object_ref (GST_MINI_OBJECT (src_value->data[0].v_pointer));
+ gst_mini_object_ref (GST_MINI_OBJECT_CAST (src_value->data[0].
+ v_pointer));
} else {
dest_value->data[0].v_pointer = NULL;
}
static void
gst_plugin_finalize (GObject * object)
{
- GstPlugin *plugin = GST_PLUGIN (object);
+ GstPlugin *plugin = GST_PLUGIN_CAST (object);
GstRegistry *registry = gst_registry_get_default ();
GList *g;
GList *g;
for (g = list; g; g = g->next) {
- gst_object_unref (GST_PLUGIN (g->data));
+ gst_object_unref (GST_PLUGIN_CAST (g->data));
}
g_list_free (list);
}
static void
gst_plugin_feature_finalize (GObject * object)
{
- GstPluginFeature *feature = GST_PLUGIN_FEATURE (object);
+ GstPluginFeature *feature = GST_PLUGIN_FEATURE_CAST (object);
GST_DEBUG ("finalizing feature %p: '%s'", feature,
GST_PLUGIN_FEATURE_NAME (feature));
GList *g;
for (g = list; g; g = g->next) {
- GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data);
+ GstPluginFeature *feature = GST_PLUGIN_FEATURE_CAST (g->data);
gst_object_unref (feature);
}
GST_OBJECT_LOCK (registry);
existing_plugin = gst_registry_lookup_locked (registry, plugin->filename);
- if (existing_plugin) {
+ if (G_UNLIKELY (existing_plugin)) {
GST_DEBUG_OBJECT (registry,
"Replacing existing plugin %p with new plugin %p for filename \"%s\"",
existing_plugin, plugin, GST_STR_NULL (plugin->filename));
GST_OBJECT_LOCK (registry);
existing_feature = gst_registry_lookup_feature_locked (registry,
feature->name);
- if (existing_feature) {
+ if (G_UNLIKELY (existing_feature)) {
GST_DEBUG_OBJECT (registry, "Replacing existing feature %p (%s)",
existing_feature, feature->name);
registry->features = g_list_remove (registry->features, existing_feature);
list = gst_filter_run (registry->plugins, (GstFilterFunc) filter, first,
user_data);
for (g = list; g; g = g->next) {
- gst_object_ref (GST_PLUGIN (g->data));
+ gst_object_ref (GST_PLUGIN_CAST (g->data));
}
GST_OBJECT_UNLOCK (registry);
list = gst_filter_run (registry->features, (GstFilterFunc) filter, first,
user_data);
for (g = list; g; g = g->next) {
- gst_object_ref (GST_PLUGIN_FEATURE (g->data));
+ gst_object_ref (GST_PLUGIN_FEATURE_CAST (g->data));
}
GST_OBJECT_UNLOCK (registry);
walk = gst_registry_plugin_filter (registry,
(GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name);
if (walk) {
- result = GST_PLUGIN (walk->data);
+ result = GST_PLUGIN_CAST (walk->data);
gst_object_ref (result);
gst_plugin_list_free (walk);
TRUE, &data);
if (walk) {
- feature = GST_PLUGIN_FEATURE (walk->data);
+ feature = GST_PLUGIN_FEATURE_CAST (walk->data);
gst_object_ref (feature);
gst_plugin_feature_list_free (walk);
GST_OBJECT_LOCK (registry);
list = g_list_copy (registry->plugins);
for (g = list; g; g = g->next) {
- gst_object_ref (GST_PLUGIN (g->data));
+ gst_object_ref (GST_PLUGIN_CAST (g->data));
}
GST_OBJECT_UNLOCK (registry);
GList *g;
GstPluginFeature *feature;
- if (name == NULL)
+ if (G_UNLIKELY (name == NULL))
return NULL;
for (g = registry->features; g; g = g_list_next (g)) {
- feature = GST_PLUGIN_FEATURE (g->data);
+ feature = GST_PLUGIN_FEATURE_CAST (g->data);
if (feature->name && strcmp (name, feature->name) == 0) {
return feature;
}
GstPlugin *plugin;
gchar *basename;
- if (filename == NULL)
+ if (G_UNLIKELY (filename == NULL))
return NULL;
basename = g_path_get_basename (filename);
for (g = registry->plugins; g; g = g_list_next (g)) {
- plugin = GST_PLUGIN (g->data);
+ plugin = GST_PLUGIN_CAST (g->data);
if (plugin->basename && strcmp (basename, plugin->basename) == 0) {
g_free (basename);
return plugin;
if (g_str_equal (tag, "name"))
read_string (reader, &feature->name, FALSE);
- if (g_str_equal (tag, "rank"))
+ else if (g_str_equal (tag, "rank"))
read_uint (reader, &feature->rank);
+
if (GST_IS_ELEMENT_FACTORY (feature)) {
- GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
+ GstElementFactory *factory = GST_ELEMENT_FACTORY_CAST (feature);
if (g_str_equal (tag, "longname")) {
int ret;
GST_DEBUG ("adding plugin %s", plugin->desc.name);
gst_registry_add_plugin (registry, plugin);
for (g = feature_list; g; g = g_list_next (g)) {
- gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (g->data));
+ gst_registry_add_feature (registry,
+ GST_PLUGIN_FEATURE_CAST (g->data));
}
g_list_free (feature_list);
}
for (walk = g_list_last (registry->plugins); walk;
walk = g_list_previous (walk)) {
- GstPlugin *plugin = GST_PLUGIN (walk->data);
+ GstPlugin *plugin = GST_PLUGIN_CAST (walk->data);
if (!plugin->filename)
continue;