Blame SOURCES/alsa-git.patch

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