summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <benjaminfranzke@googlemail.com>2010-07-13 18:05:05 +0200
committerben <benjaminfranzke@googlemail.com>2010-07-13 18:05:05 +0200
commite81e3842b6c2b9418de5f826452f3aa8f51d6563 (patch)
treefe6e2f5430f3c3eb3611a1cce95d2baae9bdc40e
parent5423f68eb39adb4cc0165032efb7d53d38ccd10c (diff)
downloadpa-sink-ctl-e81e3842b6c2b9418de5f826452f3aa8f51d6563.tar.gz
pa-sink-ctl-e81e3842b6c2b9418de5f826452f3aa8f51d6563.tar.bz2
pa-sink-ctl-e81e3842b6c2b9418de5f826452f3aa8f51d6563.zip
add mute support for sinks and inputs
-rw-r--r--src/interface.c40
-rw-r--r--src/interface.h2
-rw-r--r--src/pa-sink-ctl.c1
-rw-r--r--src/sink_input.h1
4 files changed, 36 insertions, 8 deletions
diff --git a/src/interface.c b/src/interface.c
index f6c1ab6..b690acd 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -84,7 +84,7 @@ void print_sink_list(void) {
if (i == chooser_sink && chooser_input == -1)
wattroff(menu_win, A_REVERSE);
- print_volume(sink_list[i]->vol, y+i+offset);
+ print_volume(sink_list[i]->vol, sink_list[i]->mute, y+i+offset);
print_input_list(i);
@@ -124,18 +124,21 @@ void print_input_list(int sink_num) {
if (chooser_sink == sink_num && chooser_input == i)
wattroff(menu_win, A_REVERSE);
- print_volume(sink_list[sink_num]->input_list[i]->vol, offset + i);
+ print_volume(sink_list[sink_num]->input_list[i]->vol,
+ sink_list[sink_num]->input_list[i]->mute, offset + i);
}
}
-void print_volume(pa_volume_t volume, int y) {
+void print_volume(pa_volume_t volume, int mute, int y) {
//int x = 20;
int x = 2 /* left */ + 2 /* index num width */ + 1 /* space */ +
1 /* space */ + 13 /* input name*/ + 1 /* space */;
unsigned int vol = (unsigned int) ( (((double)volume) / ((double)VOLUME_MAX)) * VOLUME_BAR_LEN );
+ mvwprintw(menu_win, y, x - 1, "[%c]", mute ? 'M' : ' ');
+ x += 3;
mvwprintw(menu_win, y, x - 1 , "[");
for (int i = 0; i < vol; ++i)
mvwprintw(menu_win, y, x + i, "=");
@@ -150,7 +153,10 @@ void get_input(void)
int c;
// uint32_t sink;
c = wgetch(menu_win);
+
int volume_mult = 0;
+ int index;
+ int mute;
switch (c) {
case 'k':
@@ -182,10 +188,9 @@ void get_input(void)
if (volume_mult == 0)
volume_mult = 1;
- int index;
pa_cvolume volume;
pa_volume_t tmp_vol;
- pa_operation* (*volume_set) (pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata);
+ pa_operation* (*volume_set) (pa_context*,uint32_t,const pa_cvolume*,pa_context_success_cb_t,void*);
if (chooser_input >= 0) {
sink_input_info *input = sink_list[chooser_sink]->input_list[chooser_input];
@@ -216,8 +221,29 @@ void get_input(void)
change_callback,
NULL));
return;
- break;
-
+ case 'm':
+ case 'M': {
+ pa_operation* (*mute_set) (pa_context*,uint32_t,int,pa_context_success_cb_t,void*);
+ if (chooser_input >= 0) {
+ sink_input_info *input = sink_list[chooser_sink]->input_list[chooser_input];
+ index = input->index;
+ mute = input->mute;
+ mute_set = pa_context_set_sink_input_mute;
+ } else if (chooser_input == -1) {
+ sink_info *sink = sink_list[chooser_sink];
+ index = sink->index;
+ mute = sink->mute;
+ mute_set = pa_context_set_sink_mute_by_index;
+ } else
+ break;
+
+ pa_operation_unref(mute_set(context,
+ index,
+ !mute,
+ change_callback,
+ NULL));
+ return;
+ }
case '\n':
case ' ':
if (chooser_input == -1)
diff --git a/src/interface.h b/src/interface.h
index e805dfc..caa5e08 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -10,7 +10,7 @@
void print_sink_list(void);
void print_input_list(int sink_num);
-void print_volume(pa_volume_t, int);
+void print_volume(pa_volume_t, int, int);
void get_input(void);
void interface_init(void);
void interface_clear(void);
diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c
index 1417064..164755b 100644
--- a/src/pa-sink-ctl.c
+++ b/src/pa-sink-ctl.c
@@ -168,6 +168,7 @@ void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info *i, in
input->index = i->index;
input->channels = i->volume.channels;
input->vol = pa_cvolume_avg(&i->volume);
+ input->mute = i->mute;
++(sink_list[sink_num]->input_counter);
}
diff --git a/src/sink_input.h b/src/sink_input.h
index 03ed476..5a65992 100644
--- a/src/sink_input.h
+++ b/src/sink_input.h
@@ -10,6 +10,7 @@ typedef struct _sink_input_info {
uint32_t sink;
char *name;
char *pid; // maybe useless?!!?
+ int mute;
uint8_t channels;
pa_volume_t vol; // TOTO: exchange with the channel-list
} sink_input_info;