Fix a bug in the output of para_audioc.
[paraslash.git] / grab_client.c
index 13b066b..9b4ef69 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 #include "grab_client.cmdline.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "filter.h"
 #include "grab_client.h"
 #include "audiod.h"
 #include "error.h"
 #include "string.h"
 #include "fd.h"
-#include "crypt.h"
 
 /** Grab clients that are not yet attached to a filter node. */
 struct list_head inactive_grab_client_list;
@@ -82,7 +82,7 @@ static int check_gc_args(struct grab_client *gc)
 {
        int i;
        struct grab_client_args_info *c = gc->conf;
-       char **mv = grab_client_cmdline_parser_mode_values;
+       const char **mv = grab_client_cmdline_parser_mode_values;
 
        PARA_INFO_LOG("filter_num: %d\n", c->filter_num_arg);
        for (i = 0; mv[i]; i++)
@@ -97,15 +97,15 @@ static int check_gc_args(struct grab_client *gc)
                if (gc->audio_format_num < 0)
                        return gc->audio_format_num;
        }
-       if (c->slot_arg > MAX_STREAM_SLOTS)
+       if (c->slot_arg >= MAX_STREAM_SLOTS)
                return -E_BAD_GC_SLOT;
-       if (c->filter_num_arg <= 0)
+       if (c->filter_num_arg < 0)
                return -E_BAD_GC_FILTER_NUM;
        if (c->audio_format_given) {
-               if (num_filters(gc->audio_format_num) < c->filter_num_arg)
+               if (num_filters(gc->audio_format_num) <= c->filter_num_arg)
                        return -E_BAD_GC_FILTER_NUM;
        } else
-               if (c->filter_num_arg > max_num_filters())
+               if (c->filter_num_arg >= max_num_filters())
                        return -E_BAD_GC_FILTER_NUM;
 
        return 1;
@@ -179,7 +179,7 @@ void activate_inactive_grab_clients(int slot_num, int audio_format_num,
                struct filter_chain *fc)
 {
        struct grab_client *gc, *tmp;
-       int i;
+       int filter_num;
        struct filter_node *fn;
 
        list_for_each_entry_safe(gc, tmp, &inactive_grab_client_list, node) {
@@ -189,15 +189,10 @@ void activate_inactive_grab_clients(int slot_num, int audio_format_num,
                if (gc->audio_format_num >= 0 && gc->audio_format_num !=
                                audio_format_num)
                        continue;
-               if (gc->conf->filter_num_arg >= 0 &&
-                               num_filters(gc->audio_format_num)
-                               < gc->conf->filter_num_arg)
+               filter_num = gc->conf->filter_num_arg;
+               if (filter_num >= num_filters(gc->audio_format_num))
                        continue;
-               FOR_EACH_FILTER_NODE(fn, fc, i) {
-                       if (gc->conf->filter_num_arg <= 0
-                               || i == gc->conf->filter_num_arg + 1)
-                               break;
-               }
+               fn = fc->filter_nodes + filter_num;
                activate_grab_client(gc, fn);
        }
 }