mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
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.
This commit is contained in:
parent
4f14b5542e
commit
25a0f8c57f
9 changed files with 51 additions and 18 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
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>
|
2005-10-06 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* gst/gstpad.c: (gst_pad_event_default_dispatch):
|
* 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);
|
l = make_list_of_ints (NUM_ELEMENTS);
|
||||||
m = g_mutex_new ();
|
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);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ GST_START_TEST (test_resync)
|
||||||
l = make_list_of_ints (NUM_ELEMENTS);
|
l = make_list_of_ints (NUM_ELEMENTS);
|
||||||
m = g_mutex_new ();
|
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);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ GST_START_TEST (test_fold)
|
||||||
|
|
||||||
l = make_list_of_ints (NUM_ELEMENTS);
|
l = make_list_of_ints (NUM_ELEMENTS);
|
||||||
m = g_mutex_new ();
|
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);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
expected = 0;
|
expected = 0;
|
||||||
|
|
|
@ -745,7 +745,8 @@ gst_bin_iterate_elements (GstBin * bin)
|
||||||
* is freed it will unref the bin again using the provided dispose
|
* is freed it will unref the bin again using the provided dispose
|
||||||
* function. */
|
* function. */
|
||||||
gst_object_ref (bin);
|
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_cookie,
|
||||||
&bin->children,
|
&bin->children,
|
||||||
bin,
|
bin,
|
||||||
|
@ -793,7 +794,8 @@ gst_bin_iterate_recurse (GstBin * bin)
|
||||||
* is freed it will unref the bin again using the provided dispose
|
* is freed it will unref the bin again using the provided dispose
|
||||||
* function. */
|
* function. */
|
||||||
gst_object_ref (bin);
|
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_cookie,
|
||||||
&bin->children,
|
&bin->children,
|
||||||
bin,
|
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
|
/* we don't need a NextFunction because we ref the items in the _next
|
||||||
* method already */
|
* method already */
|
||||||
result = (GstBinSortIterator *)
|
result = (GstBinSortIterator *)
|
||||||
gst_iterator_new (sizeof (GstBinSortIterator),
|
gst_iterator_new (GST_TYPE_ELEMENT,
|
||||||
|
sizeof (GstBinSortIterator),
|
||||||
GST_GET_LOCK (bin),
|
GST_GET_LOCK (bin),
|
||||||
&bin->children_cookie,
|
&bin->children_cookie,
|
||||||
(GstIteratorNextFunction) gst_bin_sort_iterator_next,
|
(GstIteratorNextFunction) gst_bin_sort_iterator_next,
|
||||||
|
|
|
@ -941,7 +941,8 @@ gst_element_iterate_pads (GstElement * element)
|
||||||
|
|
||||||
GST_LOCK (element);
|
GST_LOCK (element);
|
||||||
gst_object_ref (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_cookie,
|
||||||
&element->pads,
|
&element->pads,
|
||||||
element,
|
element,
|
||||||
|
|
|
@ -201,8 +201,10 @@ gst_format_iterate_definitions (void)
|
||||||
GstIterator *result;
|
GstIterator *result;
|
||||||
|
|
||||||
g_static_mutex_lock (&mutex);
|
g_static_mutex_lock (&mutex);
|
||||||
result = gst_iterator_new_list (g_static_mutex_get_mutex (&mutex),
|
/* FIXME: register a boxed type for GstFormatDefinition */
|
||||||
&_n_values, &_gst_formats, NULL, NULL, NULL);
|
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);
|
g_static_mutex_unlock (&mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -36,12 +36,14 @@
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_iterator_init (GstIterator * it,
|
gst_iterator_init (GstIterator * it,
|
||||||
|
GType type,
|
||||||
GMutex * lock,
|
GMutex * lock,
|
||||||
guint32 * master_cookie,
|
guint32 * master_cookie,
|
||||||
GstIteratorNextFunction next,
|
GstIteratorNextFunction next,
|
||||||
GstIteratorItemFunction item,
|
GstIteratorItemFunction item,
|
||||||
GstIteratorResyncFunction resync, GstIteratorFreeFunction free)
|
GstIteratorResyncFunction resync, GstIteratorFreeFunction free)
|
||||||
{
|
{
|
||||||
|
it->type = type;
|
||||||
it->lock = lock;
|
it->lock = lock;
|
||||||
it->master_cookie = master_cookie;
|
it->master_cookie = master_cookie;
|
||||||
it->cookie = *master_cookie;
|
it->cookie = *master_cookie;
|
||||||
|
@ -55,6 +57,7 @@ gst_iterator_init (GstIterator * it,
|
||||||
/**
|
/**
|
||||||
* gst_iterator_new:
|
* gst_iterator_new:
|
||||||
* @size: the size of the iterator structure
|
* @size: the size of the iterator structure
|
||||||
|
* @type: #GType of children
|
||||||
* @lock: pointer to a #GMutex.
|
* @lock: pointer to a #GMutex.
|
||||||
* @master_cookie: pointer to a guint32 to protect the iterated object.
|
* @master_cookie: pointer to a guint32 to protect the iterated object.
|
||||||
* @next: function to get next item
|
* @next: function to get next item
|
||||||
|
@ -74,6 +77,7 @@ gst_iterator_init (GstIterator * it,
|
||||||
*/
|
*/
|
||||||
GstIterator *
|
GstIterator *
|
||||||
gst_iterator_new (guint size,
|
gst_iterator_new (guint size,
|
||||||
|
GType type,
|
||||||
GMutex * lock,
|
GMutex * lock,
|
||||||
guint32 * master_cookie,
|
guint32 * master_cookie,
|
||||||
GstIteratorNextFunction next,
|
GstIteratorNextFunction next,
|
||||||
|
@ -89,7 +93,8 @@ gst_iterator_new (guint size,
|
||||||
g_return_val_if_fail (free != NULL, NULL);
|
g_return_val_if_fail (free != NULL, NULL);
|
||||||
|
|
||||||
result = g_malloc (size);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -103,6 +108,7 @@ typedef struct _GstListIterator
|
||||||
gpointer owner;
|
gpointer owner;
|
||||||
GList **orig;
|
GList **orig;
|
||||||
GList *list; /* pointer in list */
|
GList *list; /* pointer in list */
|
||||||
|
GType *type;
|
||||||
GstIteratorDisposeFunction freefunc;
|
GstIteratorDisposeFunction freefunc;
|
||||||
} GstListIterator;
|
} GstListIterator;
|
||||||
|
|
||||||
|
@ -135,6 +141,7 @@ gst_list_iterator_free (GstListIterator * it)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_iterator_new_list:
|
* gst_iterator_new_list:
|
||||||
|
* @type: #GType of elements
|
||||||
* @lock: pointer to a #GMutex protecting the list.
|
* @lock: pointer to a #GMutex protecting the list.
|
||||||
* @master_cookie: pointer to a guint32 to protect the list.
|
* @master_cookie: pointer to a guint32 to protect the list.
|
||||||
* @list: pointer to the list
|
* @list: pointer to the list
|
||||||
|
@ -149,7 +156,8 @@ gst_list_iterator_free (GstListIterator * it)
|
||||||
* MT safe.
|
* MT safe.
|
||||||
*/
|
*/
|
||||||
GstIterator *
|
GstIterator *
|
||||||
gst_iterator_new_list (GMutex * lock,
|
gst_iterator_new_list (GType type,
|
||||||
|
GMutex * lock,
|
||||||
guint32 * master_cookie,
|
guint32 * master_cookie,
|
||||||
GList ** list,
|
GList ** list,
|
||||||
gpointer owner,
|
gpointer owner,
|
||||||
|
@ -159,6 +167,7 @@ gst_iterator_new_list (GMutex * lock,
|
||||||
|
|
||||||
/* no need to lock, nothing can change here */
|
/* no need to lock, nothing can change here */
|
||||||
result = (GstListIterator *) gst_iterator_new (sizeof (GstListIterator),
|
result = (GstListIterator *) gst_iterator_new (sizeof (GstListIterator),
|
||||||
|
type,
|
||||||
lock,
|
lock,
|
||||||
master_cookie,
|
master_cookie,
|
||||||
(GstIteratorNextFunction) gst_list_iterator_next,
|
(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);
|
g_return_val_if_fail (func != NULL, NULL);
|
||||||
|
|
||||||
result = (GstIteratorFilter *) gst_iterator_new (sizeof (GstIteratorFilter),
|
result = (GstIteratorFilter *) gst_iterator_new (sizeof (GstIteratorFilter),
|
||||||
it->lock, it->master_cookie,
|
it->type, it->lock, it->master_cookie,
|
||||||
(GstIteratorNextFunction) filter_next,
|
(GstIteratorNextFunction) filter_next,
|
||||||
(GstIteratorItemFunction) NULL,
|
(GstIteratorItemFunction) NULL,
|
||||||
(GstIteratorResyncFunction) filter_resync,
|
(GstIteratorResyncFunction) filter_resync,
|
||||||
|
|
|
@ -64,6 +64,7 @@ struct _GstIterator {
|
||||||
|
|
||||||
GstIterator *pushed; /* pushed iterator */
|
GstIterator *pushed; /* pushed iterator */
|
||||||
|
|
||||||
|
GType type;
|
||||||
GMutex *lock;
|
GMutex *lock;
|
||||||
guint32 cookie; /* cookie of the iterator */
|
guint32 cookie; /* cookie of the iterator */
|
||||||
guint32 *master_cookie; /* pointer to guint32 holding the cookie when this
|
guint32 *master_cookie; /* pointer to guint32 holding the cookie when this
|
||||||
|
@ -75,6 +76,7 @@ struct _GstIterator {
|
||||||
|
|
||||||
/* creating iterators */
|
/* creating iterators */
|
||||||
GstIterator* gst_iterator_new (guint size,
|
GstIterator* gst_iterator_new (guint size,
|
||||||
|
GType type,
|
||||||
GMutex *lock,
|
GMutex *lock,
|
||||||
guint32 *master_cookie,
|
guint32 *master_cookie,
|
||||||
GstIteratorNextFunction next,
|
GstIteratorNextFunction next,
|
||||||
|
@ -82,7 +84,8 @@ GstIterator* gst_iterator_new (guint size,
|
||||||
GstIteratorResyncFunction resync,
|
GstIteratorResyncFunction resync,
|
||||||
GstIteratorFreeFunction free);
|
GstIteratorFreeFunction free);
|
||||||
|
|
||||||
GstIterator* gst_iterator_new_list (GMutex *lock,
|
GstIterator* gst_iterator_new_list (GType type,
|
||||||
|
GMutex *lock,
|
||||||
guint32 *master_cookie,
|
guint32 *master_cookie,
|
||||||
GList **list,
|
GList **list,
|
||||||
gpointer owner,
|
gpointer owner,
|
||||||
|
|
|
@ -293,8 +293,10 @@ gst_query_type_iterate_definitions (void)
|
||||||
GstIterator *result;
|
GstIterator *result;
|
||||||
|
|
||||||
g_static_mutex_lock (&mutex);
|
g_static_mutex_lock (&mutex);
|
||||||
result = gst_iterator_new_list (g_static_mutex_get_mutex (&mutex),
|
/* FIXME: register a boxed type for GstQueryTypeDefinition */
|
||||||
&_n_values, &_gst_queries, NULL, NULL, NULL);
|
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);
|
g_static_mutex_unlock (&mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -50,7 +50,7 @@ GST_START_TEST (test_manual_iteration)
|
||||||
l = make_list_of_ints (NUM_ELEMENTS);
|
l = make_list_of_ints (NUM_ELEMENTS);
|
||||||
m = g_mutex_new ();
|
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);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ GST_START_TEST (test_resync)
|
||||||
l = make_list_of_ints (NUM_ELEMENTS);
|
l = make_list_of_ints (NUM_ELEMENTS);
|
||||||
m = g_mutex_new ();
|
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);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ GST_START_TEST (test_fold)
|
||||||
|
|
||||||
l = make_list_of_ints (NUM_ELEMENTS);
|
l = make_list_of_ints (NUM_ELEMENTS);
|
||||||
m = g_mutex_new ();
|
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);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
expected = 0;
|
expected = 0;
|
||||||
|
|
Loading…
Reference in a new issue