]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gstreamer0-10.git/commitdiff
gstregistry: Add a cookie for detecting feature list changes
authorEdward Hervey <bilboed@bilboed.com>
Sat, 24 Oct 2009 08:05:59 +0000 (10:05 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Sat, 24 Oct 2009 08:39:13 +0000 (10:39 +0200)
We also create a private structure, since we will need to add more
data there in following patches.

gst/gstregistry.c
gst/gstregistry.h

index 23f61ada283e80ddebcadbd79e4b870fc38fc733..4a603f2ee48985b39d7b29e05aa9064280887a53 100644 (file)
 
 #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);
 }
index 201acf4883e5c9d57aebeddc2db0fd7bacebe7f8..946bb4cb51faf08d190ceed24c8cf64e0b34f48e 100644 (file)
@@ -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 {