summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-12-18 13:33:35 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-12-18 13:35:50 +0100
commit3212f76818abdfd19dc32ffaeef711ea7fc636e0 (patch)
tree74eab7a3e1e342aef0908ad81eb338cf968006f9
parent89b9e7e17893ceff2b8a238258d27c184ed07c64 (diff)
downloadpa-sink-ctl-3212f76818abdfd19dc32ffaeef711ea7fc636e0.tar.gz
pa-sink-ctl-3212f76818abdfd19dc32ffaeef711ea7fc636e0.tar.bz2
pa-sink-ctl-3212f76818abdfd19dc32ffaeef711ea7fc636e0.zip
Add mute cb to vol_ctl_object
-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 {