gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
|
2011-03-16 09:50:39 +00:00
|
|
|
* Copyright (C) 2011 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
|
|
|
* gstiterator.h: Base class for iterating datastructures.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-09-24 14:14:03 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstiterator
|
|
|
|
* @short_description: Object to retrieve multiple elements in a threadsafe
|
|
|
|
* way.
|
|
|
|
* @see_also: #GstElement, #GstBin
|
|
|
|
*
|
|
|
|
* A GstIterator is used to retrieve multiple objects from another object in
|
|
|
|
* a threadsafe way.
|
|
|
|
*
|
|
|
|
* Various GStreamer objects provide access to their internal structures using
|
|
|
|
* an iterator.
|
2005-10-28 16:21:29 +00:00
|
|
|
*
|
2009-06-16 09:21:42 +00:00
|
|
|
* In general, whenever calling a GstIterator function results in your code
|
|
|
|
* receiving a refcounted object, the refcount for that object will have been
|
|
|
|
* increased. Your code is responsible for unrefing that object after use.
|
|
|
|
*
|
2005-10-28 16:21:29 +00:00
|
|
|
* The basic use pattern of an iterator is as follows:
|
|
|
|
*
|
|
|
|
* <example>
|
|
|
|
* <title>Using an iterator</title>
|
|
|
|
* <programlisting>
|
|
|
|
* it = _get_iterator(object);
|
|
|
|
* done = FALSE;
|
|
|
|
* while (!done) {
|
|
|
|
* switch (gst_iterator_next (it, &item)) {
|
|
|
|
* case GST_ITERATOR_OK:
|
|
|
|
* ... use/change item here...
|
2011-03-16 09:50:39 +00:00
|
|
|
* g_value_reset (&item);
|
2005-10-28 16:21:29 +00:00
|
|
|
* break;
|
|
|
|
* case GST_ITERATOR_RESYNC:
|
|
|
|
* ...rollback changes to items...
|
|
|
|
* gst_iterator_resync (it);
|
|
|
|
* break;
|
2005-11-27 22:43:08 +00:00
|
|
|
* case GST_ITERATOR_ERROR:
|
2009-06-16 09:21:42 +00:00
|
|
|
* ...wrong parameters were given...
|
2005-11-27 22:43:08 +00:00
|
|
|
* done = TRUE;
|
|
|
|
* break;
|
2005-10-28 16:21:29 +00:00
|
|
|
* case GST_ITERATOR_DONE:
|
|
|
|
* done = TRUE;
|
|
|
|
* break;
|
|
|
|
* }
|
|
|
|
* }
|
2011-03-16 09:50:39 +00:00
|
|
|
* g_value_unset (&item);
|
2005-10-28 16:21:29 +00:00
|
|
|
* gst_iterator_free (it);
|
|
|
|
* </programlisting>
|
|
|
|
* </example>
|
2005-10-28 18:14:24 +00:00
|
|
|
*
|
2009-06-16 09:21:42 +00:00
|
|
|
* Last reviewed on 2009-06-16 (0.10.24)
|
2005-09-24 14:14:03 +00:00
|
|
|
*/
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
|
|
|
|
#include "gst_private.h"
|
|
|
|
#include <gst/gstiterator.h>
|
|
|
|
|
2012-03-29 11:34:50 +00:00
|
|
|
/**
|
|
|
|
* gst_iterator_copy:
|
|
|
|
* @it: a #GstIterator
|
|
|
|
*
|
|
|
|
* Copy the iterator and its state.
|
|
|
|
*
|
|
|
|
* Returns: a new copy of @it.
|
|
|
|
*/
|
2011-03-16 09:50:39 +00:00
|
|
|
GstIterator *
|
|
|
|
gst_iterator_copy (const GstIterator * it)
|
2011-01-08 14:27:55 +00:00
|
|
|
{
|
2011-03-16 09:50:39 +00:00
|
|
|
GstIterator *copy;
|
|
|
|
|
|
|
|
copy = g_slice_copy (it->size, it);
|
|
|
|
if (it->copy)
|
|
|
|
it->copy (it, copy);
|
|
|
|
|
|
|
|
return copy;
|
2011-01-08 14:27:55 +00:00
|
|
|
}
|
|
|
|
|
2012-01-28 14:35:51 +00:00
|
|
|
G_DEFINE_BOXED_TYPE (GstIterator, gst_iterator,
|
|
|
|
(GBoxedCopyFunc) gst_iterator_copy, (GBoxedFreeFunc) gst_iterator_free);
|
2011-01-08 14:27:55 +00:00
|
|
|
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
static void
|
|
|
|
gst_iterator_init (GstIterator * it,
|
2011-01-08 14:07:55 +00:00
|
|
|
guint size,
|
2005-10-07 00:14:45 +00:00
|
|
|
GType type,
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
GMutex * lock,
|
|
|
|
guint32 * master_cookie,
|
2011-03-16 09:50:39 +00:00
|
|
|
GstIteratorCopyFunction copy,
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
GstIteratorNextFunction next,
|
|
|
|
GstIteratorItemFunction item,
|
|
|
|
GstIteratorResyncFunction resync, GstIteratorFreeFunction free)
|
|
|
|
{
|
2011-01-08 14:07:55 +00:00
|
|
|
it->size = size;
|
2005-10-07 00:14:45 +00:00
|
|
|
it->type = type;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
it->lock = lock;
|
|
|
|
it->master_cookie = master_cookie;
|
|
|
|
it->cookie = *master_cookie;
|
2011-03-16 09:50:39 +00:00
|
|
|
it->copy = copy;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
it->next = next;
|
|
|
|
it->item = item;
|
|
|
|
it->resync = resync;
|
|
|
|
it->free = free;
|
|
|
|
it->pushed = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-19 09:59:29 +00:00
|
|
|
* gst_iterator_new: (skip)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* @size: the size of the iterator structure
|
2005-10-07 00:14:45 +00:00
|
|
|
* @type: #GType of children
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* @lock: pointer to a #GMutex.
|
2008-08-29 17:58:25 +00:00
|
|
|
* @master_cookie: pointer to a guint32 that is changed when the items in the
|
|
|
|
* iterator changed.
|
2011-03-16 09:50:39 +00:00
|
|
|
* @copy: copy function
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* @next: function to get next item
|
|
|
|
* @item: function to call on each item retrieved
|
|
|
|
* @resync: function to resync the iterator
|
|
|
|
* @free: function to free the iterator
|
|
|
|
*
|
|
|
|
* Create a new iterator. This function is mainly used for objects
|
|
|
|
* implementing the next/resync/free function to iterate a data structure.
|
Docs updates, clean up some headers.
Original commit message from CVS:
* docs/design/part-MT-refcounting.txt:
* docs/design/part-conventions.txt:
* docs/design/part-gstobject.txt:
* docs/design/part-relations.txt:
* docs/design/part-standards.txt:
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_add),
(gst_bin_remove_func), (gst_bin_remove), (gst_bin_iterate_recurse),
(gst_bin_get_by_name), (gst_bin_get_by_interface),
(gst_bin_iterate_all_by_interface):
* gst/gstbuffer.h:
* gst/gstclock.h:
* gst/gstelement.c: (gst_element_class_init),
(gst_element_change_state), (gst_element_set_loop_function):
* gst/gstelement.h:
* gst/gstiterator.c:
* gst/gstobject.c: (gst_object_class_init), (gst_object_ref),
(gst_object_unref), (gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed), (gst_object_set_name),
(gst_object_set_parent), (gst_object_unparent),
(gst_object_check_uniqueness):
* gst/gstobject.h:
Docs updates, clean up some headers.
Free iterators in GstBin.
GstObject is now looking good.
2005-03-08 14:38:06 +00:00
|
|
|
*
|
|
|
|
* For each item retrieved, the @item function is called with the lock
|
|
|
|
* held. The @free function is called when the iterator is freed.
|
2005-08-20 12:39:05 +00:00
|
|
|
*
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* Returns: the new #GstIterator.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstIterator *
|
|
|
|
gst_iterator_new (guint size,
|
2005-10-07 00:14:45 +00:00
|
|
|
GType type,
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
GMutex * lock,
|
|
|
|
guint32 * master_cookie,
|
2011-03-16 09:50:39 +00:00
|
|
|
GstIteratorCopyFunction copy,
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
GstIteratorNextFunction next,
|
|
|
|
GstIteratorItemFunction item,
|
|
|
|
GstIteratorResyncFunction resync, GstIteratorFreeFunction free)
|
|
|
|
{
|
|
|
|
GstIterator *result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (size >= sizeof (GstIterator), NULL);
|
2005-10-10 15:30:45 +00:00
|
|
|
g_return_val_if_fail (g_type_qname (type) != 0, NULL);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
g_return_val_if_fail (master_cookie != NULL, NULL);
|
|
|
|
g_return_val_if_fail (next != NULL, NULL);
|
|
|
|
g_return_val_if_fail (resync != NULL, NULL);
|
|
|
|
g_return_val_if_fail (free != NULL, NULL);
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
result = g_slice_alloc0 (size);
|
|
|
|
gst_iterator_init (result, size, type, lock, master_cookie, copy, next, item,
|
2011-01-08 14:07:55 +00:00
|
|
|
resync, free);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* list iterator
|
|
|
|
*/
|
|
|
|
typedef struct _GstListIterator
|
|
|
|
{
|
|
|
|
GstIterator iterator;
|
2011-03-16 09:50:39 +00:00
|
|
|
GObject *owner;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
GList **orig;
|
|
|
|
GList *list; /* pointer in list */
|
2011-03-16 09:50:39 +00:00
|
|
|
|
|
|
|
void (*set_value) (GValue * value, gpointer item);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
} GstListIterator;
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
static void
|
|
|
|
gst_list_iterator_copy (const GstListIterator * it, GstListIterator * copy)
|
|
|
|
{
|
|
|
|
if (copy->owner)
|
|
|
|
g_object_ref (copy->owner);
|
|
|
|
}
|
|
|
|
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
static GstIteratorResult
|
2011-03-16 09:50:39 +00:00
|
|
|
gst_list_iterator_next (GstListIterator * it, GValue * elem)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
2011-03-16 09:50:39 +00:00
|
|
|
gpointer data;
|
|
|
|
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
if (it->list == NULL)
|
|
|
|
return GST_ITERATOR_DONE;
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
data = it->list->data;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
it->list = g_list_next (it->list);
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
it->set_value (elem, data);
|
|
|
|
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
return GST_ITERATOR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_list_iterator_resync (GstListIterator * it)
|
|
|
|
{
|
|
|
|
it->list = *it->orig;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_list_iterator_free (GstListIterator * it)
|
|
|
|
{
|
2011-03-16 09:50:39 +00:00
|
|
|
if (it->owner)
|
|
|
|
g_object_unref (it->owner);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-19 09:59:29 +00:00
|
|
|
* gst_iterator_new_list: (skip)
|
2005-10-07 00:14:45 +00:00
|
|
|
* @type: #GType of elements
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* @lock: pointer to a #GMutex protecting the list.
|
2008-08-29 17:58:25 +00:00
|
|
|
* @master_cookie: pointer to a guint32 that is incremented when the list
|
|
|
|
* is changed.
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* @list: pointer to the list
|
|
|
|
* @owner: object owning the list
|
2011-03-16 09:50:39 +00:00
|
|
|
* @item: function to call on each item retrieved
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
2005-08-20 12:39:05 +00:00
|
|
|
* Create a new iterator designed for iterating @list.
|
|
|
|
*
|
2008-08-29 17:58:25 +00:00
|
|
|
* The list you iterate is usually part of a data structure @owner and is
|
|
|
|
* protected with @lock.
|
|
|
|
*
|
|
|
|
* The iterator will use @lock to retrieve the next item of the list and it
|
|
|
|
* will then call the @item function before releasing @lock again.
|
|
|
|
*
|
|
|
|
* When a concurrent update to the list is performed, usually by @owner while
|
|
|
|
* holding @lock, @master_cookie will be updated. The iterator implementation
|
2009-03-11 22:41:24 +00:00
|
|
|
* will notice the update of the cookie and will return %GST_ITERATOR_RESYNC to
|
2008-08-29 17:58:25 +00:00
|
|
|
* the user of the iterator in the next call to gst_iterator_next().
|
|
|
|
*
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* Returns: the new #GstIterator for @list.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstIterator *
|
2005-10-07 00:14:45 +00:00
|
|
|
gst_iterator_new_list (GType type,
|
2011-03-16 09:50:39 +00:00
|
|
|
GMutex * lock, guint32 * master_cookie, GList ** list, GObject * owner,
|
|
|
|
GstIteratorItemFunction item)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
|
|
|
GstListIterator *result;
|
2011-03-16 09:50:39 +00:00
|
|
|
gpointer set_value;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, G_TYPE_OBJECT)) {
|
|
|
|
set_value = g_value_set_object;
|
|
|
|
} else if (g_type_is_a (type, G_TYPE_BOXED)) {
|
|
|
|
set_value = g_value_set_boxed;
|
|
|
|
} else if (g_type_is_a (type, G_TYPE_POINTER)) {
|
|
|
|
set_value = g_value_set_pointer;
|
|
|
|
} else if (g_type_is_a (type, G_TYPE_STRING)) {
|
|
|
|
set_value = g_value_set_string;
|
|
|
|
} else {
|
|
|
|
g_critical ("List iterators can only be created for lists containing "
|
|
|
|
"instances of GObject, boxed types, pointer types and strings");
|
|
|
|
return NULL;
|
|
|
|
}
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
|
|
|
|
/* no need to lock, nothing can change here */
|
|
|
|
result = (GstListIterator *) gst_iterator_new (sizeof (GstListIterator),
|
2005-10-07 00:14:45 +00:00
|
|
|
type,
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
lock,
|
|
|
|
master_cookie,
|
2011-03-16 09:50:39 +00:00
|
|
|
(GstIteratorCopyFunction) gst_list_iterator_copy,
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
(GstIteratorNextFunction) gst_list_iterator_next,
|
|
|
|
(GstIteratorItemFunction) item,
|
|
|
|
(GstIteratorResyncFunction) gst_list_iterator_resync,
|
|
|
|
(GstIteratorFreeFunction) gst_list_iterator_free);
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
result->owner = owner ? g_object_ref (owner) : NULL;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
result->orig = list;
|
|
|
|
result->list = *list;
|
2011-03-16 09:50:39 +00:00
|
|
|
result->set_value = set_value;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
|
|
|
|
return GST_ITERATOR (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_iterator_pop (GstIterator * it)
|
|
|
|
{
|
|
|
|
if (it->pushed) {
|
|
|
|
gst_iterator_free (it->pushed);
|
|
|
|
it->pushed = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_iterator_next:
|
|
|
|
* @it: The #GstIterator to iterate
|
2011-08-12 09:45:01 +00:00
|
|
|
* @elem: (out caller-allocates): pointer to hold next element
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
2008-08-29 17:58:25 +00:00
|
|
|
* Get the next item from the iterator in @elem.
|
|
|
|
*
|
|
|
|
* Only when this function returns %GST_ITERATOR_OK, @elem will contain a valid
|
2011-03-16 09:50:39 +00:00
|
|
|
* value. @elem must have been initialized to the type of the iterator or
|
|
|
|
* initialized to zeroes with g_value_unset(). The caller is responsible for
|
|
|
|
* unsetting or resetting @elem with g_value_unset() or g_value_reset()
|
|
|
|
* after usage.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2008-08-29 17:58:25 +00:00
|
|
|
* When this function returns %GST_ITERATOR_DONE, no more elements can be
|
|
|
|
* retrieved from @it.
|
|
|
|
*
|
|
|
|
* A return value of %GST_ITERATOR_RESYNC indicates that the element list was
|
|
|
|
* concurrently updated. The user of @it should call gst_iterator_resync() to
|
|
|
|
* get the newly updated list.
|
|
|
|
*
|
|
|
|
* A return value of %GST_ITERATOR_ERROR indicates an unrecoverable fatal error.
|
|
|
|
*
|
2011-03-16 09:50:39 +00:00
|
|
|
* Returns: The result of the iteration. Unset @elem after usage.
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstIteratorResult
|
2011-03-16 09:50:39 +00:00
|
|
|
gst_iterator_next (GstIterator * it, GValue * elem)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
|
|
|
GstIteratorResult result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (it != NULL, GST_ITERATOR_ERROR);
|
|
|
|
g_return_val_if_fail (elem != NULL, GST_ITERATOR_ERROR);
|
2011-03-16 09:50:39 +00:00
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (elem) == G_TYPE_INVALID
|
|
|
|
|| G_VALUE_HOLDS (elem, it->type), GST_ITERATOR_ERROR);
|
|
|
|
|
|
|
|
if (G_VALUE_TYPE (elem) == G_TYPE_INVALID)
|
|
|
|
g_value_init (elem, it->type);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
|
|
|
|
restart:
|
|
|
|
if (it->pushed) {
|
|
|
|
result = gst_iterator_next (it->pushed, elem);
|
|
|
|
if (result == GST_ITERATOR_DONE) {
|
|
|
|
/* we are done with this iterator, pop it and
|
|
|
|
* fallthrough iterating the main iterator again. */
|
|
|
|
gst_iterator_pop (it);
|
|
|
|
} else {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (G_LIKELY (it->lock))
|
|
|
|
g_mutex_lock (it->lock);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (*it->master_cookie != it->cookie)) {
|
|
|
|
result = GST_ITERATOR_RESYNC;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = it->next (it, elem);
|
|
|
|
if (result == GST_ITERATOR_OK && it->item) {
|
|
|
|
GstIteratorItem itemres;
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
itemres = it->item (it, elem);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
switch (itemres) {
|
|
|
|
case GST_ITERATOR_ITEM_SKIP:
|
|
|
|
if (G_LIKELY (it->lock))
|
|
|
|
g_mutex_unlock (it->lock);
|
2011-03-16 09:50:39 +00:00
|
|
|
g_value_reset (elem);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
goto restart;
|
|
|
|
case GST_ITERATOR_ITEM_END:
|
|
|
|
result = GST_ITERATOR_DONE;
|
2011-03-16 09:50:39 +00:00
|
|
|
g_value_reset (elem);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
break;
|
|
|
|
case GST_ITERATOR_ITEM_PASS:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (G_LIKELY (it->lock))
|
|
|
|
g_mutex_unlock (it->lock);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_iterator_resync:
|
|
|
|
* @it: The #GstIterator to resync
|
|
|
|
*
|
|
|
|
* Resync the iterator. this function is mostly called
|
2006-01-27 22:34:51 +00:00
|
|
|
* after gst_iterator_next() returned %GST_ITERATOR_RESYNC.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2008-08-29 17:58:25 +00:00
|
|
|
* When an iterator was pushed on @it, it will automatically be popped again
|
|
|
|
* with this function.
|
|
|
|
*
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_iterator_resync (GstIterator * it)
|
|
|
|
{
|
|
|
|
g_return_if_fail (it != NULL);
|
|
|
|
|
|
|
|
gst_iterator_pop (it);
|
|
|
|
|
|
|
|
if (G_LIKELY (it->lock))
|
|
|
|
g_mutex_lock (it->lock);
|
|
|
|
it->resync (it);
|
|
|
|
it->cookie = *it->master_cookie;
|
|
|
|
if (G_LIKELY (it->lock))
|
|
|
|
g_mutex_unlock (it->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_iterator_free:
|
|
|
|
* @it: The #GstIterator to free
|
|
|
|
*
|
2005-08-20 12:39:05 +00:00
|
|
|
* Free the iterator.
|
|
|
|
*
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_iterator_free (GstIterator * it)
|
|
|
|
{
|
|
|
|
g_return_if_fail (it != NULL);
|
|
|
|
|
|
|
|
gst_iterator_pop (it);
|
|
|
|
|
|
|
|
it->free (it);
|
2011-01-08 14:12:41 +00:00
|
|
|
|
2011-01-08 14:14:40 +00:00
|
|
|
g_slice_free1 (it->size, it);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_iterator_push:
|
|
|
|
* @it: The #GstIterator to use
|
|
|
|
* @other: The #GstIterator to push
|
|
|
|
*
|
|
|
|
* Pushes @other iterator onto @it. All calls performed on @it are
|
2009-03-11 22:41:24 +00:00
|
|
|
* forwarded to @other. If @other returns %GST_ITERATOR_DONE, it is
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* popped again and calls are handled by @it again.
|
|
|
|
*
|
|
|
|
* This function is mainly used by objects implementing the iterator
|
|
|
|
* next function to recurse into substructures.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2008-08-29 17:58:25 +00:00
|
|
|
* When gst_iterator_resync() is called on @it, @other will automatically be
|
|
|
|
* popped.
|
|
|
|
*
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_iterator_push (GstIterator * it, GstIterator * other)
|
|
|
|
{
|
|
|
|
g_return_if_fail (it != NULL);
|
|
|
|
g_return_if_fail (other != NULL);
|
|
|
|
|
|
|
|
it->pushed = other;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct _GstIteratorFilter
|
|
|
|
{
|
|
|
|
GstIterator iterator;
|
|
|
|
GstIterator *slave;
|
|
|
|
|
|
|
|
GCompareFunc func;
|
2011-03-16 09:50:39 +00:00
|
|
|
GValue user_data;
|
|
|
|
gboolean have_user_data;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
} GstIteratorFilter;
|
|
|
|
|
|
|
|
static GstIteratorResult
|
2011-03-16 09:50:39 +00:00
|
|
|
filter_next (GstIteratorFilter * it, GValue * elem)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
|
|
|
GstIteratorResult result = GST_ITERATOR_ERROR;
|
|
|
|
gboolean done = FALSE;
|
2011-03-16 09:50:39 +00:00
|
|
|
GValue item = { 0, };
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
|
|
|
|
while (G_LIKELY (!done)) {
|
|
|
|
result = gst_iterator_next (it->slave, &item);
|
|
|
|
switch (result) {
|
|
|
|
case GST_ITERATOR_OK:
|
|
|
|
if (G_LIKELY (GST_ITERATOR (it)->lock))
|
|
|
|
g_mutex_unlock (GST_ITERATOR (it)->lock);
|
2011-03-16 09:50:39 +00:00
|
|
|
if (it->func (&item, &it->user_data) == 0) {
|
|
|
|
g_value_copy (&item, elem);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
done = TRUE;
|
|
|
|
}
|
2011-03-16 09:50:39 +00:00
|
|
|
g_value_reset (&item);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
if (G_LIKELY (GST_ITERATOR (it)->lock))
|
|
|
|
g_mutex_lock (GST_ITERATOR (it)->lock);
|
|
|
|
break;
|
|
|
|
case GST_ITERATOR_RESYNC:
|
|
|
|
case GST_ITERATOR_DONE:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-03-16 09:50:39 +00:00
|
|
|
g_value_unset (&item);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-03-16 09:50:39 +00:00
|
|
|
filter_copy (const GstIteratorFilter * it, GstIteratorFilter * copy)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
2011-03-16 09:50:39 +00:00
|
|
|
copy->slave = gst_iterator_copy (it->slave);
|
|
|
|
|
|
|
|
if (it->have_user_data) {
|
|
|
|
memset (©->user_data, 0, sizeof (copy->user_data));
|
|
|
|
g_value_init (©->user_data, G_VALUE_TYPE (&it->user_data));
|
|
|
|
g_value_copy (&it->user_data, ©->user_data);
|
|
|
|
}
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-03-16 09:50:39 +00:00
|
|
|
filter_resync (GstIteratorFilter * it)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
2011-03-16 09:50:39 +00:00
|
|
|
gst_iterator_resync (it->slave);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
filter_free (GstIteratorFilter * it)
|
|
|
|
{
|
2011-03-16 09:50:39 +00:00
|
|
|
if (it->have_user_data)
|
|
|
|
g_value_unset (&it->user_data);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
gst_iterator_free (it->slave);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_iterator_filter:
|
|
|
|
* @it: The #GstIterator to filter
|
2011-04-14 13:51:24 +00:00
|
|
|
* @func: (scope call): the compare function to select elements
|
|
|
|
* @user_data: (closure): user data passed to the compare function
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
|
|
|
* Create a new iterator from an existing iterator. The new iterator
|
2005-11-09 15:31:08 +00:00
|
|
|
* will only return those elements that match the given compare function @func.
|
2011-03-16 09:50:39 +00:00
|
|
|
* The first parameter that is passed to @func is the #GValue of the current
|
|
|
|
* iterator element and the second parameter is @user_data. @func should
|
|
|
|
* return 0 for elements that should be included in the filtered iterator.
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
|
|
|
* When this iterator is freed, @it will also be freed.
|
|
|
|
*
|
2011-04-14 13:51:24 +00:00
|
|
|
* Returns: (transfer full): a new #GstIterator.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstIterator *
|
2011-03-16 09:50:39 +00:00
|
|
|
gst_iterator_filter (GstIterator * it, GCompareFunc func,
|
|
|
|
const GValue * user_data)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
|
|
|
GstIteratorFilter *result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (it != NULL, NULL);
|
|
|
|
g_return_val_if_fail (func != NULL, NULL);
|
|
|
|
|
|
|
|
result = (GstIteratorFilter *) gst_iterator_new (sizeof (GstIteratorFilter),
|
2005-10-07 00:14:45 +00:00
|
|
|
it->type, it->lock, it->master_cookie,
|
2011-03-16 09:50:39 +00:00
|
|
|
(GstIteratorCopyFunction) filter_copy,
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
(GstIteratorNextFunction) filter_next,
|
|
|
|
(GstIteratorItemFunction) NULL,
|
|
|
|
(GstIteratorResyncFunction) filter_resync,
|
|
|
|
(GstIteratorFreeFunction) filter_free);
|
2011-03-16 09:50:39 +00:00
|
|
|
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
it->lock = NULL;
|
|
|
|
result->func = func;
|
2011-03-16 09:50:39 +00:00
|
|
|
if (user_data) {
|
|
|
|
g_value_init (&result->user_data, G_VALUE_TYPE (user_data));
|
|
|
|
g_value_copy (user_data, &result->user_data);
|
|
|
|
result->have_user_data = TRUE;
|
|
|
|
} else {
|
|
|
|
result->have_user_data = FALSE;
|
|
|
|
}
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
result->slave = it;
|
|
|
|
|
|
|
|
return GST_ITERATOR (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_iterator_fold:
|
2005-11-09 15:31:08 +00:00
|
|
|
* @it: The #GstIterator to fold over
|
2011-04-14 13:51:24 +00:00
|
|
|
* @func: (scope call): the fold function
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* @ret: the seed value passed to the fold function
|
2011-04-14 13:51:24 +00:00
|
|
|
* @user_data: (closure): user data passed to the fold function
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
2008-08-29 17:58:25 +00:00
|
|
|
* Folds @func over the elements of @iter. That is to say, @func will be called
|
|
|
|
* as @func (object, @ret, @user_data) for each object in @it. The normal use
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* of this procedure is to accumulate the results of operating on the objects in
|
2011-03-16 09:50:39 +00:00
|
|
|
* @ret.
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
2009-03-11 22:41:24 +00:00
|
|
|
* This procedure can be used (and is used internally) to implement the
|
|
|
|
* gst_iterator_foreach() and gst_iterator_find_custom() operations.
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
|
|
|
* The fold will proceed as long as @func returns TRUE. When the iterator has no
|
2009-03-11 22:41:24 +00:00
|
|
|
* more arguments, %GST_ITERATOR_DONE will be returned. If @func returns FALSE,
|
|
|
|
* the fold will stop, and %GST_ITERATOR_OK will be returned. Errors or resyncs
|
|
|
|
* will cause fold to return %GST_ITERATOR_ERROR or %GST_ITERATOR_RESYNC as
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* appropriate.
|
|
|
|
*
|
|
|
|
* The iterator will not be freed.
|
|
|
|
*
|
|
|
|
* Returns: A #GstIteratorResult, as described above.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstIteratorResult
|
2005-11-09 15:31:08 +00:00
|
|
|
gst_iterator_fold (GstIterator * it, GstIteratorFoldFunction func,
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
GValue * ret, gpointer user_data)
|
|
|
|
{
|
2011-03-16 09:50:39 +00:00
|
|
|
GValue item = { 0, };
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
GstIteratorResult result;
|
|
|
|
|
|
|
|
while (1) {
|
2005-11-09 15:31:08 +00:00
|
|
|
result = gst_iterator_next (it, &item);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
switch (result) {
|
|
|
|
case GST_ITERATOR_OK:
|
2011-03-16 09:50:39 +00:00
|
|
|
if (!func (&item, ret, user_data))
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
goto fold_done;
|
2011-03-16 09:50:39 +00:00
|
|
|
|
|
|
|
g_value_reset (&item);
|
|
|
|
break;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
case GST_ITERATOR_RESYNC:
|
|
|
|
case GST_ITERATOR_ERROR:
|
|
|
|
goto fold_done;
|
|
|
|
case GST_ITERATOR_DONE:
|
|
|
|
goto fold_done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fold_done:
|
2011-03-16 09:50:39 +00:00
|
|
|
g_value_unset (&item);
|
|
|
|
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2011-03-16 09:50:39 +00:00
|
|
|
GstIteratorForeachFunction func;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
gpointer user_data;
|
|
|
|
} ForeachFoldData;
|
|
|
|
|
|
|
|
static gboolean
|
2011-03-16 09:50:39 +00:00
|
|
|
foreach_fold_func (const GValue * item, GValue * unused, ForeachFoldData * data)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
|
|
|
data->func (item, data->user_data);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_iterator_foreach:
|
2005-11-09 15:31:08 +00:00
|
|
|
* @it: The #GstIterator to iterate
|
2011-04-14 13:51:24 +00:00
|
|
|
* @func: (scope call): the function to call for each element.
|
|
|
|
* @user_data: (closure): user data passed to the function
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
2005-11-09 15:31:08 +00:00
|
|
|
* Iterate over all element of @it and call the given function @func for
|
2011-03-16 09:50:39 +00:00
|
|
|
* each element.
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
|
|
|
* Returns: the result call to gst_iterator_fold(). The iterator will not be
|
|
|
|
* freed.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstIteratorResult
|
2011-03-16 09:50:39 +00:00
|
|
|
gst_iterator_foreach (GstIterator * it, GstIteratorForeachFunction func,
|
|
|
|
gpointer user_data)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
|
|
|
ForeachFoldData data;
|
|
|
|
|
|
|
|
data.func = func;
|
|
|
|
data.user_data = user_data;
|
|
|
|
|
2005-11-09 15:31:08 +00:00
|
|
|
return gst_iterator_fold (it, (GstIteratorFoldFunction) foreach_fold_func,
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
NULL, &data);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GCompareFunc func;
|
|
|
|
gpointer user_data;
|
2011-03-16 09:50:39 +00:00
|
|
|
gboolean found;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
} FindCustomFoldData;
|
|
|
|
|
|
|
|
static gboolean
|
2011-03-16 09:50:39 +00:00
|
|
|
find_custom_fold_func (const GValue * item, GValue * ret,
|
|
|
|
FindCustomFoldData * data)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
2005-03-09 16:10:59 +00:00
|
|
|
if (data->func (item, data->user_data) == 0) {
|
2011-03-16 09:50:39 +00:00
|
|
|
data->found = TRUE;
|
|
|
|
g_value_copy (item, ret);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_iterator_find_custom:
|
|
|
|
* @it: The #GstIterator to iterate
|
2011-04-14 13:51:24 +00:00
|
|
|
* @func: (scope call): the compare function to use
|
2011-06-05 17:11:22 +00:00
|
|
|
* @elem: (out): pointer to a #GValue where to store the result
|
2011-04-14 13:51:24 +00:00
|
|
|
* @user_data: (closure): user data passed to the compare function
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
2005-11-09 15:31:08 +00:00
|
|
|
* Find the first element in @it that matches the compare function @func.
|
2011-03-16 09:50:39 +00:00
|
|
|
* @func should return 0 when the element is found. The first parameter
|
|
|
|
* to @func will be the current element of the iterator and the
|
|
|
|
* second parameter will be @user_data.
|
|
|
|
* The result will be stored in @elem if a result is found.
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
|
|
|
* The iterator will not be freed.
|
|
|
|
*
|
2011-03-16 09:50:39 +00:00
|
|
|
* This function will return FALSE if an error happened to the iterator
|
|
|
|
* or if the element wasn't found.
|
2005-10-28 16:21:29 +00:00
|
|
|
*
|
2011-03-16 09:50:39 +00:00
|
|
|
* Returns: Returns TRUE if the element was found, else FALSE.
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
2011-03-16 09:50:39 +00:00
|
|
|
gboolean
|
2005-11-09 15:31:08 +00:00
|
|
|
gst_iterator_find_custom (GstIterator * it, GCompareFunc func,
|
2011-03-16 09:50:39 +00:00
|
|
|
GValue * elem, gpointer user_data)
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
{
|
|
|
|
GstIteratorResult res;
|
|
|
|
FindCustomFoldData data;
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (elem) == G_TYPE_INVALID
|
|
|
|
|| G_VALUE_HOLDS (elem, it->type), GST_ITERATOR_ERROR);
|
|
|
|
|
|
|
|
if (G_VALUE_TYPE (elem) == G_TYPE_INVALID)
|
|
|
|
g_value_init (elem, it->type);
|
|
|
|
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
data.func = func;
|
|
|
|
data.user_data = user_data;
|
2011-03-16 09:50:39 +00:00
|
|
|
data.found = FALSE;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
|
2010-06-13 09:24:10 +00:00
|
|
|
do {
|
|
|
|
res =
|
|
|
|
gst_iterator_fold (it, (GstIteratorFoldFunction) find_custom_fold_func,
|
2011-03-16 09:50:39 +00:00
|
|
|
elem, &data);
|
2010-12-14 15:06:46 +00:00
|
|
|
if (res == GST_ITERATOR_RESYNC)
|
|
|
|
gst_iterator_resync (it);
|
2010-06-13 09:24:10 +00:00
|
|
|
} while (res == GST_ITERATOR_RESYNC);
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
if (!data.found)
|
|
|
|
g_value_unset (elem);
|
|
|
|
|
|
|
|
return data.found;
|
gst/gstiterator.*: Added missing files.
Original commit message from CVS:
* gst/gstiterator.c: (gst_iterator_init), (gst_iterator_new),
(gst_list_iterator_next), (gst_list_iterator_resync),
(gst_list_iterator_free), (gst_iterator_new_list),
(gst_iterator_pop), (gst_iterator_next), (gst_iterator_resync),
(gst_iterator_free), (gst_iterator_push), (filter_next),
(filter_resync), (filter_uninit), (filter_free),
(gst_iterator_filter), (gst_iterator_fold), (foreach_fold_func),
(gst_iterator_foreach), (find_custom_fold_func),
(gst_iterator_find_custom):
* gst/gstiterator.h:
Added missing files.
2005-03-07 18:29:36 +00:00
|
|
|
}
|
2009-08-26 14:39:19 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstIterator parent;
|
2011-03-16 09:50:39 +00:00
|
|
|
GValue object;
|
2009-08-26 14:39:19 +00:00
|
|
|
gboolean visited;
|
2011-03-16 09:50:39 +00:00
|
|
|
gboolean empty;
|
2009-08-26 14:39:19 +00:00
|
|
|
} GstSingleObjectIterator;
|
|
|
|
|
|
|
|
static guint32 _single_object_dummy_cookie = 0;
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
static void
|
|
|
|
gst_single_object_iterator_copy (const GstSingleObjectIterator * it,
|
|
|
|
GstSingleObjectIterator * copy)
|
|
|
|
{
|
|
|
|
if (!it->empty) {
|
|
|
|
memset (©->object, 0, sizeof (copy->object));
|
|
|
|
g_value_init (©->object, it->parent.type);
|
|
|
|
g_value_copy (&it->object, ©->object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-26 14:39:19 +00:00
|
|
|
static GstIteratorResult
|
2011-03-16 09:50:39 +00:00
|
|
|
gst_single_object_iterator_next (GstSingleObjectIterator * it, GValue * result)
|
2009-08-26 14:39:19 +00:00
|
|
|
{
|
2011-03-16 09:50:39 +00:00
|
|
|
if (it->visited || it->empty)
|
2009-08-26 14:39:19 +00:00
|
|
|
return GST_ITERATOR_DONE;
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
g_value_copy (&it->object, result);
|
2009-09-01 08:20:59 +00:00
|
|
|
it->visited = TRUE;
|
2011-03-16 09:50:39 +00:00
|
|
|
|
2009-08-26 14:39:19 +00:00
|
|
|
return GST_ITERATOR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_single_object_iterator_resync (GstSingleObjectIterator * it)
|
|
|
|
{
|
|
|
|
it->visited = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_single_object_iterator_free (GstSingleObjectIterator * it)
|
|
|
|
{
|
2011-03-16 09:50:39 +00:00
|
|
|
if (!it->empty)
|
|
|
|
g_value_unset (&it->object);
|
2009-08-26 14:39:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-08-31 18:38:07 +00:00
|
|
|
* gst_iterator_new_single:
|
2009-08-26 14:39:19 +00:00
|
|
|
* @type: #GType of the passed object
|
|
|
|
* @object: object that this iterator should return
|
|
|
|
*
|
|
|
|
* This #GstIterator is a convenient iterator for the common
|
|
|
|
* case where a #GstIterator needs to be returned but only
|
2009-10-14 08:16:31 +00:00
|
|
|
* a single object has to be considered. This happens often
|
2009-08-26 14:39:19 +00:00
|
|
|
* for the #GstPadIterIntLinkFunction.
|
|
|
|
*
|
2009-08-31 18:38:07 +00:00
|
|
|
* Returns: the new #GstIterator for @object.
|
2009-08-26 14:39:19 +00:00
|
|
|
*
|
2009-08-31 18:38:07 +00:00
|
|
|
* Since: 0.10.25
|
2009-08-26 14:39:19 +00:00
|
|
|
*/
|
|
|
|
GstIterator *
|
2011-03-16 09:50:39 +00:00
|
|
|
gst_iterator_new_single (GType type, const GValue * object)
|
2009-08-26 14:39:19 +00:00
|
|
|
{
|
|
|
|
GstSingleObjectIterator *result;
|
|
|
|
|
|
|
|
result = (GstSingleObjectIterator *)
|
|
|
|
gst_iterator_new (sizeof (GstSingleObjectIterator),
|
2009-09-01 05:27:25 +00:00
|
|
|
type, NULL, &_single_object_dummy_cookie,
|
2011-03-16 09:50:39 +00:00
|
|
|
(GstIteratorCopyFunction) gst_single_object_iterator_copy,
|
|
|
|
(GstIteratorNextFunction) gst_single_object_iterator_next,
|
|
|
|
(GstIteratorItemFunction) NULL,
|
2009-08-26 14:39:19 +00:00
|
|
|
(GstIteratorResyncFunction) gst_single_object_iterator_resync,
|
|
|
|
(GstIteratorFreeFunction) gst_single_object_iterator_free);
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
if (object) {
|
|
|
|
g_value_init (&result->object, type);
|
|
|
|
g_value_copy (object, &result->object);
|
|
|
|
result->empty = FALSE;
|
|
|
|
} else {
|
|
|
|
result->empty = TRUE;
|
|
|
|
}
|
2009-08-26 14:39:19 +00:00
|
|
|
result->visited = FALSE;
|
|
|
|
|
2011-03-16 09:50:39 +00:00
|
|
|
return GST_ITERATOR (result);
|
2009-08-26 14:39:19 +00:00
|
|
|
}
|