gst/gstindex.*: Add new function with option to dispose of user_data in resolver.

Original commit message from CVS:
Patch by: Siavash Safi <siavash dot safi at gmail dot com>
* gst/gstindex.c: (gst_index_finalize), (gst_index_set_resolver),
(gst_index_set_resolver_full):
* gst/gstindex.h:
Add new function with option to dispose of user_data in resolver.
Actually call the dispose function when finalizing the object and not
just when changing the resolver/filter.
API: GstIndex::gst_index_set_resolver_full()
* docs/gst/gstreamer-sections.txt:
Add new function to docs. Fixes #515469.
This commit is contained in:
Siavash Safi 2008-02-11 17:53:57 +00:00 committed by Wim Taymans
parent 0a5db2e479
commit fdd893cd17
5 changed files with 53 additions and 2 deletions

View file

@ -1,3 +1,18 @@
2008-02-11 Wim Taymans <wim.taymans@collabora.co.uk>
Patch by: Siavash Safi <siavash dot safi at gmail dot com>
* gst/gstindex.c: (gst_index_finalize), (gst_index_set_resolver),
(gst_index_set_resolver_full):
* gst/gstindex.h:
Add new function with option to dispose of user_data in resolver.
Actually call the dispose function when finalizing the object and not
just when changing the resolver/filter.
API: GstIndex::gst_index_set_resolver_full()
* docs/gst/gstreamer-sections.txt:
Add new function to docs. Fixes #515469.
2008-02-11 Sebastian Dröge <slomo@circular-chaos.org>
* gst/gstindex.c: (gst_index_finalize):

2
common

@ -1 +1 @@
Subproject commit 961bb6bd997d7c8da6058534e86b4a1361c0fcea
Subproject commit 05a617c9043ddb78f8578195b18c166d7e1d4c2e

View file

@ -791,6 +791,7 @@ gst_index_get_certainty
gst_index_set_filter
gst_index_set_filter_full
gst_index_set_resolver
gst_index_set_resolver_full
gst_index_get_writer_id
gst_index_add_format
gst_index_add_association

View file

@ -227,6 +227,12 @@ gst_index_finalize (GObject * object)
index->writers = NULL;
}
if (index->filter_user_data && index->filter_user_data_destroy)
index->filter_user_data_destroy (index->filter_user_data);
if (index->resolver_user_data && index->resolver_user_data_destroy)
index->resolver_user_data_destroy (index->resolver_user_data);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -471,11 +477,34 @@ gst_index_set_filter_full (GstIndex * index,
void
gst_index_set_resolver (GstIndex * index,
GstIndexResolver resolver, gpointer user_data)
{
gst_index_set_resolver_full (index, resolver, user_data, NULL);
}
/**
* gst_index_set_resolver_full:
* @index: the index to register the resolver on
* @resolver: the resolver to register
* @user_data: data passed to the resolver function
* @user_data_destroy: destroy function for @user_data
*
* Lets the app register a custom function to map index
* ids to writer descriptions.
*
* Since: 0.10.18
*/
void
gst_index_set_resolver_full (GstIndex * index, GstIndexResolver resolver,
gpointer user_data, GDestroyNotify user_data_destroy)
{
g_return_if_fail (GST_IS_INDEX (index));
if (index->resolver_user_data && index->resolver_user_data_destroy)
index->resolver_user_data_destroy (index->resolver_user_data);
index->resolver = resolver;
index->resolver_user_data = user_data;
index->resolver_user_data_destroy = user_data_destroy;
index->method = GST_INDEX_RESOLVER_CUSTOM;
}

View file

@ -340,8 +340,11 @@ struct _GstIndex {
GHashTable *writers;
gint last_id;
/* ABI added since 0.10.18 */
GDestroyNotify resolver_user_data_destroy;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
gpointer _gst_reserved[GST_PADDING - 1];
};
struct _GstIndexClass {
@ -386,6 +389,9 @@ void gst_index_set_filter_full (GstIndex *index,
GDestroyNotify user_data_destroy);
void gst_index_set_resolver (GstIndex *index,
GstIndexResolver resolver, gpointer user_data);
void gst_index_set_resolver_full (GstIndex *index, GstIndexResolver resolver,
gpointer user_data,
GDestroyNotify user_data_destroy);
gboolean gst_index_get_writer_id (GstIndex *index, GstObject *writer, gint *id);