aboutsummaryrefslogtreecommitdiffstats
path: root/pulsemix.c
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-08-13 16:51:11 -0400
committerDave Reisner <dreisner@archlinux.org>2012-08-13 16:51:11 -0400
commit58ffb2e6f35ae2528d55ce92f79b42b8bc17be9c (patch)
tree54629bfd4189d500942a5de72c8209174a579c0f /pulsemix.c
parentc874ebb5389424e2d04be0c64350c9146b8f8d49 (diff)
downloadmirror-ponymix-58ffb2e6f35ae2528d55ce92f79b42b8bc17be9c.tar.gz
mirror-ponymix-58ffb2e6f35ae2528d55ce92f79b42b8bc17be9c.tar.bz2
mirror-ponymix-58ffb2e6f35ae2528d55ce92f79b42b8bc17be9c.zip
add adj-balance verb for incremental balance changes
This is useful if you ever wanted to script balance adjustment, since it would otherwise require 2 invocations (get + set).
Diffstat (limited to 'pulsemix.c')
-rw-r--r--pulsemix.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pulsemix.c b/pulsemix.c
index 3795e1e..9a3484a 100644
--- a/pulsemix.c
+++ b/pulsemix.c
@@ -65,6 +65,7 @@ enum action {
ACTION_SETVOL,
ACTION_GETBAL,
ACTION_SETBAL,
+ ACTION_ADJBAL,
ACTION_INCREASE,
ACTION_DECREASE,
ACTION_MUTE,
@@ -626,6 +627,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fputs(" set-volume VALUE set volume for device\n", out);
fputs(" get-balance get balance for device\n", out);
fputs(" set-balance VALUE set balance for device\n", out);
+ fputs(" adj-balance VALUE increase or decrease balance for device\n", out);
fputs(" increase VALUE increase volume\n", out);
fputs(" decrease VALUE decrease volume\n", out);
fputs(" mute mute device\n", out);
@@ -658,6 +660,8 @@ static enum action string_to_verb(const char *string)
return ACTION_GETBAL;
else if (strcmp(string, "set-balance") == 0)
return ACTION_SETBAL;
+ else if (strcmp(string, "adj-balance") == 0)
+ return ACTION_ADJBAL;
else if (strcmp(string, "increase") == 0)
return ACTION_INCREASE;
else if (strcmp(string, "decrease") == 0)
@@ -692,8 +696,10 @@ static int do_verb(struct pulseaudio_t *pulse, enum action verb, int value)
printf("%d\n", pulse->head->balance);
return 0;
case ACTION_SETBAL:
+ return set_balance(pulse, pulse->head, CLAMP(value, -100, 100));
+ case ACTION_ADJBAL:
return set_balance(pulse, pulse->head,
- CLAMP(value, -100, 100));
+ CLAMP(pulse->head->balance + value, -100, 100));
case ACTION_INCREASE:
return set_volume(pulse, pulse->head,
CLAMP(pulse->head->volume_percent + value, 0, 100));
@@ -781,6 +787,7 @@ int main(int argc, char *argv[])
switch (verb) {
case ACTION_SETVOL:
case ACTION_SETBAL:
+ case ACTION_ADJBAL:
case ACTION_INCREASE:
case ACTION_DECREASE:
if (optind == argc)