Blame SOURCES/alsa-git.patch

f18a9b
From 737b64e1940b29c575be3942cd9f87aa390d93b2 Mon Sep 17 00:00:00 2001
f18a9b
From: =?UTF-8?q?=E7=A9=8D=E4=B8=B9=E5=B0=BC=20Dan=20Jacobson?=
f18a9b
 <jidanni@jidanni.org>
f18a9b
Date: Sun, 18 Oct 2020 18:33:54 +0800
f18a9b
Subject: [PATCH 02/14] alsamixer: Fix the mixer views description in man page
f18a9b
f18a9b
Fix grammar mess.
f18a9b
f18a9b
From: Dan Jacobson <jidanni@jidanni.org>
f18a9b
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f18a9b
---
f18a9b
 alsamixer/alsamixer.1 | 2 +-
f18a9b
 1 file changed, 1 insertion(+), 1 deletion(-)
f18a9b
f18a9b
diff --git a/alsamixer/alsamixer.1 b/alsamixer/alsamixer.1
f18a9b
index 8d34680..2d711cf 100644
f18a9b
--- a/alsamixer/alsamixer.1
f18a9b
+++ b/alsamixer/alsamixer.1
f18a9b
@@ -34,7 +34,7 @@ Toggle the using of colors.
f18a9b
 
f18a9b
 .SH MIXER VIEWS
f18a9b
 
f18a9b
-The top-left corner of \fBalsamixer\fP is the are to show some basic
f18a9b
+The top-left corner of \fBalsamixer\fP shows some basic
f18a9b
 information: the card name, the mixer chip name, the current view
f18a9b
 mode and the currently selected mixer item.
f18a9b
 When the mixer item is switched off, \fI[Off]\fP is displayed in its
f18a9b
-- 
f18a9b
2.29.2
f18a9b
f18a9b
From 986a1bd3d2eebd41a2925969826fca870b2cd330 Mon Sep 17 00:00:00 2001
f18a9b
From: Jaroslav Kysela <perex@perex.cz>
f18a9b
Date: Fri, 23 Oct 2020 12:05:56 +0200
f18a9b
Subject: [PATCH 06/14] aplay: cosmetic code fix in xrun()
f18a9b
f18a9b
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f18a9b
---
f18a9b
 aplay/aplay.c | 3 ++-
f18a9b
 1 file changed, 2 insertions(+), 1 deletion(-)
f18a9b
f18a9b
diff --git a/aplay/aplay.c b/aplay/aplay.c
f18a9b
index a27220d..ae60988 100644
f18a9b
--- a/aplay/aplay.c
f18a9b
+++ b/aplay/aplay.c
f18a9b
@@ -1676,7 +1676,8 @@ static void xrun(void)
f18a9b
 			prg_exit(EXIT_FAILURE);
f18a9b
 		}
f18a9b
 		return;		/* ok, data should be accepted again */
