From 9e792ee5b8aa7f5e4f3addea3ba579b84581a4a0 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Sat, 24 Oct 2009 10:05:59 +0200 Subject: [PATCH] gstregistry: Add a cookie for detecting feature list changes We also create a private structure, since we will need to add more data there in following patches. --- gst/gstregistry.c | 14 ++++++++++++++ gst/gstregistry.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gst/gstregistry.c b/gst/gstregistry.c index 23f61ada28..4a603f2ee4 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c @@ -116,6 +116,12 @@ #define GST_CAT_DEFAULT GST_CAT_REGISTRY +struct _GstRegistryPrivate +{ + /* updated whenever the feature list changes */ + guint32 cookie; +}; + /* the one instance of the default registry and the mutex protecting the * variable. */ static GStaticMutex _gst_registry_mutex = G_STATIC_MUTEX_INIT; @@ -166,6 +172,7 @@ gst_registry_class_init (GstRegistryClass * klass) gobject_class = (GObjectClass *) klass; parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (GstRegistryPrivate)); /** * GstRegistry::plugin-added: @@ -201,6 +208,9 @@ gst_registry_init (GstRegistry * registry) { registry->feature_hash = g_hash_table_new (g_str_hash, g_str_equal); registry->basename_hash = g_hash_table_new (g_str_hash, g_str_equal); + registry->private = + G_TYPE_INSTANCE_GET_PRIVATE (registry, GST_TYPE_REGISTRY, + GstRegistryPrivate); } static void @@ -425,6 +435,7 @@ gst_registry_remove_features_for_plugin_unlocked (GstRegistry * registry, } f = next; } + registry->private->cookie++; } /** @@ -500,6 +511,8 @@ gst_registry_add_feature (GstRegistry * registry, GstPluginFeature * feature) } gst_object_ref_sink (feature); + + registry->private->cookie++; GST_OBJECT_UNLOCK (registry); GST_LOG_OBJECT (registry, "emitting feature-added for %s", feature->name); @@ -529,6 +542,7 @@ gst_registry_remove_feature (GstRegistry * registry, GstPluginFeature * feature) GST_OBJECT_LOCK (registry); registry->features = g_list_remove (registry->features, feature); g_hash_table_remove (registry->feature_hash, feature->name); + registry->private->cookie++; GST_OBJECT_UNLOCK (registry); gst_object_unref (feature); } diff --git a/gst/gstregistry.h b/gst/gstregistry.h index 201acf4883..946bb4cb51 100644 --- a/gst/gstregistry.h +++ b/gst/gstregistry.h @@ -39,6 +39,7 @@ G_BEGIN_DECLS typedef struct _GstRegistry GstRegistry; typedef struct _GstRegistryClass GstRegistryClass; +typedef struct _GstRegistryPrivate GstRegistryPrivate; /** * GstRegistry: @@ -62,8 +63,10 @@ struct _GstRegistry { /* hash to speedup _lookup */ GHashTable *basename_hash; + GstRegistryPrivate *private; + /*< private >*/ - gpointer _gst_reserved[GST_PADDING-2]; + gpointer _gst_reserved[GST_PADDING-3]; }; struct _GstRegistryClass {