Commit 25a0f8c5 authored by Johan Dahlin's avatar Johan Dahlin

Add a GType to GstIterator, update callsites and tests.

Original commit message from CVS:
* check/gst/gstiterator.c: (GST_START_TEST):
* gst/gstbin.c: (gst_bin_iterate_elements),
(gst_bin_iterate_recurse), (gst_bin_iterate_sorted):
* gst/gstelement.c: (gst_element_iterate_pads):
* gst/gstformat.c: (gst_format_iterate_definitions):
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_iterator_new_list), (gst_iterator_filter):
* gst/gstiterator.h:
* gst/gstquery.c: (gst_query_type_iterate_definitions):
Add a GType to GstIterator, update callsites and tests.
parent 4f14b554
2005-10-04 Johan Dahlin <johan@gnome.org>
* check/gst/gstiterator.c: (GST_START_TEST):
* gst/gstbin.c: (gst_bin_iterate_elements),
(gst_bin_iterate_recurse), (gst_bin_iterate_sorted):
* gst/gstelement.c: (gst_element_iterate_pads):
* gst/gstformat.c: (gst_format_iterate_definitions):
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_iterator_new_list), (gst_iterator_filter):
* gst/gstiterator.h:
* gst/gstquery.c: (gst_query_type_iterate_definitions):
Add a GType to GstIterator, update callsites and tests.
2005-10-06 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gstpad.c: (gst_pad_event_default_dispatch):
......
......@@ -50,7 +50,7 @@ GST_START_TEST (test_manual_iteration)
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
iter = gst_iterator_new_list (G_TYPE_INT, m, &cookie, &l, NULL, NULL, NULL);
fail_unless (iter != NULL);
......@@ -88,7 +88,7 @@ GST_START_TEST (test_resync)
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
iter = gst_iterator_new_list (G_TYPE_INT, m, &cookie, &l, NULL, NULL, NULL);
fail_unless (iter != NULL);
......@@ -142,7 +142,7 @@ GST_START_TEST (test_fold)
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
iter = gst_iterator_new_list (G_TYPE_INT, m, &cookie, &l, NULL, NULL, NULL);
fail_unless (iter != NULL);
expected = 0;
......
......@@ -745,7 +745,8 @@ gst_bin_iterate_elements (GstBin * bin)
* is freed it will unref the bin again using the provided dispose
* function. */
gst_object_ref (bin);
result = gst_iterator_new_list (GST_GET_LOCK (bin),
result = gst_iterator_new_list (GST_TYPE_ELEMENT,
GST_GET_LOCK (bin),
&bin->children_cookie,
&bin->children,
bin,
......@@ -793,7 +794,8 @@ gst_bin_iterate_recurse (GstBin * bin)
* is freed it will unref the bin again using the provided dispose
* function. */
gst_object_ref (bin);
result = gst_iterator_new_list (GST_GET_LOCK (bin),
result = gst_iterator_new_list (GST_TYPE_ELEMENT,
GST_GET_LOCK (bin),
&bin->children_cookie,
&bin->children,
bin,
......@@ -1285,7 +1287,8 @@ gst_bin_iterate_sorted (GstBin * bin)
/* we don't need a NextFunction because we ref the items in the _next
* method already */
result = (GstBinSortIterator *)
gst_iterator_new (sizeof (GstBinSortIterator),
gst_iterator_new (GST_TYPE_ELEMENT,
sizeof (GstBinSortIterator),
GST_GET_LOCK (bin),
&bin->children_cookie,
(GstIteratorNextFunction) gst_bin_sort_iterator_next,
......
......@@ -941,7 +941,8 @@ gst_element_iterate_pads (GstElement * element)
GST_LOCK (element);
gst_object_ref (element);
result = gst_iterator_new_list (GST_GET_LOCK (element),
result = gst_iterator_new_list (GST_TYPE_PAD,
GST_GET_LOCK (element),
&element->pads_cookie,
&element->pads,
element,
......
......@@ -201,8 +201,10 @@ gst_format_iterate_definitions (void)
GstIterator *result;
g_static_mutex_lock (&mutex);
result = gst_iterator_new_list (g_static_mutex_get_mutex (&mutex),
&_n_values, &_gst_formats, NULL, NULL, NULL);
/* FIXME: register a boxed type for GstFormatDefinition */
result = gst_iterator_new_list (G_TYPE_POINTER,
g_static_mutex_get_mutex (&mutex), &_n_values, &_gst_formats,
NULL, NULL, NULL);
g_static_mutex_unlock (&mutex);
return result;
......
......@@ -36,12 +36,14 @@
static void
gst_iterator_init (GstIterator * it,
GType type,
GMutex * lock,
guint32 * master_cookie,
GstIteratorNextFunction next,
GstIteratorItemFunction item,
GstIteratorResyncFunction resync, GstIteratorFreeFunction free)
{
it->type = type;
it->lock = lock;
it->master_cookie = master_cookie;
it->cookie = *master_cookie;
......@@ -55,6 +57,7 @@ gst_iterator_init (GstIterator * it,
/**
* gst_iterator_new:
* @size: the size of the iterator structure
* @type: #GType of children
* @lock: pointer to a #GMutex.
* @master_cookie: pointer to a guint32 to protect the iterated object.
* @next: function to get next item
......@@ -74,6 +77,7 @@ gst_iterator_init (GstIterator * it,
*/
GstIterator *
gst_iterator_new (guint size,
GType type,
GMutex * lock,
guint32 * master_cookie,
GstIteratorNextFunction next,
......@@ -89,7 +93,8 @@ gst_iterator_new (guint size,
g_return_val_if_fail (free != NULL, NULL);
result = g_malloc (size);
gst_iterator_init (result, lock, master_cookie, next, item, resync, free);
gst_iterator_init (result, type, lock, master_cookie, next, item, resync,
free);
return result;
}
......@@ -103,6 +108,7 @@ typedef struct _GstListIterator
gpointer owner;
GList **orig;
GList *list; /* pointer in list */
GType *type;
GstIteratorDisposeFunction freefunc;
} GstListIterator;
......@@ -135,6 +141,7 @@ gst_list_iterator_free (GstListIterator * it)
/**
* gst_iterator_new_list:
* @type: #GType of elements
* @lock: pointer to a #GMutex protecting the list.
* @master_cookie: pointer to a guint32 to protect the list.
* @list: pointer to the list
......@@ -149,7 +156,8 @@ gst_list_iterator_free (GstListIterator * it)
* MT safe.
*/
GstIterator *
gst_iterator_new_list (GMutex * lock,
gst_iterator_new_list (GType type,
GMutex * lock,
guint32 * master_cookie,
GList ** list,
gpointer owner,
......@@ -159,6 +167,7 @@ gst_iterator_new_list (GMutex * lock,
/* no need to lock, nothing can change here */
result = (GstListIterator *) gst_iterator_new (sizeof (GstListIterator),
type,
lock,
master_cookie,
(GstIteratorNextFunction) gst_list_iterator_next,
......@@ -402,7 +411,7 @@ gst_iterator_filter (GstIterator * it, GCompareFunc func, gpointer user_data)
g_return_val_if_fail (func != NULL, NULL);
result = (GstIteratorFilter *) gst_iterator_new (sizeof (GstIteratorFilter),
it->lock, it->master_cookie,
it->type, it->lock, it->master_cookie,
(GstIteratorNextFunction) filter_next,
(GstIteratorItemFunction) NULL,
(GstIteratorResyncFunction) filter_resync,
......
......@@ -64,6 +64,7 @@ struct _GstIterator {
GstIterator *pushed; /* pushed iterator */
GType type;
GMutex *lock;
guint32 cookie; /* cookie of the iterator */
guint32 *master_cookie; /* pointer to guint32 holding the cookie when this
......@@ -75,6 +76,7 @@ struct _GstIterator {
/* creating iterators */
GstIterator* gst_iterator_new (guint size,
GType type,
GMutex *lock,
guint32 *master_cookie,
GstIteratorNextFunction next,
......@@ -82,7 +84,8 @@ GstIterator* gst_iterator_new (guint size,
GstIteratorResyncFunction resync,
GstIteratorFreeFunction free);
GstIterator* gst_iterator_new_list (GMutex *lock,
GstIterator* gst_iterator_new_list (GType type,
GMutex *lock,
guint32 *master_cookie,
GList **list,
gpointer owner,
......
......@@ -293,8 +293,10 @@ gst_query_type_iterate_definitions (void)
GstIterator *result;
g_static_mutex_lock (&mutex);
result = gst_iterator_new_list (g_static_mutex_get_mutex (&mutex),
&_n_values, &_gst_queries, NULL, NULL, NULL);
/* FIXME: register a boxed type for GstQueryTypeDefinition */
result = gst_iterator_new_list (G_TYPE_POINTER,
g_static_mutex_get_mutex (&mutex), &_n_values, &_gst_queries,
NULL, NULL, NULL);
g_static_mutex_unlock (&mutex);
return result;
......
......@@ -50,7 +50,7 @@ GST_START_TEST (test_manual_iteration)
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
iter = gst_iterator_new_list (G_TYPE_INT, m, &cookie, &l, NULL, NULL, NULL);
fail_unless (iter != NULL);
......@@ -88,7 +88,7 @@ GST_START_TEST (test_resync)
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
iter = gst_iterator_new_list (G_TYPE_INT, m, &cookie, &l, NULL, NULL, NULL);
fail_unless (iter != NULL);
......@@ -142,7 +142,7 @@ GST_START_TEST (test_fold)
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
iter = gst_iterator_new_list (G_TYPE_INT, m, &cookie, &l, NULL, NULL, NULL);
fail_unless (iter != NULL);
expected = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment