Blame SOURCES/alsa-utils-1.1.8-post.patch

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