gst/gstindex.h (GstIndex): Add field for user_data_destroy. We don't have a dispose...
authorAndy Wingo <wingo@pobox.com>
Sat, 19 Nov 2005 17:26:27 +0000 (17:26 +0000)
committerAndy Wingo <wingo@pobox.com>
Sat, 19 Nov 2005 17:26:27 +0000 (17:26 +0000)
Original commit message from CVS:
2005-11-19  Andy Wingo  <wingo@pobox.com>

* gst/gstindex.h (GstIndex): Add field for user_data_destroy. We
don't have a dispose function, so it won't get called when the
object is unreffed, but oh well!

* gst/gstindex.c (gst_index_set_filter_full): New API function,
allows a destroy function to be set so user_data can be freed.
Fixes #168438.
(gst_index_set_filter): Call gst_index_set_filter_full.

ChangeLog
gst/gstindex.c
gst/gstindex.h

index 28251fa..b4b2984 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2005-11-19  Andy Wingo  <wingo@pobox.com>
 
+       * gst/gstindex.h (GstIndex): Add field for user_data_destroy. We
+       don't have a dispose function, so it won't get called when the
+       object is unreffed, but oh well!
+
+       * gst/gstindex.c (gst_index_set_filter_full): New API function,
+       allows a destroy function to be set so user_data can be freed.
+       Fixes #168438.
+       (gst_index_set_filter): Call gst_index_set_filter_full.
+
        * check/gst/gstvalue.c (test_string): Add test for bug #165650.
 
        * gst/gstvalue.c (gst_string_wrap): Trying to serialize a NULL
index 31197e7..cae56d2 100644 (file)
@@ -402,8 +402,31 @@ gst_index_set_filter (GstIndex * index,
 {
   g_return_if_fail (GST_IS_INDEX (index));
 
+  gst_index_set_filter_full (index, filter, user_data, NULL);
+}
+
+/**
+ * gst_index_set_filter_full:
+ * @index: the index to register the filter on
+ * @filter: the filter to register
+ * @user_data: data passed to the filter function
+ * @user_data_destroy: function to call when @user_data is unset
+ *
+ * Lets the app register a custom filter function so that
+ * it can select what entries should be stored in the index.
+ */
+void
+gst_index_set_filter_full (GstIndex * index,
+    GstIndexFilter filter, gpointer user_data, GDestroyNotify user_data_destroy)
+{
+  g_return_if_fail (GST_IS_INDEX (index));
+
+  if (index->filter_user_data && index->filter_user_data_destroy)
+    index->filter_user_data_destroy (index->filter_user_data);
+
   index->filter = filter;
   index->filter_user_data = user_data;
+  index->filter_user_data_destroy = user_data_destroy;
 }
 
 /**
index 06adf38..2ca164e 100644 (file)
@@ -327,6 +327,7 @@ struct _GstIndex {
 
   GstIndexFilter        filter;
   gpointer              filter_user_data;
+  GDestroyNotify        filter_user_data_destroy;
 
   GHashTable           *writers;
   gint                  last_id;
@@ -369,6 +370,9 @@ GstIndexCertainty   gst_index_get_certainty         (GstIndex *index);
 
 void                   gst_index_set_filter            (GstIndex *index,
                                                         GstIndexFilter filter, gpointer user_data);
+void                   gst_index_set_filter_full       (GstIndex *index,
+                                                        GstIndexFilter filter, gpointer user_data,
+                                                         GDestroyNotify user_data_destroy);
 void                   gst_index_set_resolver          (GstIndex *index,
                                                         GstIndexResolver resolver, gpointer user_data);