f18a9b
-	} if (snd_pcm_status_get_state(status) == SND_PCM_STATE_DRAINING) {
f18a9b
+	}
f18a9b
+	if (snd_pcm_status_get_state(status) == SND_PCM_STATE_DRAINING) {
f18a9b
 		if (verbose) {
f18a9b
 			fprintf(stderr, _("Status(DRAINING):\n"));
f18a9b
 			snd_pcm_status_dump(status, log);
f18a9b
-- 
f18a9b
2.29.2
f18a9b
f18a9b
f18a9b
From c1b92db5ef01311e5fc983f3134caa00826d0c2d Mon Sep 17 00:00:00 2001
f18a9b
From: Jaroslav Kysela <perex@perex.cz>
f18a9b
Date: Sun, 8 Nov 2020 19:11:12 +0100
f18a9b
Subject: [PATCH 07/14] aplay: fix the CPU busy loop in the pause handler
f18a9b
f18a9b
Use the standard poll mechanism to ensure that there's
f18a9b
something in the input to avoid busy loop on the file
f18a9b
descriptor with the non-block mode set.
f18a9b
f18a9b
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f18a9b
---
f18a9b
 aplay/aplay.c | 17 +++++++++++++++--
f18a9b
 1 file changed, 15 insertions(+), 2 deletions(-)
f18a9b
f18a9b
diff --git a/aplay/aplay.c b/aplay/aplay.c
f18a9b
index ae60988..d385da2 100644
f18a9b
--- a/aplay/aplay.c
f18a9b
+++ b/aplay/aplay.c
f18a9b
@@ -1553,6 +1553,19 @@ static void done_stdin(void)
f18a9b
 	tcsetattr(fileno(stdin), TCSANOW, &term);
f18a9b
 }
f18a9b
 
f18a9b
+static char wait_for_input(void)
f18a9b
+{
f18a9b
+	struct pollfd pfd;
f18a9b
+	unsigned char b;
f18a9b
+
f18a9b
+	do {
f18a9b
+		pfd.fd = fileno(stdin);
f18a9b
+		pfd.events = POLLIN;
f18a9b
+		poll(&pfd, 1, -1);
f18a9b
+	} while (read(fileno(stdin), &b, 1) != 1);
f18a9b
+	return b;
f18a9b
+}
f18a9b
+
f18a9b
 static void do_pause(void)
f18a9b
 {
f18a9b
 	int err;
f18a9b
@@ -1571,7 +1584,7 @@ static void do_pause(void)
f18a9b
 		return;
f18a9b
 	}
f18a9b
 	while (1) {
f18a9b
-		while (read(fileno(stdin), &b, 1) != 1);
f18a9b
+		b = wait_for_input();
f18a9b
 		if (b == ' ' || b == '\r') {
f18a9b
 			while (read(fileno(stdin), &b, 1) == 1);
f18a9b
 			if (snd_pcm_state(handle) == SND_PCM_STATE_SUSPENDED)
f18a9b
@@ -1596,7 +1609,7 @@ static void check_stdin(void)
f18a9b
 				while (read(fileno(stdin), &b, 1) == 1);
f18a9b
 				fprintf(stderr, _("\r=== PAUSE ===                                                            "));
f18a9b
 				fflush(stderr);
f18a9b
-			do_pause();
f18a9b
+				do_pause();
f18a9b
 				fprintf(stderr, "                                                                          \r");
f18a9b
 				fflush(stderr);
f18a9b
 			}
f18a9b
-- 
f18a9b
2.29.2
f18a9b
f18a9b
f18a9b
From 5812f37d877c12bc594b9ffddc493d305991963a Mon Sep 17 00:00:00 2001
f18a9b
From: Takashi Iwai <tiwai@suse.de>
f18a9b
Date: Wed, 9 Dec 2020 18:35:49 +0100
f18a9b
Subject: [PATCH 08/14] alsa-info: Add lsusb and stream outputs
f18a9b
f18a9b
We need more detailed information for USB-audio devices, at least the
f18a9b
lsusb -v output and the contents of stream* proc files.
f18a9b
Let's add them to alsa-info.sh output.
f18a9b
f18a9b
Signed-off-by: Takashi Iwai <tiwai@suse.de>
f18a9b
---
f18a9b
 alsa-info/alsa-info.sh | 33 +++++++++++++++++++++++++++++++++
f18a9b
 1 file changed, 33 insertions(+)
f18a9b
f18a9b
diff --git a/alsa-info/alsa-info.sh b/alsa-info/alsa-info.sh
f18a9b
index f179bfa..3871b97 100755
f18a9b
--- a/alsa-info/alsa-info.sh
f18a9b
+++ b/alsa-info/alsa-info.sh
f18a9b
@@ -476,6 +476,18 @@ cat /proc/asound/card*/codec\#* > $TEMPDIR/alsa-hda-intel.tmp 2> /dev/null
f18a9b
 cat /proc/asound/card*/codec97\#0/ac97\#0-0 > $TEMPDIR/alsa-ac97.tmp 2> /dev/null
f18a9b
 cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > $TEMPDIR/alsa-ac97-regs.tmp 2> /dev/null
f18a9b
 
f18a9b
+#Check for USB descriptors
f18a9b
+if [ -x /usr/bin/lsusb ]; then
f18a9b
+    for f in /proc/asound/card[0-9]*/usbbus; do
f18a9b
+	test -f "$f" || continue
f18a9b
+	id=$(sed 's@/@:@' $f)
f18a9b
+	lsusb -v -s $id >> $TEMPDIR/lsusb.tmp 2> /dev/null
f18a9b
+    done
f18a9b
+fi
f18a9b
+
f18a9b
+#Check for USB stream setup
f18a9b
+cat /proc/asound/card*/stream[0-9]* > $TEMPDIR/alsa-usbstream.tmp 2> /dev/null
f18a9b
+
f18a9b
 #Check for USB mixer setup
f18a9b
 cat /proc/asound/card*/usbmixer > $TEMPDIR/alsa-usbmixer.tmp 2> /dev/null
f18a9b
 
f18a9b
@@ -649,6 +661,27 @@ if [ -s "$TEMPDIR/alsa-ac97.tmp" ]; then
f18a9b
 	echo "" >> $FILE
f18a9b
 fi
f18a9b
 
f18a9b
+if [ -s "$TEMPDIR/lsusb.tmp" ]; then
f18a9b
+        echo "!!USB Descriptors" >> $FILE
f18a9b
+        echo "!!---------------" >> $FILE
f18a9b
+        echo "--startcollapse--" >> $FILE
f18a9b
+        cat $TEMPDIR/lsusb.tmp >> $FILE
f18a9b
+        echo "--endcollapse--" >> $FILE
f18a9b
+	echo "" >> $FILE
f18a9b
+	echo "" >> $FILE
f18a9b
+fi
f18a9b
+
f18a9b
+if [ -s "$TEMPDIR/lsusb.tmp" ]; then
f18a9b
+        echo "!!USB Stream information" >> $FILE
f18a9b
+        echo "!!----------------------" >> $FILE
f18a9b
+        echo "--startcollapse--" >> $FILE
f18a9b
+        echo "" >> $FILE
f18a9b
+        cat $TEMPDIR/alsa-usbstream.tmp >> $FILE
f18a9b
+        echo "--endcollapse--" >> $FILE
f18a9b
+	echo "" >> $FILE
f18a9b
+	echo "" >> $FILE
f18a9b
+fi
f18a9b
+
f18a9b
 if [ -s "$TEMPDIR/alsa-usbmixer.tmp" ]; then
f18a9b
         echo "!!USB Mixer information" >> $FILE
f18a9b
         echo "!!---------------------" >> $FILE
f18a9b
-- 
f18a9b
2.29.2
f18a9b
f18a9b
f18a9b
From 878e1a7c0f03233530e7675ae015aced069c971d Mon Sep 17 00:00:00 2001
f18a9b
From: Takashi Iwai <tiwai@suse.de>
f18a9b
Date: Fri, 11 Dec 2020 23:41:59 +0100
f18a9b
Subject: [PATCH 10/14] alsactl: Fix double decrease of lock timeout
f18a9b
f18a9b
The state_lock() has a loop to wait for the lock file creation, and
f18a9b
the timeout value gets decremented twice mistakenly, which leads to a
f18a9b
half timeout (5 seconds) than expected 10 seconds.  Fix it.
f18a9b
f18a9b
Signed-off-by: Takashi Iwai <tiwai@suse.de>
f18a9b
---
f18a9b
 alsactl/lock.c | 1 -
f18a9b
 1 file changed, 1 deletion(-)
f18a9b
f18a9b
diff --git a/alsactl/lock.c b/alsactl/lock.c
f18a9b
index 4a48539..05f6e4d 100644
f18a9b
--- a/alsactl/lock.c
f18a9b
+++ b/alsactl/lock.c
f18a9b
@@ -63,7 +63,6 @@ static int state_lock_(const char *file, int lock, int timeout, int _fd)
f18a9b
 			if (fd < 0) {
f18a9b
 				if (errno == EBUSY || errno == EAGAIN) {
f18a9b
 					sleep(1);
f18a9b
-					timeout--;
f18a9b
 				} else {
f18a9b
 					err = -errno;
f18a9b
 					goto out;
f18a9b
-- 
f18a9b
2.29.2
f18a9b
f18a9b
f18a9b
From c53f7cd03881092d5a61505d23ab8f920b7faf12 Mon Sep 17 00:00:00 2001
f18a9b
From: Takashi Iwai <tiwai@suse.de>
f18a9b
Date: Fri, 11 Dec 2020 23:46:23 +0100
f18a9b
Subject: [PATCH 11/14] alsactl: Fix race at creating a lock file
f18a9b
f18a9b
A race at creating a lock file in state_lock() was discovered
f18a9b
recently: namely, between the first open(O_RDWR) and the second
f18a9b
open(O_RDWR|O_CREAT|O_EXCL) calls, another alsactl invocation may
f18a9b
already create a lock file, then the second open() will return EEXIST,
f18a9b
which isn't handled properly and treated as a fatal error.
f18a9b
f18a9b
In this patch, we check EEXIST case and try again open() with O_RDWR.
f18a9b
This must succeed usually, and if it fails, handle finally as the
f18a9b
fatal error.
f18a9b
f18a9b
BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1179904
f18a9b
Signed-off-by: Takashi Iwai <tiwai@suse.de>
f18a9b
---
f18a9b
 alsactl/lock.c | 11 ++++++++---
f18a9b
 1 file changed, 8 insertions(+), 3 deletions(-)
f18a9b
f18a9b
diff --git a/alsactl/lock.c b/alsactl/lock.c
f18a9b
index 05f6e4d..5b47462 100644
f18a9b
--- a/alsactl/lock.c
f18a9b
+++ b/alsactl/lock.c
f18a9b
@@ -63,10 +63,15 @@ static int state_lock_(const char *file, int lock, int timeout, int _fd)
f18a9b
 			if (fd < 0) {
f18a9b
 				if (errno == EBUSY || errno == EAGAIN) {
f18a9b
 					sleep(1);
f18a9b
-				} else {
f18a9b
-					err = -errno;
f18a9b
-					goto out;
f18a9b
+					continue;
f18a9b
 				}
f18a9b
+				if (errno == EEXIST) {
f18a9b
+					fd = open(nfile, O_RDWR);
f18a9b
+					if (fd >= 0)
f18a9b
+						break;
f18a9b
+				}
f18a9b
+				err = -errno;
f18a9b
+				goto out;
f18a9b
 			}
f18a9b
 		}
f18a9b
 	}
f18a9b
-- 
f18a9b
2.29.2
f18a9b
f18a9b
f18a9b
From 12487b40b6e7230a003eb6e4333ee820d8578592 Mon Sep 17 00:00:00 2001
f18a9b
From: Takashi Iwai <tiwai@suse.de>
f18a9b
Date: Fri, 11 Dec 2020 23:55:34 +0100
f18a9b
Subject: [PATCH 12/14] alsactl: Remove asound.state file check from
f18a9b
 alsa-restore.service again
f18a9b
f18a9b
We added the check of asound.state file presence some time ago to
f18a9b
assure that alsactl gets called only if the state file is already
f18a9b
present.  Since then, the situation has changed significantly:
f18a9b
e.g. now alsactl does initialize if the state file isn't present, and
f18a9b
the same alsa-restore.service is used to save the state.  This means
f18a9b
that we should start this service no matter the state file exists at
f18a9b
the boot time or not.  So, revert the old change again.
f18a9b
f18a9b
Signed-off-by: Takashi Iwai <tiwai@suse.de>
f18a9b
---
f18a9b
 alsactl/alsa-restore.service.in | 1 -
f18a9b
 1 file changed, 1 deletion(-)
f18a9b
f18a9b
diff --git a/alsactl/alsa-restore.service.in b/alsactl/alsa-restore.service.in
f18a9b
index a84c2e8..80fd5fd 100644
f18a9b
--- a/alsactl/alsa-restore.service.in
f18a9b
+++ b/alsactl/alsa-restore.service.in
f18a9b
@@ -7,7 +7,6 @@
f18a9b
 Description=Save/Restore Sound Card State
f18a9b
 ConditionPathExists=!@daemonswitch@
f18a9b
 ConditionPathExistsGlob=/dev/snd/control*
f18a9b
-ConditionPathExists=@asoundrcfile@
f18a9b
 
f18a9b
 [Service]
f18a9b
 Type=oneshot
f18a9b
-- 
f18a9b
2.29.2
f18a9b
f18a9b
f18a9b
From 76bc37aeb77d51f995e223582d25335cd98b2eea Mon Sep 17 00:00:00 2001
f18a9b
From: Jaroslav Kysela <perex@perex.cz>
f18a9b
Date: Sun, 3 Jan 2021 17:19:03 +0100
f18a9b
Subject: [PATCH 13/14] aplay: add test code for snd_pcm_status() to
f18a9b
 --test-position
f18a9b
f18a9b
We need to test also snd_pcm_status() values.
f18a9b
f18a9b
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f18a9b
---
f18a9b
 aplay/aplay.c | 48 ++++++++++++++++++++++++++++++++++++++----------
f18a9b
 1 file changed, 38 insertions(+), 10 deletions(-)
f18a9b
f18a9b
diff --git a/aplay/aplay.c b/aplay/aplay.c
f18a9b
index d385da2..5a6d5c3 100644
f18a9b
--- a/aplay/aplay.c
f18a9b
+++ b/aplay/aplay.c
f18a9b
@@ -1953,22 +1953,38 @@ static void do_test_position(void)
f18a9b
 	static snd_pcm_sframes_t minavail, mindelay;
f18a9b
 	static snd_pcm_sframes_t badavail = 0, baddelay = 0;
f18a9b
 	snd_pcm_sframes_t outofrange;
f18a9b
-	snd_pcm_sframes_t avail, delay;
f18a9b
+	snd_pcm_sframes_t avail, delay, savail, sdelay;
f18a9b
+	snd_pcm_status_t *status;
f18a9b
 	int err;
f18a9b
 
f18a9b
+	snd_pcm_status_alloca(&status);
f18a9b
 	err = snd_pcm_avail_delay(handle, &avail, &delay);
f18a9b
 	if (err < 0)
f18a9b
 		return;
f18a9b
+	err = snd_pcm_status(handle, status);
f18a9b
+	if (err < 0)
f18a9b
+		return;
f18a9b
+	savail = snd_pcm_status_get_avail(status);
f18a9b
+	sdelay = snd_pcm_status_get_delay(status);
f18a9b
 	outofrange = (test_coef * (snd_pcm_sframes_t)buffer_frames) / 2;
f18a9b
 	if (avail > outofrange || avail < -outofrange ||
f18a9b
 	    delay > outofrange || delay < -outofrange) {
f18a9b
-	  badavail = avail; baddelay = delay;
f18a9b
-	  availsum = delaysum = samples = 0;
f18a9b
-	  maxavail = maxdelay = 0;
f18a9b
-	  minavail = mindelay = buffer_frames * 16;
f18a9b
-	  fprintf(stderr, _("Suspicious buffer position (%li total): "
f18a9b
-	  	"avail = %li, delay = %li, buffer = %li\n"),
f18a9b
-	  	++counter, (long)avail, (long)delay, (long)buffer_frames);
f18a9b
+		badavail = avail; baddelay = delay;
f18a9b
+		availsum = delaysum = samples = 0;
f18a9b
+		maxavail = maxdelay = 0;
f18a9b
+		minavail = mindelay = buffer_frames * 16;
f18a9b
+		fprintf(stderr, _("Suspicious buffer position (%li total): "
f18a9b
+			"avail = %li, delay = %li, buffer = %li\n"),
f18a9b
+			++counter, (long)avail, (long)delay, (long)buffer_frames);
f18a9b
+	} else if (savail > outofrange || savail < -outofrange ||
f18a9b
+		   sdelay > outofrange || sdelay < -outofrange) {
f18a9b
+		badavail = savail; baddelay = sdelay;
f18a9b
+		availsum = delaysum = samples = 0;
f18a9b
+		maxavail = maxdelay = 0;
f18a9b
+		minavail = mindelay = buffer_frames * 16;
f18a9b
+		fprintf(stderr, _("Suspicious status buffer position (%li total): "
f18a9b
+			"avail = %li, delay = %li, buffer = %li\n"),
f18a9b
+			++counter, (long)savail, (long)sdelay, (long)buffer_frames);
f18a9b
 	} else if (verbose) {
f18a9b
 		time(&now;;
f18a9b
 		if (tmr == (time_t) -1) {
f18a9b
@@ -1979,19 +1995,27 @@ static void do_test_position(void)
f18a9b
 		}
f18a9b
 		if (avail > maxavail)
f18a9b
 			maxavail = avail;
f18a9b
+		if (savail > maxavail)
f18a9b
+			maxavail = savail;
f18a9b
 		if (delay > maxdelay)
f18a9b
 			maxdelay = delay;
f18a9b
+		if (sdelay > maxdelay)
f18a9b
+			maxdelay = sdelay;
f18a9b
 		if (avail < minavail)
f18a9b
 			minavail = avail;
f18a9b
+		if (savail < minavail)
f18a9b
+			minavail = savail;
f18a9b
 		if (delay < mindelay)
f18a9b
 			mindelay = delay;
f18a9b
+		if (sdelay < mindelay)
f18a9b
+			mindelay = sdelay;
f18a9b
 		availsum += avail;
f18a9b
 		delaysum += delay;
f18a9b
 		samples++;
f18a9b
-		if (avail != 0 && now != tmr) {
f18a9b
+		if ((maxavail != 0 || maxdelay != 0) && now != tmr) {
f18a9b
 			fprintf(stderr, "BUFPOS: avg%li/%li "
f18a9b
 				"min%li/%li max%li/%li (%li) (%li:%li/%li)\n",
f18a9b
-				(long)(availsum / samples),
f18a9b
+                         (long)(availsum / samples),
f18a9b
 				(long)(delaysum / samples),
f18a9b
 				(long)minavail, (long)mindelay,
f18a9b
 				(long)maxavail, (long)maxdelay,
f18a9b
@@ -2000,6 +2024,10 @@ static void do_test_position(void)
f18a9b
 			tmr = now;
f18a9b
 		}
f18a9b
 	}
f18a9b
+	if (verbose == 1) {
f18a9b
+		fprintf(stderr, _("Status(R/W) (standalone avail=%li delay=%li):\n"), (long)avail, (long)delay);
f18a9b
+		snd_pcm_status_dump(status, log);
f18a9b
+	}
f18a9b
 }
f18a9b
 
f18a9b
 /*
f18a9b
-- 
f18a9b
2.29.2
f18a9b
f18a9b
f18a9b
From 3980fe71c9795271639239ad8fa982a59de8ff1f Mon Sep 17 00:00:00 2001
f18a9b
From: Jaroslav Kysela <perex@perex.cz>
f18a9b
Date: Mon, 4 Jan 2021 12:13:03 +0100
f18a9b
Subject: [PATCH 14/14] aplay: add avail > delay checks to --test-position
f18a9b
f18a9b
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f18a9b
---
f18a9b
 aplay/aplay.c | 8 ++++++++
f18a9b
 1 file changed, 8 insertions(+)
f18a9b
f18a9b
diff --git a/aplay/aplay.c b/aplay/aplay.c
f18a9b
index 5a6d5c3..b75be6c 100644
f18a9b
--- a/aplay/aplay.c
f18a9b
+++ b/aplay/aplay.c
f18a9b
@@ -1985,6 +1985,14 @@ static void do_test_position(void)
f18a9b
 		fprintf(stderr, _("Suspicious status buffer position (%li total): "
f18a9b
 			"avail = %li, delay = %li, buffer = %li\n"),
f18a9b
 			++counter, (long)savail, (long)sdelay, (long)buffer_frames);
f18a9b
+	} else if (avail > delay) {
f18a9b
+		fprintf(stderr, _("Suspicious buffer position avail > delay (%li total): "
f18a9b
+			"avail = %li, delay = %li\n"),
f18a9b
+			++counter, (long)avail, (long)delay);
f18a9b
+	} else if (savail > sdelay) {
f18a9b
+		fprintf(stderr, _("Suspicious status buffer position avail > delay (%li total): "
f18a9b
+			"avail = %li, delay = %li\n"),
f18a9b
+			++counter, (long)savail, (long)sdelay);
f18a9b
 	} else if (verbose) {
f18a9b
 		time(&now;;
f18a9b
 		if (tmr == (time_t) -1) {
f18a9b
-- 
f18a9b
2.29.2
f18a9b