summaryrefslogtreecommitdiff
path: root/src/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c42
1 files changed, 20 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