4f1395ef675d573529c17e37a256fe2e76815be5
[platform/upstream/gstreamer.git] / gst / gstfilter.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <gst/gstfilter.h>
21
22 GList *
23 gst_filter_run (const GList * list, GstFilterFunc func, gboolean first,
24     gpointer user_data)
25 {
26   const GList *walk = list;
27   GList *result = NULL;
28
29   while (walk) {
30     gboolean res = TRUE;
31     gpointer data = walk->data;
32
33     walk = g_list_next (walk);
34
35     if (func)
36       res = func (data, user_data);
37
38     if (res) {
39       result = g_list_prepend (result, data);
40
41       if (first)
42         break;
43     }
44   }
45
46   return result;
47 }