volume option

This commit is contained in:
Martin Stransky 2006-01-25 09:53:26 +00:00
parent 7d8f53c3b4
commit 55ae1d8729
2 changed files with 39 additions and 8 deletions

View File

@ -3,7 +3,7 @@
Summary: Advanced Linux Sound Architecture (ALSA) utilities Summary: Advanced Linux Sound Architecture (ALSA) utilities
Name: alsa-utils Name: alsa-utils
Version: 1.0.11 Version: 1.0.11
Release: 1.rc2 Release: 2.rc2
License: GPL License: GPL
Group: Applications/Multimedia Group: Applications/Multimedia
URL: http://www.alsa-project.org/ URL: http://www.alsa-project.org/
@ -69,6 +69,9 @@ install -m 755 alsacard %{buildroot}/bin
/usr/share/locale/* /usr/share/locale/*
%changelog %changelog
* Wed Jan 25 2006 Martin Stransky <stransky@redhat.com> 1.0.11-2.rc2
- added volume option to alsaunmute utility (for s-c-s)
* Thu Jan 12 2006 Martin Stransky <stransky@redhat.com> 1.0.11-1.rc2 * Thu Jan 12 2006 Martin Stransky <stransky@redhat.com> 1.0.11-1.rc2
- new upstream - new upstream

View File

@ -16,6 +16,8 @@
* *
*/ */
#define VERSION "0.2"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -259,6 +261,16 @@ const char * get_card_driver(int index)
return(NULL); 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) void check_data(void)
{ {
char *p_tmp; char *p_tmp;
@ -272,13 +284,15 @@ void check_data(void)
void usage(char *p_name) 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("This software may be freely redistributed under the terms of the GNU\n");
printf("public license.\n\n"); printf("public license.\n\n");
printf("usage: %s card_number [-v]\n\n", p_name); printf("Usage: alsaunmute card_number [-v] [-s volume]\n\n", p_name);
printf(" card_number - number of unmuted card\n"); printf(" card_number - number of unmuted card\n");
printf(" [-v] - verbose mode\n\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); exit(0);
} }
@ -290,6 +304,8 @@ int main(int argc, char **argv)
{ {
const char *p_driver; const char *p_driver;
int index; int index;
int volume = 75;
int param;
if (argc < 2) { if (argc < 2) {
usage(argv[0]); usage(argv[0]);
@ -298,10 +314,19 @@ int main(int argc, char **argv)
index = atoi(argv[1]); index = atoi(argv[1]);
p_driver = get_card_driver(index); 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"))) { if (param+1 < argc && (!strcmp(argv[param],"-s") || !strcmp(argv[param],"-S"))) {
verbose = TRUE; param++;
volume = atoi(argv[param]);
}
} }
if(!p_driver) { if(!p_driver) {
fprintf(stderr,"Wrong card index %d...\n",index); fprintf(stderr,"Wrong card index %d...\n",index);
@ -309,11 +334,14 @@ int main(int argc, char **argv)
} }
if(verbose) { 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(); check_data();
// setting volume
set_volume(volume);
// default settings for all cards // default settings for all cards
unmute_card(index,""); unmute_card(index,"");