From 4a61de0e11de11453baae88bab58c49c904198b2 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sat, 19 Nov 2005 17:26:27 +0000 Subject: [PATCH] gst/gstindex.h (GstIndex): Add field for user_data_destroy. We don't have a dispose function, so it won't get called ... Original commit message from CVS: 2005-11-19 Andy Wingo * 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 | 9 +++++++++ gst/gstindex.c | 23 +++++++++++++++++++++++ gst/gstindex.h | 4 ++++ 3 files changed, 36 insertions(+) diff --git a/ChangeLog b/ChangeLog index 28251fa..b4b2984 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2005-11-19 Andy Wingo + * 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 diff --git a/gst/gstindex.c b/gst/gstindex.c index 31197e7..cae56d2 100644 --- a/gst/gstindex.c +++ b/gst/gstindex.c @@ -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; } /** diff --git a/gst/gstindex.h b/gst/gstindex.h index 06adf38..2ca164e 100644 --- a/gst/gstindex.h +++ b/gst/gstindex.h @@ -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); -- 2.7.4