summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorben <benjaminfranzke@googlemail.com>2010-07-13 16:28:36 +0200
committerben <benjaminfranzke@googlemail.com>2010-07-13 16:28:36 +0200
commit803b7b24229c42cd9d5eee8c1da166382a321d5c (patch)
tree14a9c3f52e3134ff7a57deef85f504f106e140fb /src
parent54c748fc6c1ceb0e3602482ab29f1e4e523d0b77 (diff)
downloadpa-sink-ctl-803b7b24229c42cd9d5eee8c1da166382a321d5c.tar.gz
pa-sink-ctl-803b7b24229c42cd9d5eee8c1da166382a321d5c.tar.bz2
pa-sink-ctl-803b7b24229c42cd9d5eee8c1da166382a321d5c.zip
sink_inputs volume made changable
Diffstat (limited to 'src')
-rw-r--r--src/interface.c26
-rw-r--r--src/pa-sink-ctl.c1
-rw-r--r--src/sink_input.c12
-rw-r--r--src/sink_input.h1
4 files changed, 32 insertions, 8 deletions
diff --git a/src/interface.c b/src/interface.c
index 5492fbf..f46f6dc 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -149,6 +149,8 @@ void get_input(void)
int c;
// uint32_t sink;
c = wgetch(menu_win);
+ int volume_mult = 0;
+
switch (c) {
case KEY_UP:
if (chooser_input == -1 && chooser_sink > 0) {
@@ -170,9 +172,29 @@ void get_input(void)
break;
case KEY_LEFT:
- break;
-
+ volume_mult = -1;
case KEY_RIGHT:
+ if (volume_mult == 0)
+ volume_mult = 1;
+ if (chooser_input == -1)
+ break;
+ sink_input_info *input = sink_list[chooser_sink]->input_list[chooser_input];
+ pa_cvolume volume;
+ volume.channels = input->channels;
+
+ int input_vol = input->vol + 2 * volume_mult * (VOLUME_MAX / 100);
+#define CHECK_MIN_MAX(val, min, max) ((val) > (max) ? (max) : ((val) < (min) ? (min) : (val)))
+ pa_volume_t new_vol = CHECK_MIN_MAX(input_vol, 0, VOLUME_MAX);
+#undef CHECK_MIN_MAX
+ for (int i = 0; i < volume.channels; ++i)
+ volume.values[i] = new_vol;
+
+ pa_operation_unref(pa_context_set_sink_input_volume(context,
+ input->index,
+ &volume,
+ change_callback,
+ NULL));
+ return;
break;
case 32:
diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c
index 42ebc07..fce5a84 100644
--- a/src/pa-sink-ctl.c
+++ b/src/pa-sink-ctl.c
@@ -164,6 +164,7 @@ void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info *i, in
sink_input_info* input = sink_list[sink_num]->input_list[counter];
input->name = strdup(pa_proplist_gets(i->proplist, "application.name"));
input->index = i->index;
+ input->channels = i->volume.channels;
input->vol = pa_cvolume_avg(&i->volume);
++(sink_list[sink_num]->input_counter);
diff --git a/src/sink_input.c b/src/sink_input.c
index 8b3eab8..a1440df 100644
--- a/src/sink_input.c
+++ b/src/sink_input.c
@@ -16,10 +16,10 @@ sink_input_info* sink_input_init(void) {
}
void sink_input_clear(sink_input_info* sink_input) {
-
+
if (sink_input->name != NULL)
free(sink_input->name);
-
+
if (sink_input->pid != NULL)
free(sink_input->pid);
@@ -33,12 +33,12 @@ sink_input_info** sink_input_list_init(int max) {
for (int i = 0; i < max; ++i)
sink_input_list[i] = NULL;
-
+
return sink_input_list;
}
void sink_input_list_enlarge(sink_input_info*** sink_input_list, int* max, int counter) {
-
+
*max *= 2;
*sink_input_list = (sink_input_info**) realloc(*sink_input_list, (*max) * sizeof(sink_input_info*));
@@ -47,7 +47,7 @@ void sink_input_list_enlarge(sink_input_info*** sink_input_list, int* max, int c
}
void sink_input_list_clear(sink_input_info** sink_input_list, int *max) {
-
+
for (int i = 0; i < (*max); ++i)
if (sink_input_list[i] != NULL)
sink_input_clear(sink_input_list[i]);
@@ -59,7 +59,7 @@ void sink_input_list_clear(sink_input_info** sink_input_list, int *max) {
}
void sink_input_check(sink_input_info** sink_input) {
-
+
if (sink_input == NULL)
printf("Error: NULL\n");
diff --git a/src/sink_input.h b/src/sink_input.h
index 92ff4bb..03ed476 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?!!?
+ uint8_t channels;
pa_volume_t vol; // TOTO: exchange with the channel-list
} sink_input_info;