Merge commit 'fml/master'
[paraslash.git] / grab_client.c
index 926e8fd..77d3616 100644 (file)
@@ -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);
 }