Blame SOURCES/alsa-git.patch

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