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

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