summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/command.c17
-rw-r--r--src/ctl.h1
-rw-r--r--src/pa-sink-ctl.c16
3 files changed, 19 insertions, 15 deletions
diff --git a/src/command.c b/src/command.c
index 47e42a4..7ab68cb 100644
--- a/src/command.c
+++ b/src/command.c
@@ -24,19 +24,6 @@
#include "ctl.h"
#include "command.h"
-static int
-main_ctl_childs_len(struct context *ctx, struct main_ctl *ctl)
-{
- struct slave_ctl *sctl;
- int len = 0;
-
- list_foreach(*ctl->childs_list, sctl)
- if (sctl->parent_index == ctl->base.index)
- len++;
-
- return len;
-}
-
static void
up(struct context *ctx, int key)
{
@@ -53,7 +40,7 @@ up(struct context *ctx, int key)
ctl = (struct main_ctl *) interface_get_current_ctl(ifc, NULL);
/* autoassigment to SELECTED_MAIN_CTL (=-1) if length = 0 */
- ifc->chooser_child = main_ctl_childs_len(ctx, ctl) - 1;
+ ifc->chooser_child = ctl->base.childs_len(&ctl->base) - 1;
} else if (ifc->chooser_child >= 0)
--ifc->chooser_child;
@@ -77,7 +64,7 @@ down(struct context *ctx, int key)
if (parent)
ctl = parent;
- max_ctl_childs = main_ctl_childs_len(ctx, (struct main_ctl *) ctl) -1;
+ max_ctl_childs = ctl->childs_len(ctl) -1;
if (ifc->chooser_child == max_ctl_childs) {
if (ifc->chooser_main_ctl < max_len -1) {
diff --git a/src/ctl.h b/src/ctl.h
index eb169b1..2f54416 100644
--- a/src/ctl.h
+++ b/src/ctl.h
@@ -42,6 +42,7 @@ struct vol_ctl {
pa_context_success_cb_t, gpointer);
void (*childs_foreach)(struct vol_ctl *ctx, GFunc func, gpointer udata);
+ gint (*childs_len)(struct vol_ctl *ctx);
};
struct main_ctl {
diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c
index 70c5ffa..77be8c1 100644
--- a/src/pa-sink-ctl.c
+++ b/src/pa-sink-ctl.c
@@ -81,6 +81,20 @@ main_ctl_childs_foreach(struct vol_ctl *ctl, GFunc func, gpointer user_data)
func(&sctl->base, user_data);
}
+static gint
+main_ctl_childs_len(struct vol_ctl *ctl)
+{
+ struct main_ctl *mctl = (struct main_ctl *) ctl;
+ struct slave_ctl *sctl;
+ int len = 0;
+
+ list_foreach(*mctl->childs_list, sctl)
+ if (sctl->parent_index == mctl->base.index)
+ len++;
+
+ return len;
+}
+
static void
sink_info_cb(pa_context *c, const pa_sink_info *i,
gint is_last, gpointer userdata)
@@ -112,6 +126,7 @@ sink_info_cb(pa_context *c, const pa_sink_info *i,
sink->base.mute_set = pa_context_set_sink_mute_by_index;
sink->base.volume_set = pa_context_set_sink_volume_by_index;
sink->base.childs_foreach = main_ctl_childs_foreach;
+ sink->base.childs_len = main_ctl_childs_len;
sink->move_child = pa_context_move_sink_input_by_index;
sink->childs_list = &ctx->input_list;
@@ -160,6 +175,7 @@ source_info_cb(pa_context *c, const pa_source_info *i,
source->base.mute_set = pa_context_set_source_mute_by_index;
source->base.volume_set = pa_context_set_source_volume_by_index;
source->base.childs_foreach = main_ctl_childs_foreach;
+ source->base.childs_len = main_ctl_childs_len;
source->move_child = pa_context_move_source_output_by_index;
source->childs_list = &ctx->output_list;