From f6b9527cd98a1859f61bdc31cbe527ec59e85b7e Mon Sep 17 00:00:00 2001 From: perex Date: Nov 21 2008 14:12:27 +0000 Subject: alsa-utils: fix alsactl restore --- diff --git a/alsa-utils.spec b/alsa-utils.spec index ef77645..fad85a1 100644 --- a/alsa-utils.spec +++ b/alsa-utils.spec @@ -4,7 +4,7 @@ Summary: Advanced Linux Sound Architecture (ALSA) utilities Name: alsa-utils Version: 1.0.18 -Release: 5%{?prever_dot}%{?dist} +Release: 6%{?prever_dot}%{?dist} License: GPLv2+ Group: Applications/Multimedia URL: http://www.alsa-project.org/ @@ -13,6 +13,7 @@ Source4: alsaunmute Source6: alsa-info.sh Source10: alsa.rules Source11: alsactl.conf +Patch0: alsactl-fix-restore1.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: alsa-lib-devel >= %{version} BuildRequires: ncurses-devel @@ -26,6 +27,7 @@ Architecture (ALSA). %prep %setup -q -n %{name}-%{version}%{?prever} +%patch0 -p1 -b .restore1 %build %configure CFLAGS="$RPM_OPT_FLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" --sbindir=/sbin --disable-alsaconf @@ -90,6 +92,9 @@ if [ -s /etc/alsa/asound.state -a ! -s /etc/asound.state ] ; then fi %changelog +* Fri Nov 21 2008 Jaroslav Kysela 1.0.18-6 +- fix alsactl restore when driver has more controls than asound.state file + * Tue Nov 04 2008 Jaroslav Kysela 1.0.18-5 - fixed building diff --git a/alsactl-add-ignore-option.patch b/alsactl-add-ignore-option.patch deleted file mode 100644 index ac7a88c..0000000 --- a/alsactl-add-ignore-option.patch +++ /dev/null @@ -1,126 +0,0 @@ -From f63ff476f3538f519ac8ff0acd4acdab29889ad5 Mon Sep 17 00:00:00 2001 -From: Jaroslav Kysela -Date: Thu, 18 Sep 2008 09:40:02 +0200 -Subject: [PATCH] alsactl: Add -g,--ignore option to ignore 'No soundcards found' error - -Signed-off-by: Jaroslav Kysela ---- - alsactl/alsactl.1 | 5 +++++ - alsactl/alsactl.c | 10 ++++++++-- - alsactl/alsactl.h | 1 + - alsactl/state.c | 16 ++++++++++++---- - 4 files changed, 26 insertions(+), 6 deletions(-) - -diff --git a/alsactl/alsactl.1 b/alsactl/alsactl.1 -index d7f30f6..b038a82 100644 ---- a/alsactl/alsactl.1 -+++ b/alsactl/alsactl.1 -@@ -51,6 +51,11 @@ Used with restore command. Try to restore the matching control elements - as much as possible. This option is set as default now. - - .TP -+\fI\-g, \-\-ignore\fP -+Used with store and restore commands. Do not show 'No soundcards found' -+and do not set an error exit code when soundcards are not installed. -+ -+.TP - \fI\-P, \-\-pedantic\fP - Used with restore command. Don't restore mismatching control elements. - This option was the old default behavior. -diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c -index 57957bf..f846316 100644 ---- a/alsactl/alsactl.c -+++ b/alsactl/alsactl.c -@@ -34,6 +34,7 @@ - - int debugflag = 0; - int force_restore = 1; -+int ignore_nocards = 0; - char *command; - char *statefile = NULL; - -@@ -48,7 +49,8 @@ static void help(void) - printf(" -f,--file # configuration file (default " SYS_ASOUNDRC ")\n"); - printf(" -F,--force try to restore the matching controls as much as possible\n"); - printf(" (default mode)\n"); -- printf(" -P,--pedantic don't restore mismatching controls (old default)\n"); -+ printf(" -g,--ignore ignore 'No soundcards found' error\n"); -+ printf(" -P,--pedantic do not restore mismatching controls (old default)\n"); - printf(" -r,--runstate # save restore and init state to this file (only errors)\n"); - printf(" default settings is 'no file set'\n"); - printf(" -R,--remove remove runstate file at first, otherwise append errors\n"); -@@ -75,6 +77,7 @@ int main(int argc, char *argv[]) - {"env", 1, NULL, 'E'}, - {"initfile", 1, NULL, 'i'}, - {"force", 0, NULL, 'F'}, -+ {"ignore", 0, NULL, 'g'}, - {"pedantic", 0, NULL, 'P'}, - {"runstate", 0, NULL, 'r'}, - {"remove", 0, NULL, 'R'}, -@@ -99,7 +102,7 @@ int main(int argc, char *argv[]) - while (1) { - int c; - -- if ((c = getopt_long(argc, argv, "hdvf:FE:i:Pr:R", long_option, NULL)) < 0) -+ if ((c = getopt_long(argc, argv, "hdvf:FgE:i:Pr:R", long_option, NULL)) < 0) - break; - switch (c) { - case 'h': -@@ -111,6 +114,9 @@ int main(int argc, char *argv[]) - case 'F': - force_restore = 1; - break; -+ case 'g': -+ ignore_nocards = 1; -+ break; - case 'E': - if (putenv(optarg)) { - fprintf(stderr, "environment string '%s' is wrong\n", optarg); -diff --git a/alsactl/alsactl.h b/alsactl/alsactl.h -index 408b145..44d27f1 100644 ---- a/alsactl/alsactl.h -+++ b/alsactl/alsactl.h -@@ -1,5 +1,6 @@ - extern int debugflag; - extern int force_restore; -+extern int ignore_nocards; - extern char *command; - extern char *statefile; - -diff --git a/alsactl/state.c b/alsactl/state.c -index 554020b..576721a 100644 ---- a/alsactl/state.c -+++ b/alsactl/state.c -@@ -1507,8 +1507,12 @@ int save_state(const char *file, const char *cardname) - break; - if (card < 0) { - if (first) { -- error("No soundcards found..."); -- return -ENODEV; -+ if (ignore_nocards) { -+ return 0; -+ } else { -+ error("No soundcards found..."); -+ return -ENODEV; -+ } - } - break; - } -@@ -1606,8 +1610,12 @@ int load_state(const char *file, const char *initfile, const char *cardname) - break; - if (card < 0) { - if (first) { -- error("No soundcards found..."); -- return -ENODEV; -+ if (ignore_nocards) { -+ return 0; -+ } else { -+ error("No soundcards found..."); -+ return -ENODEV; -+ } - } - break; - } --- -1.6.0.GIT - diff --git a/alsactl-fix-card-parsing.patch b/alsactl-fix-card-parsing.patch deleted file mode 100644 index 858de14..0000000 --- a/alsactl-fix-card-parsing.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0a8e8d581e5df6f1b13ea009fcdd77c6afcbdc43 Mon Sep 17 00:00:00 2001 -From: Jaroslav Kysela -Date: Thu, 11 Sep 2008 13:39:42 +0200 -Subject: [PATCH] alsactl: Fix oops (when parsing card argument) - -Signed-off-by: Jaroslav Kysela ---- - alsactl/alsactl.c | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) - -diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c -index 6728fbc..57957bf 100644 ---- a/alsactl/alsactl.c -+++ b/alsactl/alsactl.c -@@ -150,7 +150,7 @@ int main(int argc, char *argv[]) - } - - cardname = argc - optind > 1 ? argv[optind + 1] : NULL; -- for (tmp = devfiles; cardname != NULL && tmp != NULL; tmp++) { -+ for (tmp = devfiles; cardname != NULL && *tmp != NULL; tmp++) { - int len = strlen(*tmp); - if (!strncmp(cardname, *tmp, len)) { - long l = strtol(cardname + len, NULL, 0); --- -1.6.0.GIT - diff --git a/alsactl-fix-restore1.patch b/alsactl-fix-restore1.patch new file mode 100644 index 0000000..42d80d7 --- /dev/null +++ b/alsactl-fix-restore1.patch @@ -0,0 +1,47 @@ +From 05f78cc6811110156c701fd9a2a5d15de8b4b1c7 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Fri, 21 Nov 2008 14:44:31 +0100 +Subject: [PATCH] alsactl: Fix restore / init call behaviour when driver contains more controls + +Fix check when driver contains more controls than state file. In this case, +initialization procedure should be run, too. + +Signed-off-by: Jaroslav Kysela +--- + alsactl/state.c | 6 +++--- + 1 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/alsactl/state.c b/alsactl/state.c +index 467fa93..635a999 100644 +--- a/alsactl/state.c ++++ b/alsactl/state.c +@@ -1162,7 +1162,7 @@ static int set_control(snd_ctl_t *handle, snd_config_t *control, + return -EINVAL; + } + numid = atoi(id); +- if (numid > *maxnumid) ++ if ((int)numid > *maxnumid) + *maxnumid = numid; + snd_config_for_each(i, next, control) { + snd_config_t *n = snd_config_iterator_entry(i); +@@ -1398,7 +1398,7 @@ static int set_controls(int card, snd_config_t *top, int doit) + snd_ctl_card_info_t *info; + snd_config_t *control; + snd_config_iterator_t i, next; +- int err, maxnumid; ++ int err, maxnumid = -1; + char name[32], tmpid[16]; + const char *id; + snd_ctl_card_info_alloca(&info); +@@ -1442,7 +1442,7 @@ static int set_controls(int card, snd_config_t *top, int doit) + + /* check if we have additional controls in driver */ + /* in this case we should go through init procedure */ +- if (!doit) { ++ if (!doit && maxnumid >= 0) { + snd_ctl_elem_id_t *id; + snd_ctl_elem_info_t *info; + snd_ctl_elem_id_alloca(&id); +-- +1.6.0.1.217.gb4928 +