From dd8c488fdf28f5d237b624530ae01376e930aded Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 06 2019 11:13:10 +0000 Subject: import alsa-utils-1.1.8-2.el7 --- diff --git a/.alsa-utils.metadata b/.alsa-utils.metadata index 9bf146f..77195b2 100644 --- a/.alsa-utils.metadata +++ b/.alsa-utils.metadata @@ -1 +1 @@ -62d07a089cb702ad93deed570d8dd77f6e6a7aae SOURCES/alsa-utils-1.1.6.tar.bz2 +36859b70c6b09458f9f28ae63d4fc3bf754b86b8 SOURCES/alsa-utils-1.1.8.tar.bz2 diff --git a/.gitignore b/.gitignore index d806072..1fa7551 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/alsa-utils-1.1.6.tar.bz2 +SOURCES/alsa-utils-1.1.8.tar.bz2 diff --git a/SOURCES/alsa-utils-1.1.6-post.patch b/SOURCES/alsa-utils-1.1.6-post.patch deleted file mode 100644 index 949b5df..0000000 --- a/SOURCES/alsa-utils-1.1.6-post.patch +++ /dev/null @@ -1,36 +0,0 @@ -From da4d5bd53a1a57d1b39318b83d3280fbcd78e9f6 Mon Sep 17 00:00:00 2001 -From: Takashi Iwai -Date: Tue, 15 May 2018 22:17:01 +0200 -Subject: [PATCH] aplay: Fix invalid file size check for non-regular files - -aplay tries to check the file size via fstat() at parsing the format -headers and avoids parsing when the size is shorter than the given -size. This works fine for regular files, but when a special file like -pipe is passed, it fails, eventually leading to the fallback mode -wrongly. - -A proper fix is to do this sanity check only for a regular file. - -Reported-by: Jay Foster -Signed-off-by: Takashi Iwai ---- - aplay/aplay.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/aplay/aplay.c b/aplay/aplay.c -index bbd7fff..63ec9ef 100644 ---- a/aplay/aplay.c -+++ b/aplay/aplay.c -@@ -2821,7 +2821,8 @@ static int read_header(int *loaded, int header_size) - - /* don't be adventurous, get out if file size is smaller than - * requested header size */ -- if (buf.st_size < header_size) -+ if ((buf.st_mode & S_IFMT) == S_IFREG && -+ buf.st_size < header_size) - return -1; - - if (*loaded < header_size) { --- -2.13.6 - diff --git a/SOURCES/alsa-utils-1.1.8-post.patch b/SOURCES/alsa-utils-1.1.8-post.patch new file mode 100644 index 0000000..fad2415 --- /dev/null +++ b/SOURCES/alsa-utils-1.1.8-post.patch @@ -0,0 +1,1580 @@ +From 116488e5f2f1b897084bd151381ee254e1cc177d Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Fri, 18 Jan 2019 09:24:12 +0100 +Subject: [PATCH 01/20] alsamixer: define _GNU_SOURCE to get exp10 + +Fixes Master, Headphones and Speaker stuck at -8 percentage after +building with Clang 7.0.1 and getting warned about implicit declaration +of exp10, which is behind _GNU_SOURCE as a non-standard feature. Thanks +Takashi Iwai for the CFLAGS suggestion on the mailing list. GCC build is +not affected, so not adding a compiler check to the configure script. + +uClibc-ng has got exp10 since 1.0.12, so the fallback macro is no longer +needed. However, alsa-utils relies on gettext so might need further +patches to actually work on uClibc systems. + +Signed-off-by: makepost +Signed-off-by: Jaroslav Kysela +--- + alsamixer/Makefile.am | 2 +- + alsamixer/volume_mapping.c | 5 ----- + 2 files changed, 1 insertion(+), 6 deletions(-) + +diff --git a/alsamixer/Makefile.am b/alsamixer/Makefile.am +index 259b29e..249e8f8 100644 +--- a/alsamixer/Makefile.am ++++ b/alsamixer/Makefile.am +@@ -1,4 +1,4 @@ +-AM_CFLAGS = @CURSES_CFLAGS@ -DCURSESINC="@CURSESINC@" ++AM_CFLAGS = -D_GNU_SOURCE @CURSES_CFLAGS@ -DCURSESINC="@CURSESINC@" + LDADD = @CURSESLIB@ + + bin_PROGRAMS = alsamixer +diff --git a/alsamixer/volume_mapping.c b/alsamixer/volume_mapping.c +index 94bd0fe..48cfbe2 100644 +--- a/alsamixer/volume_mapping.c ++++ b/alsamixer/volume_mapping.c +@@ -36,11 +36,6 @@ + #include + #include "volume_mapping.h" + +-#ifdef __UCLIBC__ +-/* 10^x = 10^(log e^x) = (e^x)^log10 = e^(x * log 10) */ +-#define exp10(x) (exp((x) * log(10))) +-#endif /* __UCLIBC__ */ +- + #define MAX_LINEAR_DB_SCALE 24 + + static inline bool use_linear_dB_scale(long dBmin, long dBmax) +-- +2.20.1 + + +From 83bce86c26be6c04bcef584fbe00f320b3582c92 Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 14:27:11 +0900 +Subject: [PATCH 02/20] axfer: add a section about unit test + +Two unit tests are available to check internal implementation of axfer. +They perform file I/O for many times and take much time to finish. + +This commit adds a section about it. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 16 ++++++++++++++++ + axfer/axfer.1 | 7 +++++++ + 2 files changed, 23 insertions(+) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index 4ff6082..02e5b4c 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -971,6 +971,22 @@ some scenarios below, no copying occurs between modules. + - xfer(mmap/interleaved), mapper(single), container(any) + - xfer(mmap/non\-interleaved), mapper(multiple), containers(any) + ++.SS Unit test ++ ++For each of the ++.I mapper ++and ++.I container ++module, unit test is available. To run the tests, execute below command: ++ ++.nf ++$ make test ++.fi ++ ++Each test iterates writing to file and reading to the file for many times and it ++takes long time to finish. Please take care of the execution time if running on ++any CI environment. ++ + .SH SEE ALSO + \fB + axfer(1), +diff --git a/axfer/axfer.1 b/axfer/axfer.1 +index bfcd15d..3ae9c8e 100644 +--- a/axfer/axfer.1 ++++ b/axfer/axfer.1 +@@ -75,6 +75,13 @@ Operates for playback transmission. + .I EXIT_FAILURE + (1). + ++.SH UNIT TEST ++ ++This program has unit tests for internal implementation. Please refer to the ++manual of ++.I axfer-transfer ++for details. ++ + .SH COMPATIBILITY TO APLAY + + The +-- +2.20.1 + + +From b6142611c68a380644ce34f885e2d67da084b538 Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 14:39:18 +0900 +Subject: [PATCH 03/20] axfer: fulfill section for backward compatibitity for + chmap option + +At present, axfer losts backward compatibility to aplay in a point of +'chmap' option. + +This commit filfills a section to describe lose of backward compatibility +of chmap option. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index 02e5b4c..1fdfc91 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -872,6 +872,15 @@ according to pushed enter key. However, this feature requires an additional + input handling in main loop and leave bothersome operation to maintain PCM + substream. + ++.TP ++.I \-m, \-\-chmap=CH1,CH2,... ++ALSA PCM core and control core doesn't support this feature, therefore ++remapping should be done in userspace. This brings overhead to align audio ++data frames, especially for mmap operation. Furthermore, as of alsa-lib v1.1.8, ++some plugins don't support this feature expectedly, thus this option is a lack ++of transparent operation. At present, this option is not supported yet not to ++confuse users. ++ + .TP + .I SIGTSTP, SIGCONT + This performs suspend/resume of PCM substream. In aplay(1) implementation, +-- +2.20.1 + + +From 827ed7d1933ee9a0ce052d9eb2c0b1c79770dff2 Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 14:48:33 +0900 +Subject: [PATCH 04/20] axfer: correct description about snoop mode of libffado + +The libffado library can listen to isochronous channels to which unit on +IEEE 1394 bus transfers packets as long as the unit allows software to +read the channel from its register. + +This commit corrects description about snoop mode. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index 1fdfc91..89df3cc 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -560,8 +560,9 @@ audio data frame. + .B \-\-snoop + + This option allows this program to run snoop mode. In this mode, libffado +-listens all isochronous channels. When isochronous communication starts +-by any unit on the same bus, the packets can be handled by this program. ++listens isochronous channels to which device transfers isochronous packet. When ++isochronous communication starts by any unit on the same bus, the packets can ++be handled by this program. + + .TP + .B \-\-sched\-priority +-- +2.20.1 + + +From 1848b38ca94a52e4539e27526b2c028aa487053b Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 14:49:43 +0900 +Subject: [PATCH 05/20] axfer: correct message to notice that help text is + implemented + +Now help message is available to give help option to command line. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index 89df3cc..d631f72 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -100,7 +100,7 @@ is not allowed except for paths listed below: + + .TP + .B \-h, \-\-help +-Print help messages and finish run time. Not yet implemented. ++Print help messages and finish run time. + + .TP + .B \-q, \-\-quiet +-- +2.20.1 + + +From fb038252d49b31e77f56a9c62527bb108cc965ad Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Tue, 15 Jan 2019 08:49:58 +0900 +Subject: [PATCH 06/20] axfer: supplement value of options for the manual of + transfer subcommand + +This commit supplements value of options for the manual of transfer +subcommand. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 40 ++++++++++++++++++++-------------------- + 1 file changed, 20 insertions(+), 20 deletions(-) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index d631f72..a8bf9c7 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -203,7 +203,7 @@ and + is used as a default. + + .TP +-.B \-t, \-\-file\-type=TYPES ++.B \-t, \-\-file\-type=TYPE + Indicate the type of file. This is required for capture transmission. Available + types are listed below: + - wav: Microsoft/IBM RIFF/Wave format +@@ -242,7 +242,7 @@ Select backend of transmission from a list below. The default is libasound. + .SS Backend options for libasound + + .TP +-.B \-D, \-\-device ++.B \-D, \-\-device=NODE + + This option is used to select PCM node in libasound configuration space. + Available nodes are listed by +@@ -271,7 +271,7 @@ This option implicitly uses + option as well to prevent heavy consumption of CPU time. + + .TP +-.B \-F, \-\-period\-size ++.B \-F, \-\-period\-size=# + + This option configures given value to + .I period_size +@@ -288,7 +288,7 @@ intervals of hardware interrupt, thus the same amount of audio data frame as + the value is expected to be available for one I/O operation. + + .TP +-.B \-\-period\-time ++.B \-\-period\-time=# + + This option configures given value to + .I period_time +@@ -297,7 +297,7 @@ hardware parameter of PCM substream. This option is similar to + option, however its unit is micro\-second. + + .TP +-.B \-B, \-\-buffer\-size ++.B \-B, \-\-buffer\-size=# + + This option configures given value to + .I buffer_size +@@ -311,7 +311,7 @@ the size of period. Actually, it is not, depending on implementation of the PCM + plugins, in\-kernel driver and PCM I/O plugins. + + .TP +-.B \-\-buffer\-time ++.B \-\-buffer\-time=# + + This option configures given value to + .I buffer_time +@@ -320,7 +320,7 @@ hardware parameter of PCM substream. This option is similar to + option, however its unit is micro\-second. + + .TP +-.B \-\-waiter\-type ++.B \-\-waiter\-type=TYPE + + This option indicates the type of waiter for event notification. At present, + four types are available; +@@ -355,7 +355,7 @@ Neither this option nor + is available at the same time. + + .TP +-.B \-\-sched\-model ++.B \-\-sched\-model=MODEL + + This option selects scheduling model for process of this program. One of + .I irq +@@ -368,7 +368,7 @@ When nothing specified, + model is used. + + .TP +-.B \-A, \-\-avail\-min ++.B \-A, \-\-avail\-min=# + + This option configures given value to + .I avail\-min +@@ -386,7 +386,7 @@ value of + option is used. + + .TP +-.B \-R, \-\-start\-delay ++.B \-R, \-\-start\-delay=# + + This option configures given value to + .I start_threshold +@@ -420,7 +420,7 @@ value of + option is used. + + .TP +-.B \-T, \-\-stop\-delay ++.B \-T, \-\-stop\-delay=# + + This option configures given value to + .I stop_threshold +@@ -500,7 +500,7 @@ This backend is automatically available when configure script detects + symbol in libffado shared object. + + .TP +-.B \-p, \-\-port ++.B \-p, \-\-port=# + + This option uses given value to decide which 1394 OHCI controller is used to + communicate. When Linux system has two 1394 OHCI controllers, +@@ -513,7 +513,7 @@ is available at the same time. If nothing specified, libffado performs to + communicate to units on IEEE 1394 bus managed by all of 1394 OHCI controller available in Linux system. + + .TP +-.B \-n, \-\-node ++.B \-n, \-\-node=# + + This option uses given value to decide which unit is used to communicate. This + option requires +@@ -522,7 +522,7 @@ option to indicate which 1394 OHCI controller is used to communicate to the + specified unit. + + .TP +-.B \-g, \-\-guid ++.B \-g, \-\-guid=HEXADECIMAL + + This option uses given value to decide a target unit to communicate. The value + should be prefixed with '0x' and consists of hexadecimal literal letters +@@ -533,7 +533,7 @@ communicate to units on IEEE 1394 bus managed by all of 1394 OHCI controller + available in Linux system. + + .TP +-.B \-\-frames\-per\-period ++.B \-\-frames\-per\-period=# + + This option uses given value to decide the number of audio data frame in one + read/write operation. The operation is blocked till the number of available +@@ -541,7 +541,7 @@ audio data frame exceeds the given value. As a default, 512 audio data frames + is used. + + .TP +-.B \-\-periods\-per\-buffer ++.B \-\-periods\-per\-buffer=# + + This option uses given value to decide the size of intermediate buffer between + this program and libffado. As a default, 2 periods per buffer is used. +@@ -565,7 +565,7 @@ isochronous communication starts by any unit on the same bus, the packets can + be handled by this program. + + .TP +-.B \-\-sched\-priority ++.B \-\-sched\-priority=# + + This option executes + .I pthread_setschedparam() +@@ -796,7 +796,7 @@ supports. As of 2018, PCM buffer of non\-interleaved order is hardly used by + sound devices. + + .TP +-.I \-A, \-\-avail\-min ++.I \-A, \-\-avail\-min=# + This option indicates threshold to wake up blocked process in a unit of + audio data frame. Against aplay(1) implementation, this option has no effect + with +@@ -808,7 +808,7 @@ of + option. + + .TP +-.I \-R, \-\-start\-delay ++.I \-R, \-\-start\-delay=# + This option indicates threshold to start prepared PCM substream in a unit of + audio data frame. Against aplay(1) implementation, this option has no effect + with +@@ -820,7 +820,7 @@ of + option. + + .TP +-.I \-T, \-\-stop\-delay ++.I \-T, \-\-stop\-delay=# + This option indicates threshold to stop running PCM substream in a unit of + audio data frame. Against aplay(1) implementation, this option has no effect + with +-- +2.20.1 + + +From 9ed5d7c876a1c11118f2524327c9eac65e7d66dd Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 14:56:12 +0900 +Subject: [PATCH 07/20] axfer: correct invalid usage of escape of itaric text + +A dot sign is valid for a prefix of instruction. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index a8bf9c7..375678e 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -75,7 +75,7 @@ The standard input or output is used if filepath is not specified or given as + \&. + + For playback transmission, container format of given +-\I filepath ++.I filepath + is detected automatically and metadata is used for parameters of sample format, + channels, rate, duration. If nothing detected, content of given file path is + handled as raw data. In this case, the parameters should be indicated as +-- +2.20.1 + + +From 2ba2066008c0fbe98374cc22e8a2eaa4e4e1b2bd Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 18:03:11 +0900 +Subject: [PATCH 08/20] axfer: add an entry of axfer to README + +Axfer has beed added as a rework of aplay with robust design to +support recent features of Linux sound subsystem. + +This commit adds an entry to README. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + README.md | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/README.md b/README.md +index bee2e94..c28e2ea 100644 +--- a/README.md ++++ b/README.md +@@ -11,6 +11,7 @@ alsaconf | the ALSA driver configurator script + alsa-info | a script to gather information about ALSA subsystem + alsactl | an utility for soundcard settings management + aplay/arecord | an utility for the playback / capture of .wav,.voc,.au files ++axfer | an utility to transfer audio data frame (enhancement of aplay) + amixer | a command line mixer + alsamixer | a ncurses mixer + amidi | a utility to send/receive sysex dumps or other MIDI data +-- +2.20.1 + + +From 257be19c47e62cd0553e740599802cec9182b37c Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 17:36:22 +0900 +Subject: [PATCH 09/20] axfer: allow to be compiled with glibc-2.11 or former + +The program, axfer, was developed in userspace with glibc-2.28. This +userspace is mostly compliant to POSIX:2008 and some additional macros +for poll event are officially available. The glibc supports them as a +default since its v2.12 release. It will be failed to be compiled with +old glibc or the other libraries for C standard APIs. + +One of the purpose of axfer is an better alternative of aplay. In a +point of the purpose, it's preferable to be compiled with the old +libraries. + +This commit adds conditional macros to be compiled with libraries for +old compliance level of POSIX. + +Reported-by: Jay Foster +Fixes: fce16d9279b6 ('axfer: add an implementation of waiter for select(2)') +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/waiter-select.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/axfer/waiter-select.c b/axfer/waiter-select.c +index a35ea85..a2776e5 100644 +--- a/axfer/waiter-select.c ++++ b/axfer/waiter-select.c +@@ -15,10 +15,19 @@ + #include + + // Except for POLLERR. +-#define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP) +-#define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT) ++#ifdef POLLRDNORM ++// This program is for userspace compliant to POSIX 2008 (IEEE 1003.1:2008). ++// This is the default compliance level since glibc-2.12 or later. ++# define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP) ++# define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT) ++#else ++// However it's allowed to be for old compliance levels. ++# define POLLIN_SET (POLLIN | POLLHUP) ++# define POLLOUT_SET (POLLOUT) ++#endif + #define POLLEX_SET (POLLPRI) + ++ + struct select_state { + fd_set rfds_rd; + fd_set rfds_wr; +-- +2.20.1 + + +From 6fdaa0c52412205017a9a71872169c75f3d3a542 Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 11:24:53 +0900 +Subject: [PATCH 10/20] axfer: add missing header file of unit test to + distribution + +The file 'axfer/test/generator.h' is missing in distribution and brings +FTBFS for unit tests of axfer. + +This commit fixes to add it. + +Reported-by: Elimar Riesebieter +Fixes: b878df1ff0b0: ('axfer: add unit test for container interface') +Fixes: 39d1ab8a0cb4: ('axfer: add a unit test for mapper interface') +Signed-off-by: Takashi Iwai +--- + axfer/test/Makefile.am | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/axfer/test/Makefile.am b/axfer/test/Makefile.am +index 76a93bf..6521134 100644 +--- a/axfer/test/Makefile.am ++++ b/axfer/test/Makefile.am +@@ -14,6 +14,7 @@ container_test_SOURCES = \ + ../container-voc.c \ + ../container-raw.c \ + generator.c \ ++ generator.h \ + container-test.c + + mapper_test_SOURCES = \ +@@ -28,4 +29,5 @@ mapper_test_SOURCES = \ + ../mapper-single.c \ + ../mapper-multiple.c \ + generator.c \ ++ generator.h \ + mapper-test.c +-- +2.20.1 + + +From 52c9cc9571659377800fea026cf31b24e2f31394 Mon Sep 17 00:00:00 2001 +From: Prashant Malani +Date: Tue, 29 Jan 2019 01:58:26 -0800 +Subject: [PATCH 11/20] seq: arecordmidi: Add num-events option + +Add a command line option to automatically exit after recording a fixed +number of MIDI events. This allows a program using arecordmidi to expect +a MIDI file to be written automatically when the specified number of +events have been received, instead of having to send a SIGINT or SIGTERM +programmatically. + +It also avoids the need to have the arecordmidi process running in the +background, and then constantly stat the output file to check if any +bytes have been written to it (this makes for less predictable and +longer-running tests). + +This functionality finds use in Chrome OS functional testing, since +having to send SIGTERM/SIGINT programmatically and then wait for the +output file adds unpredictability and delay to the tests. + +The addition of this command-line option should (hopefully) not break +any existing usage. + +Signed-off-by: Prashant Malani +Signed-off-by: Takashi Iwai +--- + seq/aplaymidi/arecordmidi.c | 47 ++++++++++++++++++++++++++++++++++--- + 1 file changed, 44 insertions(+), 3 deletions(-) + +diff --git a/seq/aplaymidi/arecordmidi.c b/seq/aplaymidi/arecordmidi.c +index 19dbb7d..c0d0569 100644 +--- a/seq/aplaymidi/arecordmidi.c ++++ b/seq/aplaymidi/arecordmidi.c +@@ -86,6 +86,25 @@ static int ts_num = 4; /* time signature: numerator */ + static int ts_div = 4; /* time signature: denominator */ + static int ts_dd = 2; /* time signature: denominator as a power of two */ + ++/* Parse a decimal number from a command line argument. */ ++static long arg_parse_decimal_num(const char *str, int *err) ++{ ++ long val; ++ char *endptr; ++ ++ errno = 0; ++ val = strtol(str, &endptr, 0); ++ if (errno > 0) { ++ *err = -errno; ++ return 0; ++ } ++ if (*endptr != '\0') { ++ *err = -EINVAL; ++ return 0; ++ } ++ ++ return val; ++} + + /* prints an error message to stderr, and dies */ + static void fatal(const char *msg, ...) +@@ -690,7 +709,8 @@ static void help(const char *argv0) + " -t,--ticks=ticks resolution in ticks per beat or frame\n" + " -s,--split-channels create a track for each channel\n" + " -m,--metronome=client:port play a metronome signal\n" +- " -i,--timesig=nn:dd time signature\n", ++ " -i,--timesig=nn:dd time signature\n" ++ " -n,--num-events=events fixed number of events to record, then exit\n", + argv0); + } + +@@ -706,7 +726,7 @@ static void sighandler(int sig) + + int main(int argc, char *argv[]) + { +- static const char short_options[] = "hVlp:b:f:t:sdm:i:"; ++ static const char short_options[] = "hVlp:b:f:t:sdm:i:n:"; + static const struct option long_options[] = { + {"help", 0, NULL, 'h'}, + {"version", 0, NULL, 'V'}, +@@ -719,6 +739,7 @@ int main(int argc, char *argv[]) + {"dump", 0, NULL, 'd'}, + {"metronome", 1, NULL, 'm'}, + {"timesig", 1, NULL, 'i'}, ++ {"num-events", 1, NULL, 'n'}, + { } + }; + +@@ -727,6 +748,9 @@ int main(int argc, char *argv[]) + struct pollfd *pfds; + int npfds; + int c, err; ++ /* If |num_events| isn't specified, leave it at 0. */ ++ long num_events = 0; ++ long events_received = 0; + + init_seq(); + +@@ -775,6 +799,16 @@ int main(int argc, char *argv[]) + case 'i': + time_signature(optarg); + break; ++ case 'n': ++ err = 0; ++ num_events = arg_parse_decimal_num(optarg, &err); ++ if (err != 0) { ++ fatal("Couldn't parse num_events argument: %s\n", ++ strerror(-err)); ++ } ++ if (num_events <= 0) ++ fatal("num_events must be greater than 0"); ++ break; + default: + help(argv[0]); + return 1; +@@ -864,13 +898,20 @@ int main(int argc, char *argv[]) + err = snd_seq_event_input(seq, &event); + if (err < 0) + break; +- if (event) ++ if (event) { + record_event(event); ++ events_received++; ++ } + } while (err > 0); + if (stop) + break; ++ if (num_events && (events_received == num_events)) ++ break; + } + ++ if (num_events && events_received < num_events) ++ fputs("Warning: Received signal before num_events\n", stdout); ++ + finish_tracks(); + write_file(); + +-- +2.20.1 + + +From a558b71e63a50c045731e032dc35623674848c6c Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Tue, 12 Mar 2019 15:52:49 +0100 +Subject: [PATCH 12/20] alsa-info.sh: cleanups + +- fix awk arguments +- backticks/gravemarks removal +- some cosmetic and indentation changes +- add REQUIRES to check the basic tools + +Signed-off-by: Jaroslav Kysela +--- + alsa-info/alsa-info.sh | 169 +++++++++++++++++++++-------------------- + 1 file changed, 85 insertions(+), 84 deletions(-) + +diff --git a/alsa-info/alsa-info.sh b/alsa-info/alsa-info.sh +index cda4125..cf7ad89 100755 +--- a/alsa-info/alsa-info.sh ++++ b/alsa-info/alsa-info.sh +@@ -22,22 +22,26 @@ CHANGELOG="http://www.alsa-project.org/alsa-info.sh.changelog" + + ################################################################################## + +-#The script was written for 2 main reasons: +-# 1. Remove the need for the devs/helpers to ask several questions before we can easily help the user. +-# 2. Allow newer/inexperienced ALSA users to give us all the info we need to help them. ++# The script was written for 2 main reasons: ++# 1. Remove the need for the devs/helpers to ask several questions before we can easily help the user. ++# 2. Allow newer/inexperienced ALSA users to give us all the info we need to help them. + + #Set the locale (this may or may not be a good idea.. let me know) + export LC_ALL=C + +-#Change the PATH variable, so we can run lspci (needed for some distros) ++# Change the PATH variable, so we can run lspci (needed for some distros) + PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin + BGTITLE="ALSA-Info v $SCRIPT_VERSION" + PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc" +-#Define some simple functions + +-WGET=$(which wget 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null) ++WGET=$(which wget 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null) ++REQUIRES="mktemp grep pgrep whereis ping awk date uname cat dmesg amixer alsactl" + +-pbcheck(){ ++# ++# Define some simple functions ++# ++ ++pbcheck() { + [[ $UPLOAD = "no" ]] && return + + if [[ -z $PASTEBIN ]]; then +@@ -50,9 +54,9 @@ pbcheck(){ + update() { + test -z "$WGET" -o ! -x "$WGET" && return + +- SHFILE=`mktemp -t alsa-info.XXXXXXXXXX` || exit 1 ++ SHFILE=$(mktemp -t alsa-info.XXXXXXXXXX) || exit 1 + wget -O $SHFILE "http://www.alsa-project.org/alsa-info.sh" >/dev/null 2>&1 +- REMOTE_VERSION=`grep SCRIPT_VERSION $SHFILE |head -n1 |sed 's/.*=//'` ++ REMOTE_VERSION=$(grep SCRIPT_VERSION $SHFILE | head -n1 | sed 's/.*=//') + if [ -s "$SHFILE" -a "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then + if [[ -n $DIALOG ]] + then +@@ -131,7 +135,7 @@ withlsmod() { + echo "!!All Loaded Modules" >> $FILE + echo "!!------------------" >> $FILE + echo "" >> $FILE +- lsmod |awk {'print $1'} >> $FILE ++ lsmod | awk '{print $1}' >> $FILE + echo "" >> $FILE + echo "" >> $FILE + } +@@ -140,13 +144,13 @@ withamixer() { + echo "!!Amixer output" >> $FILE + echo "!!-------------" >> $FILE + echo "" >> $FILE +- for i in `grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1} '` ; do +- CARD_NAME=`grep "^ *$i " $TEMPDIR/alsacards.tmp|awk {'print $2'}` +- echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE +- echo "" >>$FILE +- amixer -c$i info>> $FILE 2>&1 +- amixer -c$i>> $FILE 2>&1 +- echo "" >> $FILE ++ for i in $(grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1 }') ; do ++ CARD_NAME=$(grep "^ *$i " $TEMPDIR/alsacards.tmp | awk '{ print $2 }') ++ echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE ++ echo "" >>$FILE ++ amixer -c$i info >> $FILE 2>&1 ++ amixer -c$i >> $FILE 2>&1 ++ echo "" >> $FILE + done + echo "" >> $FILE + } +@@ -155,17 +159,7 @@ withalsactl() { + echo "!!Alsactl output" >> $FILE + echo "!!--------------" >> $FILE + echo "" >> $FILE +- exe="" +- if [ -x /usr/sbin/alsactl ]; then +- exe="/usr/sbin/alsactl" +- fi +- if [ -x /usr/local/sbin/alsactl ]; then +- exe="/usr/local/sbin/alsactl" +- fi +- if [ -z "$exe" ]; then +- exe=`whereis alsactl | cut -d ' ' -f 2` +- fi +- $exe -f $TEMPDIR/alsactl.tmp store ++ alsactl -f $TEMPDIR/alsactl.tmp store + echo "--startcollapse--" >> $FILE + cat $TEMPDIR/alsactl.tmp >> $FILE + echo "--endcollapse--" >> $FILE +@@ -183,8 +177,7 @@ withdevices() { + } + + withconfigs() { +-if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] || [[ -e $HOME/.asoundrc.asoundconf ]] +-then ++if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] || [[ -e $HOME/.asoundrc.asoundconf ]]; then + echo "!!ALSA configuration files" >> $FILE + echo "!!------------------------" >> $FILE + echo "" >> $FILE +@@ -268,7 +261,7 @@ withall() { + } + + get_alsa_library_version() { +- ALSA_LIB_VERSION=`grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null|awk {'print $3'}|sed 's/"//g'` ++ ALSA_LIB_VERSION=$(grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null | awk '{ print $3 }' | sed 's/"//g') + + if [ -z "$ALSA_LIB_VERSION" ]; then + if [ -f /etc/lsb-release ]; then +@@ -276,7 +269,7 @@ get_alsa_library_version() { + case "$DISTRIB_ID" in + Ubuntu) + if which dpkg > /dev/null ; then +- ALSA_LIB_VERSION=`dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -` ++ ALSA_LIB_VERSION=$(dpkg -l libasound2 | tail -1 | awk '{ print $3 }' | cut -f 1 -d -) + fi + + if [ "$ALSA_LIB_VERSION" = "" ]; then +@@ -290,7 +283,7 @@ get_alsa_library_version() { + esac + elif [ -f /etc/debian_version ]; then + if which dpkg > /dev/null ; then +- ALSA_LIB_VERSION=`dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -` ++ ALSA_LIB_VERSION=$(dpkg -l libasound2 | tail -1 | awk '{ print $3 }' | cut -f 1 -d -) + fi + + if [ "$ALSA_LIB_VERSION" = "" ]; then +@@ -301,16 +294,24 @@ get_alsa_library_version() { + fi + } + ++# Basic requires ++for prg in $REQUIRES; do ++ t=$(which $prg 2> /dev/null) ++ if test -z "$t"; then ++ echo "This script requires $prg utility to continue." ++ exit 1 ++ fi ++done + +-#Run checks to make sure the programs we need are installed. +-LSPCI=$(which lspci 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null); +-TPUT=$(which tput 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null); ++# Run checks to make sure the programs we need are installed. ++LSPCI=$(which lspci 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null); ++TPUT=$(which tput 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null); + DIALOG=$(which dialog 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null); + +-#Check to see if sysfs is enabled in the kernel. We'll need this later on +-SYSFS=$(mount |grep sysfs|awk {'print $3'}); ++# Check to see if sysfs is enabled in the kernel. We'll need this later on ++SYSFS=$(mount | grep sysfs | awk '{ print $3 }'); + +-#Check modprobe config files for sound related options ++# Check modprobe config files for sound related options + SNDOPTIONS=$(modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p') + + KEEP_OUTPUT= +@@ -386,11 +387,11 @@ else + fi # dialog + fi # WELCOME + +-#Set the output file +-TEMPDIR=`mktemp -t -d alsa-info.XXXXXXXXXX` || exit 1 ++# Set the output file ++TEMPDIR=$(mktemp -t -d alsa-info.XXXXXXXXXX) || exit 1 + FILE="$TEMPDIR/alsa-info.txt" + if [ -z "$NFILE" ]; then +- NFILE=`mktemp -t alsa-info.txt.XXXXXXXXXX` || exit 1 ++ NFILE=$(mktemp -t alsa-info.txt.XXXXXXXXXX) || exit 1 + fi + + trap cleanup 0 +@@ -404,17 +405,17 @@ if [ -z "$LSPCI" ]; then + fi + fi + +-#Fetch the info and store in temp files/variables +-DISTRO=`grep -ihs "buntu\|SUSE\|Fedora\|PCLinuxOS\|MEPIS\|Mandriva\|Debian\|Damn\|Sabayon\|Slackware\|KNOPPIX\|Gentoo\|Zenwalk\|Mint\|Kubuntu\|FreeBSD\|Puppy\|Freespire\|Vector\|Dreamlinux\|CentOS\|Arch\|Xandros\|Elive\|SLAX\|Red\|BSD\|KANOTIX\|Nexenta\|Foresight\|GeeXboX\|Frugalware\|64\|SystemRescue\|Novell\|Solaris\|BackTrack\|KateOS\|Pardus" /etc/{issue,*release,*version}` +-KERNEL_VERSION=`uname -r` +-KERNEL_PROCESSOR=`uname -p` +-KERNEL_MACHINE=`uname -m` +-KERNEL_OS=`uname -o` +-[[ `uname -v | grep SMP` ]] && KERNEL_SMP="Yes" || KERNEL_SMP="No" +-ALSA_DRIVER_VERSION=`cat /proc/asound/version |head -n1|awk {'print $7'} |sed 's/\.$//'` ++# Fetch the info and store in temp files/variables ++TSTAMP=$(LANG=C TZ=UTC date) ++DISTRO=$(grep -ihs "buntu\|SUSE\|Fedora\|PCLinuxOS\|MEPIS\|Mandriva\|Debian\|Damn\|Sabayon\|Slackware\|KNOPPIX\|Gentoo\|Zenwalk\|Mint\|Kubuntu\|FreeBSD\|Puppy\|Freespire\|Vector\|Dreamlinux\|CentOS\|Arch\|Xandros\|Elive\|SLAX\|Red\|BSD\|KANOTIX\|Nexenta\|Foresight\|GeeXboX\|Frugalware\|64\|SystemRescue\|Novell\|Solaris\|BackTrack\|KateOS\|Pardus" /etc/{issue,*release,*version}) ++KERNEL_VERSION=$(uname -r) ++KERNEL_PROCESSOR=$(uname -p) ++KERNEL_MACHINE=$(uname -m) ++KERNEL_OS=$(uname -o) ++[[ $(uname -v | grep SMP) ]] && KERNEL_SMP="Yes" || KERNEL_SMP="No" ++ALSA_DRIVER_VERSION=$(cat /proc/asound/version | head -n1 | awk '{ print $7 }' | sed 's/\.$//') + get_alsa_library_version +-ALSA_UTILS_VERSION=`amixer -v |awk {'print $3'}` +-LAST_CARD=$((`grep "]: " /proc/asound/cards | wc -l` - 1 )) ++ALSA_UTILS_VERSION=$(amixer -v | awk '{ print $3 }') + + ESDINST=$(which esd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null) + PAINST=$(which pulseaudio 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null) +@@ -451,10 +452,10 @@ if [ -d /sys/bus/acpi/devices ]; then + done + fi + +-cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>$TEMPDIR/alsamodules.tmp +-cat /proc/asound/cards >$TEMPDIR/alsacards.tmp ++cat /proc/asound/modules 2>/dev/null | awk '{ print $2 }' > $TEMPDIR/alsamodules.tmp ++cat /proc/asound/cards > $TEMPDIR/alsacards.tmp + if [[ ! -z "$LSPCI" ]]; then +-lspci |grep -i "multi\|audio">$TEMPDIR/lspci.tmp ++ lspci | grep -i "multi\|audio">$TEMPDIR/lspci.tmp + fi + + #Check for HDA-Intel cards codec#* +@@ -477,7 +478,7 @@ echo "!!################################" >> $FILE + echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE + echo "!!################################" >> $FILE + echo "" >> $FILE +-echo "!!Script ran on: `LANG=C TZ=UTC date`" >> $FILE ++echo "!!Script ran on: $TSTAMP" >> $FILE + echo "" >> $FILE + echo "" >> $FILE + echo "!!Linux Distribution" >> $FILE +@@ -531,35 +532,35 @@ echo "!!Sound Servers on this system" >> $FILE + echo "!!----------------------------" >> $FILE + echo "" >> $FILE + if [[ -n $PAINST ]];then +-[[ `pgrep '^(.*/)?pulseaudio$'` ]] && PARUNNING="Yes" || PARUNNING="No" ++[[ $(pgrep '^(.*/)?pulseaudio$') ]] && PARUNNING="Yes" || PARUNNING="No" + echo "Pulseaudio:" >> $FILE + echo " Installed - Yes ($PAINST)" >> $FILE + echo " Running - $PARUNNING" >> $FILE + echo "" >> $FILE + fi + if [[ -n $ESDINST ]];then +-[[ `pgrep '^(.*/)?esd$'` ]] && ESDRUNNING="Yes" || ESDRUNNING="No" ++[[ $(pgrep '^(.*/)?esd$') ]] && ESDRUNNING="Yes" || ESDRUNNING="No" + echo "ESound Daemon:" >> $FILE + echo " Installed - Yes ($ESDINST)" >> $FILE + echo " Running - $ESDRUNNING" >> $FILE + echo "" >> $FILE + fi + if [[ -n $ARTSINST ]];then +-[[ `pgrep '^(.*/)?artsd$'` ]] && ARTSRUNNING="Yes" || ARTSRUNNING="No" ++[[ $(pgrep '^(.*/)?artsd$') ]] && ARTSRUNNING="Yes" || ARTSRUNNING="No" + echo "aRts:" >> $FILE + echo " Installed - Yes ($ARTSINST)" >> $FILE + echo " Running - $ARTSRUNNING" >> $FILE + echo "" >> $FILE + fi + if [[ -n $JACKINST ]];then +-[[ `pgrep '^(.*/)?jackd$'` ]] && JACKRUNNING="Yes" || JACKRUNNING="No" ++[[ $(pgrep '^(.*/)?jackd$') ]] && JACKRUNNING="Yes" || JACKRUNNING="No" + echo "Jack:" >> $FILE + echo " Installed - Yes ($JACKINST)" >> $FILE + echo " Running - $JACKRUNNING" >> $FILE + echo "" >> $FILE + fi + if [[ -n $ROARINST ]];then +-[[ `pgrep '^(.*/)?roard$'` ]] && ROARRUNNING="Yes" || ROARRUNNING="No" ++[[ $(pgrep '^(.*/)?roard$') ]] && ROARRUNNING="Yes" || ROARRUNNING="No" + echo "RoarAudio:" >> $FILE + echo " Installed - Yes ($ROARINST)" >> $FILE + echo " Running - $ROARRUNNING" >> $FILE +@@ -602,20 +603,20 @@ echo "" >> $FILE + echo "" >> $FILE + fi + +-if [ -d "$SYSFS" ] +-then +-echo "!!Loaded sound module options" >> $FILE +-echo "!!---------------------------" >> $FILE +-echo "" >> $FILE +-for mod in `cat /proc/asound/modules|awk {'print $2'}`;do +-echo "!!Module: $mod" >> $FILE +-for params in `echo $SYSFS/module/$mod/parameters/*`; do +- echo -ne "\t"; +- echo "$params : `cat $params`" | sed 's:.*/::'; +-done >> $FILE +-echo "" >> $FILE +-done +-echo "" >> $FILE ++if [ -d "$SYSFS" ]; then ++ echo "!!Loaded sound module options" >> $FILE ++ echo "!!---------------------------" >> $FILE ++ echo "" >> $FILE ++ for mod in $(cat /proc/asound/modules | awk '{ print $2 }'); do ++ echo "!!Module: $mod" >> $FILE ++ for params in $(echo $SYSFS/module/$mod/parameters/*); do ++ echo -ne "\t" ++ value=$(cat $params) ++ echo "$params : $value" | sed 's:.*/::' ++ done >> $FILE ++ echo "" >> $FILE ++ done ++ echo "" >> $FILE + fi + + if [ -s "$TEMPDIR/alsa-hda-intel.tmp" ]; then +@@ -856,8 +857,8 @@ if [ "$UPLOAD" = "no" ]; then + + fi # UPLOAD + +-#Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it doesnt. +-if [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ `wget --help |grep post-file` ]] ++# Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it does not. ++if [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ $(wget --help | grep post-file) ]] + then + + if [[ -n $DIALOG ]] +@@ -882,7 +883,7 @@ fi + dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100 + DIALOG_EXIT_CODE=$? + if [ $DIALOG_EXIT_CODE = 0 ]; then +- grep -v "alsa-info.txt" $FILE >$TEMPDIR/uploaded.txt ++ grep -v "alsa-info.txt" $FILE > $TEMPDIR/uploaded.txt + dialog --backtitle "$BGTITLE" --textbox $TEMPDIR/uploaded.txt 0 0 + fi + +@@ -911,20 +912,20 @@ done + echo -e "\b Done!" + echo "" + +-fi #dialog ++fi # dialog + +-#See if tput is available, and use it if it is. ++# See if tput is available, and use it if it is. + if [ -n "$TPUT" ]; then + if [[ -z $PASTEBIN ]]; then +- FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2 ; tput sgr0` ++ FINAL_URL=$(tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2 ; tput sgr0) + else +- FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0` ++ FINAL_URL=$(tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'; tput sgr0) + fi + else + if [[ -z $PASTEBIN ]]; then +- FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2` ++ FINAL_URL=$(grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2) + else +- FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'` ++ FINAL_URL=$(grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p') + fi + fi + +-- +2.20.1 + + +From cf2cc375020a2cd5038332f923d428c8e642b70a Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Tue, 12 Mar 2019 16:05:23 +0100 +Subject: [PATCH 13/20] alsactl: simple coverity fix + +Signed-off-by: Jaroslav Kysela +--- + alsactl/init_parse.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/alsactl/init_parse.c b/alsactl/init_parse.c +index f39d80e..562e674 100644 +--- a/alsactl/init_parse.c ++++ b/alsactl/init_parse.c +@@ -1675,8 +1675,10 @@ static int parse(struct space *space, const char *filename) + linenum = 0; + linesize = 128; + line = malloc(linesize); +- if (line == NULL) ++ if (line == NULL) { ++ file_unmap(buf, bufsize); + return -ENOMEM; ++ } + space->filename = filename; + while (!err && pos < bufsize && !space->quit) { + count = line_width(buf, bufsize, pos); +-- +2.20.1 + + +From 6dc4b1eab578bd4b6608a0118f170cf2f84e0680 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Tue, 12 Mar 2019 16:06:03 +0100 +Subject: [PATCH 14/20] arecordmidi: simple coverity fix + +Signed-off-by: Jaroslav Kysela +--- + seq/aplaymidi/arecordmidi.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/seq/aplaymidi/arecordmidi.c b/seq/aplaymidi/arecordmidi.c +index c0d0569..f3db65e 100644 +--- a/seq/aplaymidi/arecordmidi.c ++++ b/seq/aplaymidi/arecordmidi.c +@@ -631,7 +631,7 @@ static void write_file(void) + fwrite("MThd\0\0\0\6", 1, 8, file); + /* type 0 or 1 */ + fputc(0, file); +- fputc(used_tracks > 1, file); ++ fputc(used_tracks > 1 ? 1 : 0, file); + /* number of tracks */ + fputc((used_tracks >> 8) & 0xff, file); + fputc(used_tracks & 0xff, file); +-- +2.20.1 + + +From bc42704c96c02b138849be4af6c90b4755659b56 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Tue, 12 Mar 2019 16:14:50 +0100 +Subject: [PATCH 15/20] aplay: fix the multiple open file descriptors for the + raw capture + +Signed-off-by: Jaroslav Kysela +--- + aplay/aplay.c | 18 +++++++----------- + 1 file changed, 7 insertions(+), 11 deletions(-) + +diff --git a/aplay/aplay.c b/aplay/aplay.c +index efc1eb4..8bdf45b 100644 +--- a/aplay/aplay.c ++++ b/aplay/aplay.c +@@ -2690,8 +2690,6 @@ static void end_voc(int fd) + bt.datalen_h = (u_char) ((cnt & 0xFF0000) >> 16); + if (lseek64(fd, length_seek, SEEK_SET) == length_seek) + xwrite(fd, &bt, sizeof(VocBlockType)); +- if (fd != 1) +- close(fd); + } + + static void end_wave(int fd) +@@ -2712,8 +2710,6 @@ static void end_wave(int fd) + xwrite(fd, &rifflen, 4); + if (lseek64(fd, length_seek, SEEK_SET) == length_seek) + xwrite(fd, &cd, sizeof(WaveChunkHeader)); +- if (fd != 1) +- close(fd); + } + + static void end_au(int fd) +@@ -2725,8 +2721,6 @@ static void end_au(int fd) + ah.data_size = fdcount > 0xffffffff ? 0xffffffff : BE_INT(fdcount); + if (lseek64(fd, length_seek, SEEK_SET) == length_seek) + xwrite(fd, &ah.data_size, sizeof(ah.data_size)); +- if (fd != 1) +- close(fd); + } + + static void header(int rtype, char *name) +@@ -2938,7 +2932,7 @@ static void playback(char *name) + break; + } + +- if (fd != 0) ++ if (fd != fileno(stdin)) + close(fd); + } + +@@ -3151,7 +3145,7 @@ static void capture(char *orig_name) + if (!name || !strcmp(name, "-")) { + fd = fileno(stdout); + name = "stdout"; +- tostdout=1; ++ tostdout = 1; + if (count > fmt_rec_table[file_type].max_filesize) + count = fmt_rec_table[file_type].max_filesize; + } +@@ -3159,7 +3153,7 @@ static void capture(char *orig_name) + + do { + /* open a file to write */ +- if(!tostdout) { ++ if (!tostdout) { + /* upon the second file we start the numbering scheme */ + if (filecount || use_strftime) { + filecount = new_capture_file(orig_name, namebuf, +@@ -3218,8 +3212,10 @@ static void capture(char *orig_name) + } + + /* finish sample container */ +- if (fmt_rec_table[file_type].end && !tostdout) { +- fmt_rec_table[file_type].end(fd); ++ if (!tostdout) { ++ if (fmt_rec_table[file_type].end) ++ fmt_rec_table[file_type].end(fd); ++ close(fd); + fd = -1; + } + +-- +2.20.1 + + +From 819e04c7a1958a1c4378d914b38bddaf248d9fc0 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Wed, 13 Mar 2019 14:19:12 +0100 +Subject: [PATCH 16/20] axfer: coverity fixes + +- container-voc.c - out of array access +- container-voc.c - handle correctly eof +- frame_cache.c - correct memory allocation +- container.c - byte_count might be used uninitialized +- xfer-libasound-irq-mmap.c - fix avail signess +- xfer-options.c - fix potential 32-bit wrap for duration + +Signed-off-by: Jaroslav Kysela +--- + axfer/container-voc.c | 32 +++++++++++++----------- + axfer/container.c | 2 +- + axfer/frame-cache.c | 44 +++++++++++++++++---------------- + axfer/xfer-libasound-irq-mmap.c | 2 +- + axfer/xfer-options.c | 2 +- + 5 files changed, 43 insertions(+), 39 deletions(-) + +diff --git a/axfer/container-voc.c b/axfer/container-voc.c +index 92e9c83..6fa59c3 100644 +--- a/axfer/container-voc.c ++++ b/axfer/container-voc.c +@@ -234,7 +234,7 @@ static int build_time_constant(unsigned int frames_per_second, + frames_per_second) + break; + } +- if (i < ARRAY_SIZE(ex_v110_time_consts) || ++ if (i < ARRAY_SIZE(ex_v110_time_consts) && + frames_per_second <= 192000) { + *code = ex_v110_time_consts[i].code; + } else { +@@ -520,29 +520,31 @@ static int detect_format_block(struct container_context *cntr) + { + struct parser_state *state = cntr->private_data; + struct block_header header; +- void *buf = NULL; ++ void *buf; + int err; + + again: ++ buf = NULL; + err = cache_data_block(cntr, &header, &buf); + if (err < 0) + return err; ++ if (buf) { ++ if (header.type == BLOCK_TYPE_EXTENDED_V110_FORMAT) { ++ err = parse_extended_v110_format(state, buf); ++ } else if (header.type == BLOCK_TYPE_V120_DATA) { ++ err = parse_v120_format_block(state, buf); ++ } else if (header.type == BLOCK_TYPE_V110_DATA) { ++ err = parse_v110_data(state, buf); ++ } else { ++ free(buf); ++ goto again; ++ } + +- if (header.type == BLOCK_TYPE_EXTENDED_V110_FORMAT) { +- err = parse_extended_v110_format(state, buf); +- } else if (header.type == BLOCK_TYPE_V120_DATA) { +- err = parse_v120_format_block(state, buf); +- } else if (header.type == BLOCK_TYPE_V110_DATA) { +- err = parse_v110_data(state, buf); +- } else { + free(buf); +- goto again; +- } +- +- free(buf); + +- if (err < 0) +- return err; ++ if (err < 0) ++ return err; ++ } + + // Expect to detect block_v110_data. + if (header.type == BLOCK_TYPE_EXTENDED_V110_FORMAT) +diff --git a/axfer/container.c b/axfer/container.c +index 6b0e42e..7da97c6 100644 +--- a/axfer/container.c ++++ b/axfer/container.c +@@ -296,7 +296,7 @@ int container_context_pre_process(struct container_context *cntr, + unsigned int *frames_per_second, + uint64_t *frame_count) + { +- uint64_t byte_count; ++ uint64_t byte_count = 0; + unsigned int bytes_per_frame; + int err; + +diff --git a/axfer/frame-cache.c b/axfer/frame-cache.c +index 882568f..417c1e6 100644 +--- a/axfer/frame-cache.c ++++ b/axfer/frame-cache.c +@@ -50,13 +50,18 @@ int frame_cache_init(struct frame_cache *cache, snd_pcm_access_t access, + unsigned int samples_per_frame, + unsigned int frames_per_cache) + { ++ cache->access = access; ++ cache->remained_count = 0; ++ cache->bytes_per_sample = bytes_per_sample; ++ cache->samples_per_frame = samples_per_frame; ++ cache->frames_per_cache = frames_per_cache; ++ + if (access == SND_PCM_ACCESS_RW_INTERLEAVED) + cache->align_frames = align_frames_in_i; + else if (access == SND_PCM_ACCESS_RW_NONINTERLEAVED) + cache->align_frames = align_frames_in_n; + else + return -EINVAL; +- cache->access = access; + + if (access == SND_PCM_ACCESS_RW_INTERLEAVED) { + char *buf; +@@ -64,45 +69,42 @@ int frame_cache_init(struct frame_cache *cache, snd_pcm_access_t access, + buf = calloc(frames_per_cache, + bytes_per_sample * samples_per_frame); + if (buf == NULL) +- return -ENOMEM; ++ goto nomem; + cache->buf = buf; + cache->buf_ptr = buf; + } else { +- char **bufs; +- char **buf_ptrs; ++ char **bufs = calloc(samples_per_frame, sizeof(*bufs)); ++ char **buf_ptrs = calloc(samples_per_frame, sizeof(*buf_ptrs)); + int i; + +- bufs = calloc(samples_per_frame, sizeof(*bufs)); +- if (bufs == NULL) +- return -ENOMEM; +- buf_ptrs = calloc(samples_per_frame, sizeof(*buf_ptrs)); +- if (buf_ptrs == NULL) +- return -ENOMEM; ++ cache->buf = bufs; ++ cache->buf_ptr = buf_ptrs; ++ if (bufs == NULL || buf_ptrs == NULL) ++ goto nomem; + for (i = 0; i < samples_per_frame; ++i) { + bufs[i] = calloc(frames_per_cache, bytes_per_sample); + if (bufs[i] == NULL) +- return -ENOMEM; ++ goto nomem; + buf_ptrs[i] = bufs[i]; + } +- cache->buf = bufs; +- cache->buf_ptr = buf_ptrs; + } + +- cache->remained_count = 0; +- cache->bytes_per_sample = bytes_per_sample; +- cache->samples_per_frame = samples_per_frame; +- cache->frames_per_cache = frames_per_cache; + + return 0; ++ ++nomem: ++ frame_cache_destroy(cache); ++ return -ENOMEM; + } + + void frame_cache_destroy(struct frame_cache *cache) + { + if (cache->access == SND_PCM_ACCESS_RW_NONINTERLEAVED) { +- int i; +- for (i = 0; i < cache->samples_per_frame; ++i) { +- char **bufs = cache->buf; +- free(bufs[i]); ++ char **bufs = cache->buf; ++ if (bufs) { ++ int i; ++ for (i = 0; i < cache->samples_per_frame; ++i) ++ free(bufs[i]); + } + free(cache->buf_ptr); + } +diff --git a/axfer/xfer-libasound-irq-mmap.c b/axfer/xfer-libasound-irq-mmap.c +index 0c96ee5..0fbbcc6 100644 +--- a/axfer/xfer-libasound-irq-mmap.c ++++ b/axfer/xfer-libasound-irq-mmap.c +@@ -75,7 +75,7 @@ static int irq_mmap_process_frames(struct libasound_state *state, + struct map_layout *layout = state->private_data; + const snd_pcm_channel_area_t *areas; + snd_pcm_uframes_t frame_offset; +- snd_pcm_uframes_t avail; ++ snd_pcm_sframes_t avail; + unsigned int avail_count; + void *frame_buf; + snd_pcm_sframes_t consumed_count; +diff --git a/axfer/xfer-options.c b/axfer/xfer-options.c +index 8394d8a..2713027 100644 +--- a/axfer/xfer-options.c ++++ b/axfer/xfer-options.c +@@ -395,7 +395,7 @@ void xfer_options_calculate_duration(struct xfer_context *xfer, + uint64_t frame_count; + + if (xfer->duration_seconds > 0) { +- frame_count = xfer->duration_seconds * xfer->frames_per_second; ++ frame_count = (uint64_t)xfer->duration_seconds * (uint64_t)xfer->frames_per_second; + if (frame_count < *total_frame_count) + *total_frame_count = frame_count; + } +-- +2.20.1 + + +From 9b6c5e2d5c3119dbb79fc70ac8355424a8893ed0 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Wed, 13 Mar 2019 14:22:22 +0100 +Subject: [PATCH 17/20] aplay: check the return value for + snd_pcm_sw_params_current() (coverity) + +Signed-off-by: Jaroslav Kysela +--- + aplay/aplay.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/aplay/aplay.c b/aplay/aplay.c +index 8bdf45b..5b3a766 100644 +--- a/aplay/aplay.c ++++ b/aplay/aplay.c +@@ -1411,7 +1411,11 @@ static void set_params(void) + chunk_size, buffer_size); + prg_exit(EXIT_FAILURE); + } +- snd_pcm_sw_params_current(handle, swparams); ++ err = snd_pcm_sw_params_current(handle, swparams); ++ if (err < 0) { ++ error(_("Unable to get current sw params.")); ++ prg_exit(EXIT_FAILURE); ++ } + if (avail_min < 0) + n = chunk_size; + else +-- +2.20.1 + + +From 8c026b9562dbdfc222bcd637dfb85b85f4e95412 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Wed, 13 Mar 2019 14:31:57 +0100 +Subject: [PATCH 18/20] alsactl: monitor - remove dead code in run_dispatcher() + (coverity) + +Signed-off-by: Jaroslav Kysela +--- + alsactl/monitor.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/alsactl/monitor.c b/alsactl/monitor.c +index 282fb1c..6b090e4 100644 +--- a/alsactl/monitor.c ++++ b/alsactl/monitor.c +@@ -369,8 +369,6 @@ static int run_dispatcher(int epfd, int sigfd, int infd, struct list_head *srcs, + remove_source_entry(entry); + } + } +- if (err < 0) +- break; + } + end: + free(epev); +-- +2.20.1 + + +From 8dcc3a1391ade9f714143038cf6f816fad1cc2df Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Wed, 13 Mar 2019 14:47:23 +0100 +Subject: [PATCH 19/20] alsaloop: remove unused assignment warning (coverity) + +Signed-off-by: Jaroslav Kysela +--- + alsaloop/pcmjob.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/alsaloop/pcmjob.c b/alsaloop/pcmjob.c +index 4c9517b..29d1aba 100644 +--- a/alsaloop/pcmjob.c ++++ b/alsaloop/pcmjob.c +@@ -293,7 +293,7 @@ static int increase_playback_avail_min(struct loopback_handle *lhandle) + /* avoid 100% CPU usage for broken plugins */ + ts.tv_sec = 0; + ts.tv_nsec = 10000; +- err = nanosleep(&ts, NULL); ++ nanosleep(&ts, NULL); + return 0; + } + snd_pcm_sw_params_alloca(&swparams); +-- +2.20.1 + + +From 30f9a14a7964c650fb6b2b559d6fc879844b21b4 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Wed, 13 Mar 2019 14:51:12 +0100 +Subject: [PATCH 20/20] axfer: return back unsigned avail variable, do proper + retype in xfer-libasound-irq-mmap.c + +Signed-off-by: Jaroslav Kysela +--- + axfer/xfer-libasound-irq-mmap.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/axfer/xfer-libasound-irq-mmap.c b/axfer/xfer-libasound-irq-mmap.c +index 0fbbcc6..71ee79f 100644 +--- a/axfer/xfer-libasound-irq-mmap.c ++++ b/axfer/xfer-libasound-irq-mmap.c +@@ -75,7 +75,7 @@ static int irq_mmap_process_frames(struct libasound_state *state, + struct map_layout *layout = state->private_data; + const snd_pcm_channel_area_t *areas; + snd_pcm_uframes_t frame_offset; +- snd_pcm_sframes_t avail; ++ snd_pcm_uframes_t avail; + unsigned int avail_count; + void *frame_buf; + snd_pcm_sframes_t consumed_count; +@@ -110,7 +110,7 @@ static int irq_mmap_process_frames(struct libasound_state *state, + // MEMO: either snd_pcm_avail_update() and snd_pcm_mmap_begin() can + // return the same number of available frames. + avail = snd_pcm_avail_update(state->handle); +- if (avail < 0) ++ if ((snd_pcm_sframes_t)avail < 0) + return (int)avail; + if (*frame_count < avail) + avail = *frame_count; +-- +2.20.1 + diff --git a/SPECS/alsa-utils.spec b/SPECS/alsa-utils.spec index 284e543..bd4d08f 100644 --- a/SPECS/alsa-utils.spec +++ b/SPECS/alsa-utils.spec @@ -1,10 +1,10 @@ -%define baseversion 1.1.6 +%define baseversion 1.1.8 #define fixversion .1 Summary: Advanced Linux Sound Architecture (ALSA) utilities Name: alsa-utils Version: %{baseversion}%{?fixversion} -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2+ Group: Applications/Multimedia URL: http://www.alsa-project.org/ @@ -17,7 +17,7 @@ Source10: alsa.rules Source11: alsactl.conf Source20: alsa-restore.service Source22: alsa-state.service -Patch0: alsa-utils-1.1.6-post.patch +Patch0: alsa-utils-1.1.8-post.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: alsa-lib-devel >= %{baseversion} BuildRequires: libsamplerate-devel @@ -87,7 +87,7 @@ install -p -m 644 %{SOURCE8} %{buildroot}/%{_mandir}/man1/alsa-delay.1 %files -f %{name}.lang %defattr(-,root,root,-) -%doc COPYING ChangeLog README TODO +%doc COPYING ChangeLog README.md TODO %config /etc/alsa/* %{_prefix}/lib/udev/rules.d/* %{_unitdir}/* @@ -119,6 +119,10 @@ if [ -s /etc/asound.state -a ! -s /var/lib/alsa/asound.state ] ; then fi %changelog +* Wed Mar 13 2019 Jaroslav Kysela - 1.1.8-2 +- Updated to 1.1.8 +- Resolves: rhbz#1658086 + * Tue May 22 2018 Jaroslav Kysela - 1.1.6-1 - Updated to 1.1.6 - Resolves: rhbz#1578685