diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-12-18 14:04:51 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-12-18 14:06:15 +0100 |
commit | 39c8fde50099d46f5c1bb2f12900eae420f90637 (patch) | |
tree | 39b3dfd1b1c2143356a0394000b11cb5f595dc94 /src/interface.c | |
parent | 1a8eafaf70f864b5bf360f92de7d637bbca26098 (diff) | |
download | pa-sink-ctl-39c8fde50099d46f5c1bb2f12900eae420f90637.tar.gz pa-sink-ctl-39c8fde50099d46f5c1bb2f12900eae420f90637.tar.bz2 pa-sink-ctl-39c8fde50099d46f5c1bb2f12900eae420f90637.zip |
Finally move interface_get_current_ctl into interface.c
Diffstat (limited to 'src/interface.c')
-rw-r--r-- | src/interface.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/interface.c b/src/interface.c index 1d23a30..10a16e3 100644 --- a/src/interface.c +++ b/src/interface.c @@ -38,6 +38,50 @@ #include "unix_signal.h" #endif +static struct sink_input_info * +sink_get_nth_input(struct context *ctx, struct sink_info *sink, int n) +{ + struct sink_input_info *input; + int i = 0; + + list_foreach(ctx->input_list, input) { + if (input->sink != sink->base.index) + continue; + if (i++ == n) + return input; + } + + return NULL; +} + +struct vol_ctl * +interface_get_current_ctl(struct context *ctx, struct vol_ctl **parent) +{ + struct sink_info *sink; + struct sink_input_info *input; + + if (parent) + *parent = NULL; + + sink = g_list_nth_data(ctx->sink_list, ctx->chooser_sink); + if (sink == NULL) + return NULL; + + if (ctx->chooser_input == SELECTED_SINK) + return &sink->base; + else if (ctx->chooser_input >= 0) { + input = sink_get_nth_input(ctx, sink, ctx->chooser_input); + if (input == NULL) + return NULL; + if (parent) + *parent = &sink->base; + return &input->base; + } + + g_assert(0); + return NULL; +} + static gboolean interface_resize(gpointer data) { |