diff --git a/.cvsignore b/.cvsignore index 35294be..0c02c90 100644 --- a/.cvsignore +++ b/.cvsignore @@ -14,3 +14,4 @@ alsa-utils-1.0.12.tar.bz2 alsa-utils-1.0.14rc1.tar.bz2 alsa-utils-1.0.14rc2.tar.bz2 alsa-utils-1.0.14.tar.bz2 +alsa-utils-1.0.15rc1.tar.bz2 diff --git a/alsa-utils.spec b/alsa-utils.spec index e87cd7e..b0af7a5 100644 --- a/alsa-utils.spec +++ b/alsa-utils.spec @@ -1,7 +1,10 @@ +%define prever rc1 +%define prever_dot .rc1 + Summary: Advanced Linux Sound Architecture (ALSA) utilities Name: alsa-utils -Version: 1.0.14 -Release: 2%{?prever_dot}%{?dist} +Version: 1.0.15 +Release: 0.1%{?prever_dot}%{?dist} License: GPL Group: Applications/Multimedia URL: http://www.alsa-project.org/ @@ -11,6 +14,7 @@ Source3: alsacard.c Source4: alsaunmute.c Source10: alsa.rules Patch: alsa-utils-1.0.14-alsaconf.patch +Patch1: alsa-utils-1.0.14-statedir.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: alsa-lib-devel >= %{version} BuildRequires: ncurses-devel @@ -23,7 +27,8 @@ Architecture (ALSA). %prep %setup -q -n %{name}-%{version}%{?prever} -%patch -p1 +%patch -p1 +%patch1 -p1 -b .statedir %build %configure CFLAGS="$RPM_OPT_FLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" --sbindir=/sbin @@ -50,6 +55,10 @@ install -m 755 salsa %{buildroot}/sbin mkdir -p $RPM_BUILD_ROOT/%{_sbindir} ln -s ../../sbin/alsactl $RPM_BUILD_ROOT/%{_sbindir}/alsactl +# Create a place for volume configuration +mkdir -p $RPM_BUILD_ROOT/var/lib/alsa +touch $RPM_BUILD_ROOT/var/lib/alsa/asound.state + %clean %{__rm} -rf $RPM_BUILD_ROOT @@ -69,8 +78,16 @@ ln -s ../../sbin/alsactl $RPM_BUILD_ROOT/%{_sbindir}/alsactl %dir %{_datadir}/alsa/speaker-test %{_datadir}/alsa/speaker-test/* /usr/share/locale/* +/var/lib/alsa +%ghost /var/lib/alsa/asound.state + %changelog +* Wed Sep 19 2007 Martin Stransky 1.0.15-0.1.rc1 +- new upstream +- moved saved volume settings to /var/lib (#293301) +- patched alsactl for that (#255421) + * Thu Aug 16 2007 Martin Stransky 1.0.14-2 - added an entry to alsaunmute for HP xw4550 (#252171) diff --git a/alsaunmute.c b/alsaunmute.c index 970fca8..c752392 100644 --- a/alsaunmute.c +++ b/alsaunmute.c @@ -16,7 +16,12 @@ * */ -#define VERSION "0.2" +/* + TODO + -> external unmute table +*/ + +#define VERSION "0.3" #include #include @@ -29,6 +34,7 @@ #define FALSE (1!=1) int verbose = 0; +int help = 0; typedef struct _CHANNEL { @@ -280,17 +286,45 @@ void check_data(void) } } -void usage(char *p_name) +int get_card_device(const char *p_device) +{ + int err; + snd_ctl_t *handle; + snd_ctl_card_info_t *info; + int card = 0; + + snd_ctl_card_info_alloca(&info); + + if ((err = snd_ctl_open(&handle, "default", 0)) < 0) { + fprintf(stderr,"Open error: %s\n", snd_strerror(err)); + return(0); + } + if ((err = snd_ctl_card_info(handle, info)) < 0) { + fprintf(stderr,"HW info error: %s\n", snd_strerror(err)); + return(0); + } + + card = snd_ctl_card_info_get_card(info); + + snd_ctl_close(handle); + + return(card); +} + +void usage(void) { 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: alsaunmute card_number [-v] [-s volume]\n\n"); - printf(" card_number - number of unmuted card\n"); + printf("Usage: alsaunmute [options]\n\n"); + printf(" [card_number] - sound card number. If this parameter is not given,\n"); + printf(" the \"default\" sound device is unmuted.\n"); + printf(" [-D device] - unmute specified alsa device (like \"default\")\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"); + printf(" the volume is number from 0 to 100\n"); + printf(" [-h] - this help\n\n"); exit(0); } @@ -301,31 +335,54 @@ void usage(char *p_name) int main(int argc, char **argv) { const char *p_driver; - int index; + char *p_device = "default"; + int index = -1; int volume = 75; int param; - - if (argc < 2) { - usage(argv[0]); - exit(0); - } - - 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")) { + for(param = 1; param < argc; param++) { + if (argv[param][0] >= '0' && argv[param][0] <= '9') { + index = atoi(argv[param]); + continue; + } + if (!strcmp(argv[param],"-v")) { verbose = TRUE; continue; } - - if (param+1 < argc && (!strcmp(argv[param],"-s") || !strcmp(argv[param],"-S"))) { + if (!strcmp(argv[param],"-h") || !strcmp(argv[param],"--help")) { + help = TRUE; + continue; + } + if (param+1 < argc && !strcmp(argv[param],"-s")) { param++; volume = atoi(argv[param]); + continue; + } + if (param+1 < argc && !strcmp(argv[param],"-D")) { + param++; + p_device = argv[param]; + continue; } } - + if(help) { + usage(); + } + + + if(index == -1) { + if(verbose) { + fprintf(stderr,"Unmuting ALSA device '%s'...\n",p_device); + } + index = get_card_device(p_device); + } + else { + if(verbose) { + fprintf(stderr,"Unmuting ALSA card %d...\n",index); + } + } + + p_driver = get_card_driver(index); if(!p_driver) { fprintf(stderr,"Wrong card index %d...\n",index); return(1); diff --git a/salsa.c b/salsa.c index 4c63f46..119fd1b 100644 --- a/salsa.c +++ b/salsa.c @@ -20,7 +20,7 @@ #include -#define ALSA_CONFIG_PATH "/etc/alsa/asound.state" +#define ALSA_CONFIG_PATH "/var/lib/alsa/asound.state" #define ALL_CARDS (-1) diff --git a/sources b/sources index 750adb3..6d01658 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -6d3009c157ac6fc803696d6590a48366 alsa-utils-1.0.14.tar.bz2 +f272e7681acc98d79b56909b935b7878 alsa-utils-1.0.15rc1.tar.bz2