summaryrefslogtreecommitdiff
path: root/src/command.c
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-12-13 11:29:11 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-12-13 16:30:37 +0100
commitcaf68ab21e373594866ef2b26736d3ae02ac6659 (patch)
tree012f32148fefd64d057926aa09ab19cf331873f7 /src/command.c
parenteb6b66cde77a03e0a42999fdf6d5abdb9c373ca6 (diff)
downloadpa-sink-ctl-caf68ab21e373594866ef2b26736d3ae02ac6659.tar.gz
pa-sink-ctl-caf68ab21e373594866ef2b26736d3ae02ac6659.tar.bz2
pa-sink-ctl-caf68ab21e373594866ef2b26736d3ae02ac6659.zip
Add a list_foreach makro for GList
Saves around 1-2 lines per foreach, and should be more error prone.
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/command.c b/src/command.c
index db131e4..3abe744 100644
--- a/src/command.c
+++ b/src/command.c
@@ -27,15 +27,12 @@
static int
sink_input_len(struct context *ctx, struct sink_info *sink)
{
+ struct sink_input_info *input;
int len = 0;
- GList *l;
-
- for (l = ctx->input_list; l; l = l->next) {
- struct sink_input_info *input = l->data;
+ list_foreach(ctx->input_list, input)
if (input->sink == sink->index)
len++;
- }
return len;
}
@@ -43,11 +40,10 @@ sink_input_len(struct context *ctx, struct sink_info *sink)
static struct sink_input_info *
sink_get_nth_input(struct context *ctx, struct sink_info *sink, int n)
{
- GList *l;
+ struct sink_input_info *input;
int i = 0;
- for (l = ctx->input_list; l; l = l->next) {
- struct sink_input_info *input = l->data;
+ list_foreach(ctx->input_list, input) {
if (input->sink != sink->index)
continue;
if (i++ == n)
@@ -182,7 +178,7 @@ static void
switch_sink(struct context *ctx, int key)
{
struct sink_info *sink = NULL;
- struct sink_input_info *input;
+ struct sink_input_info *input, *t;
pa_operation *o;
gint i;
@@ -207,9 +203,7 @@ switch_sink(struct context *ctx, int key)
/* get new chooser_input, if non, select sink as fallback */
ctx->chooser_input = SELECTED_SINK;
i = -1;
- for (GList *l = ctx->input_list; l; l = l->next) {
- struct sink_input_info *t = l->data;
-
+ list_foreach(ctx->input_list, t) {
if (t->index == input->index) {
ctx->chooser_input = ++i;
break;