summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/command.c42
-rw-r--r--src/pa-sink-ctl.c3
-rw-r--r--src/sink.h3
3 files changed, 26 insertions, 22 deletions
diff --git a/src/command.c b/src/command.c
index 562e358..0a0e636 100644
--- a/src/command.c
+++ b/src/command.c
@@ -151,36 +151,34 @@ volume_up(struct context *ctx, int key)
volume_change(ctx, TRUE);
}
-static void
-do_mute(struct context *ctx, int key)
+static struct vol_ctl_object *
+interface_get_current_ctl(struct context *ctx)
{
struct sink_info *sink;
struct sink_input_info *input;
- guint32 index;
- gint mute;
- pa_operation* (*mute_set) (pa_context*, guint32, int,
- pa_context_success_cb_t, void*);
-
- if (!ctx->context_ready)
- return;
sink = g_list_nth_data(ctx->sink_list, ctx->chooser_sink);
+ if (ctx->chooser_input == SELECTED_SINK)
+ return &sink->base;
- if (ctx->chooser_input >= 0) {
- input = sink_get_nth_input(ctx, sink, ctx->chooser_input);
- index = input->base.index;
- mute = !input->base.mute;
- mute_set = pa_context_set_sink_input_mute;
- } else if (ctx->chooser_input == SELECTED_SINK) {
- index = sink->base.index;
- mute = !sink->base.mute;
- mute_set = pa_context_set_sink_mute_by_index;
- } else {
- g_assert(0);
+ input = sink_get_nth_input(ctx, sink, ctx->chooser_input);
+
+ return &input->base;
+}
+
+static void
+do_mute(struct context *ctx, int key)
+{
+ struct vol_ctl_object *ctl;
+ pa_operation *o;
+
+ if (!ctx->context_ready)
return;
- }
- pa_operation_unref(mute_set(ctx->context, index, mute, NULL, NULL));
+ ctl = interface_get_current_ctl(ctx);
+
+ o = ctl->mute_set(ctx->context, ctl->index, !ctl->mute, NULL, NULL);
+ pa_operation_unref(o);
}
static void
diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c
index 0ff6ee8..784ee8e 100644
--- a/src/pa-sink-ctl.c
+++ b/src/pa-sink-ctl.c
@@ -99,6 +99,8 @@ sink_info_cb(pa_context *c, const pa_sink_info *i,
if (sink == NULL)
return;
sink->base.index = i->index;
+ sink->base.mute_set = pa_context_set_sink_mute_by_index;
+
sink->priority = get_sink_priority(ctx, i);
ctx->sink_list = g_list_insert_sorted(ctx->sink_list, sink,
compare_sink_priority);
@@ -143,6 +145,7 @@ sink_input_info_cb(pa_context *c, const pa_sink_input_info *i,
if (sink_input == NULL)
return;
sink_input->base.index = i->index;
+ sink_input->base.mute_set = pa_context_set_sink_input_mute;
ctx->input_list = g_list_append(ctx->input_list, sink_input);
} else {
sink_input = el->data;
diff --git a/src/sink.h b/src/sink.h
index 8c0c33d..60e47f0 100644
--- a/src/sink.h
+++ b/src/sink.h
@@ -32,6 +32,9 @@ struct vol_ctl_object {
guint8 channels;
gchar *name; /* displayed name */
+
+ pa_operation *(*mute_set)(pa_context *, guint32, int,
+ pa_context_success_cb_t, void *);
};
struct sink_info {