Fix a bug in the output of para_audioc.
[paraslash.git] / grab_client.c
index 926e8fd..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;
@@ -164,7 +164,7 @@ void activate_grab_client(struct grab_client *gc, struct filter_node *fn)
  *
  * \param slot_num Audiod's slot for the new audio file.
  * \param audio_format_num The number of the audio format of the new audio file.
- * \param filter_list The list of activated filters for that new audio file.
+ * \param fc The filter chain containing the activated filters.
  *
  * This is called from audiod.c when the current audio file changes. It loops
  * over all inactive grab clients and checks each grab client's configuration
@@ -176,10 +176,10 @@ void activate_grab_client(struct grab_client *gc, struct filter_node *fn)
  * activate_grab_client.
  */
 void activate_inactive_grab_clients(int slot_num, int audio_format_num,
-               struct list_head *filter_list)
+               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,17 +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;
-               i = 1;
-               list_for_each_entry(fn, filter_list, node) {
-                       if (gc->conf->filter_num_arg <= 0
-                               || i == gc->conf->filter_num_arg)
-                               break;
-                       i++;
-               }
+               fn = fc->filter_nodes + filter_num;
                activate_grab_client(gc, fn);
        }
 }
@@ -271,6 +264,6 @@ err_out:
  */
 void init_grabbing(void)
 {
-       PARA_INFO_LOG("%s", "grab init\n");
+       PARA_INFO_LOG("grab init\n");
        INIT_LIST_HEAD(&inactive_grab_client_list);
 }