From 55ae1d8729c35356b764447dd564fa271a469857 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Jan 25 2006 09:53:26 +0000 Subject: volume option --- diff --git a/alsa-utils.spec b/alsa-utils.spec index 4327b2c..ac28ac0 100644 --- a/alsa-utils.spec +++ b/alsa-utils.spec @@ -3,7 +3,7 @@ Summary: Advanced Linux Sound Architecture (ALSA) utilities Name: alsa-utils Version: 1.0.11 -Release: 1.rc2 +Release: 2.rc2 License: GPL Group: Applications/Multimedia URL: http://www.alsa-project.org/ @@ -69,6 +69,9 @@ install -m 755 alsacard %{buildroot}/bin /usr/share/locale/* %changelog +* Wed Jan 25 2006 Martin Stransky 1.0.11-2.rc2 +- added volume option to alsaunmute utility (for s-c-s) + * Thu Jan 12 2006 Martin Stransky 1.0.11-1.rc2 - new upstream diff --git a/alsaunmute.c b/alsaunmute.c index 9a2294a..7510aff 100644 --- a/alsaunmute.c +++ b/alsaunmute.c @@ -16,6 +16,8 @@ * */ +#define VERSION "0.2" + #include #include #include @@ -259,6 +261,16 @@ const char * get_card_driver(int index) return(NULL); } +void set_volume(int volume) +{ + int i; + + for (i = 0; i < sizeof(channels) / sizeof(channels[0]); i++) { + if (channels[i].play_volume > 1) + channels[i].play_volume = volume; + } +} + void check_data(void) { char *p_tmp; @@ -272,13 +284,15 @@ void check_data(void) void usage(char *p_name) { - printf("Alsa Unmute utility, Copyright 2005 Red Hat, Inc.\n"); + printf("Alsa Unmute utility, Version %s, Copyright 2005 Red Hat, Inc.\n",VERSION); printf("This software may be freely redistributed under the terms of the GNU\n"); printf("public license.\n\n"); - printf("usage: %s card_number [-v]\n\n", p_name); - printf(" card_number - number of unmuted card\n"); - printf(" [-v] - verbose mode\n\n"); + printf("Usage: alsaunmute card_number [-v] [-s volume]\n\n", p_name); + printf(" card_number - number of unmuted card\n"); + printf(" [-v] - verbose mode\n"); + printf(" [-s volume] - set this volume level instead of the default (75%)\n"); + printf(" the volume is number from 0 to 100\n\n"); exit(0); } @@ -290,6 +304,8 @@ int main(int argc, char **argv) { const char *p_driver; int index; + int volume = 75; + int param; if (argc < 2) { usage(argv[0]); @@ -298,10 +314,19 @@ int main(int argc, char **argv) index = atoi(argv[1]); p_driver = get_card_driver(index); + + for(param = 2; param < argc; param++) { + if (!strcmp(argv[param],"-v") || !strcmp(argv[param],"-V")) { + verbose = TRUE; + continue; + } - if (argc == 3 && (!strcmp(argv[2],"-v") || !strcmp(argv[2],"-V"))) { - verbose = TRUE; + if (param+1 < argc && (!strcmp(argv[param],"-s") || !strcmp(argv[param],"-S"))) { + param++; + volume = atoi(argv[param]); + } } + if(!p_driver) { fprintf(stderr,"Wrong card index %d...\n",index); @@ -309,11 +334,14 @@ int main(int argc, char **argv) } if(verbose) { - fprintf(stderr,"Card %d Driver %s...\n",index,p_driver); + fprintf(stderr,"Card %d Driver %s Volume %d%%...\n",index,p_driver,volume); } check_data(); + // setting volume + set_volume(volume); + // default settings for all cards unmute_card(index,"");