From 3dfab6fc800bec957eee78aa642d0b139300d470 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 2 Apr 2008 23:08:09 +0200 Subject: [PATCH] Grab cleanups and fixes. Change semantics of the filter number to zero-based. --- audiod.c | 4 ++-- audiod_command.c | 12 +++--------- grab_client.c | 12 +++++------- grab_client.ggo | 2 +- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/audiod.c b/audiod.c index 295c3755..3c737226 100644 --- a/audiod.c +++ b/audiod.c @@ -294,7 +294,7 @@ static void open_filters(int slot_num) INIT_LIST_HEAD(&fn->callbacks); f->open(fn); PARA_NOTICE_LOG("%s filter %d/%d (%s) started in slot %d\n", - audio_formats[s->format], i + 1, nf, f->name, slot_num); + audio_formats[s->format], i, nf, f->name, slot_num); s->fc->outbuf = fn->buf; s->fc->out_loaded = &fn->loaded; } @@ -539,7 +539,7 @@ static int add_filter(int format, char *cmdline) return filter_num; a->filter_nums[nf] = filter_num; a->num_filters++; - PARA_INFO_LOG("%s filter %d: %s\n", audio_formats[format], nf + 1, + PARA_INFO_LOG("%s filter %d: %s\n", audio_formats[format], nf, filters[filter_num].name); return filter_num; } diff --git a/audiod_command.c b/audiod_command.c index 0428bea1..b4c50dc8 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -279,8 +279,7 @@ out: static struct filter_node *find_filter_node(int slot_num, int format, int filternum) { - struct filter_node *fn; - int i, j; + int i; FOR_EACH_SLOT(i) { struct slot_info *s = &slot[i]; @@ -290,15 +289,10 @@ static struct filter_node *find_filter_node(int slot_num, int format, int filter continue; if (format >= 0 && s->format != format) continue; - if (num_filters(i) < filternum) + if (num_filters(i) <= filternum) continue; /* success */ - j = 1; - FOR_EACH_FILTER_NODE(fn, s->fc, j) { - if (filternum <= 0 || j++ == filternum) - break; - } - return fn; + return s->fc->filter_nodes + filternum; } return NULL; } diff --git a/grab_client.c b/grab_client.c index 4be23d78..77d3616d 100644 --- a/grab_client.c +++ b/grab_client.c @@ -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; @@ -190,10 +190,8 @@ void activate_inactive_grab_clients(int slot_num, int audio_format_num, audio_format_num) continue; filter_num = gc->conf->filter_num_arg; - if (filter_num >= 0 && filter_num >= num_filters(gc->audio_format_num)) + if (filter_num >= num_filters(gc->audio_format_num)) continue; - if (filter_num < 0) - filter_num = 0; fn = fc->filter_nodes + filter_num; activate_grab_client(gc, fn); } diff --git a/grab_client.ggo b/grab_client.ggo index 263259dd..5527143b 100644 --- a/grab_client.ggo +++ b/grab_client.ggo @@ -1,7 +1,7 @@ option "filter_num" f "point of filter chain to grab" int typestr="num" - default="1" + default="0" optional option "slot" s -- 2.39.5