Blame SOURCES/alsa-git.patch

3760b2
From ddfc32abf5697de1618b9e7ffdf57a0f97013090 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 08:49:32 +0200
1fd7ba
Subject: [PATCH 01/28] conf: fix load_for_all_cards()
f29710
3760b2
The 63f7745b commit is loading the driver specific configuration
3760b2
multiple times which ends with the array merges (see the bug).
f29710
3760b2
Introduce the loaded compound which traces the already loaded
3760b2
driver configurations and skip the multiple load requests.
f29710
3760b2
Fixes: https://github.com/alsa-project/alsa-lib/issues/143
3760b2
Fixes: 63f7745b ("conf: extend load_for_all_cards hook (id/value table)")
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/conf.c | 33 ++++++++++++++++++++++++++++-----
3760b2
 1 file changed, 28 insertions(+), 5 deletions(-)
f29710
f29710
diff --git a/src/conf.c b/src/conf.c
3760b2
index f6c80031..d863dec6 100644
f29710
--- a/src/conf.c
f29710
+++ b/src/conf.c
3760b2
@@ -4325,18 +4325,23 @@ static int _snd_config_hook_table(snd_config_t *root, snd_config_t *config, snd_
3760b2
 int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, snd_config_t **dst, snd_config_t *private_data ATTRIBUTE_UNUSED)
f29710
 {
3760b2
 	int card = -1, err;
3760b2
+	snd_config_t *loaded;	// trace loaded cards
3760b2
 	
3760b2
+	err = snd_config_top(&loaded);
3760b2
+	if (err < 0)
3760b2
+		return err;
3760b2
 	do {
3760b2
 		err = snd_card_next(&card;;
3760b2
 		if (err < 0)
3760b2
-			return err;
3760b2
+			goto __fin_err;
3760b2
 		if (card >= 0) {
3760b2
-			snd_config_t *n, *private_data = NULL;
3760b2
+			snd_config_t *n, *m, *private_data = NULL;
3760b2
 			const char *driver;
3760b2
 			char *fdriver = NULL;
3760b2
+			bool load;
3760b2
 			err = snd_determine_driver(card, &fdriver);
3760b2
 			if (err < 0)
3760b2
-				return err;
3760b2
+				goto __fin_err;
3760b2
 			if (snd_config_search(root, fdriver, &n) >= 0) {
3760b2
 				if (snd_config_get_string(n, &driver) < 0) {
3760b2
 					if (snd_config_get_type(n) == SND_CONFIG_TYPE_COMPOUND) {
3760b2
@@ -4357,6 +4362,19 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config,
3760b2
 				driver = fdriver;
3760b2
 			}
3760b2
 		      __std:
3760b2
+			load = true;
3760b2
+			err = snd_config_imake_integer(&m, driver, 1);
3760b2
+			if (err < 0)
3760b2
+				goto __err;
3760b2
+			err = snd_config_add(loaded, m);
3760b2
+			if (err < 0) {
3760b2
+				if (err == -EEXIST) {
3760b2
+					snd_config_delete(m);
3760b2
+					load = false;
3760b2
+				} else {
3760b2
+					goto __err;
3760b2
+				}
c4a1f5
+			}
3760b2
 			private_data = _snd_config_hook_private_data(card, driver);
3760b2
 			if (!private_data) {
3760b2
 				err = -ENOMEM;
3760b2
@@ -4365,17 +4383,22 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config,
3760b2
 			err = _snd_config_hook_table(root, config, private_data);
3760b2
 			if (err < 0)
3760b2
 				goto __err;
3760b2
-			err = snd_config_hook_load(root, config, &n, private_data);
3760b2
+			if (load)
3760b2
+				err = snd_config_hook_load(root, config, &n, private_data);
3760b2
 		      __err:
3760b2
 			if (private_data)
3760b2
 				snd_config_delete(private_data);
3760b2
 			free(fdriver);
3760b2
 			if (err < 0)
3760b2
-				return err;
3760b2
+				goto __fin_err;
3760b2
 		}
3760b2
 	} while (card >= 0);
3760b2
+	snd_config_delete(loaded);
3760b2
 	*dst = NULL;
c4a1f5
 	return 0;
3760b2
+__fin_err:
3760b2
+	snd_config_delete(loaded);
3760b2
+	return err;
c4a1f5
 }
3760b2
 #ifndef DOC_HIDDEN
3760b2
 SND_DLSYM_BUILD_VERSION(snd_config_hook_load_for_all_cards, SND_CONFIG_DLSYM_VERSION_HOOK);
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 0e4ba2ea8c0402f12a645032a14693eb9b1278e6 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 11:09:43 +0200
1fd7ba
Subject: [PATCH 02/28] ucm: add _alibpref to get the private device prefix
f29710
3760b2
It may be useful to get the device prefix for the local configuration.
f29710
3760b2
Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1251
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 include/use-case.h |  1 +
3760b2
 src/ucm/main.c     | 21 +++++++++++++++++++++
3760b2
 2 files changed, 22 insertions(+)
f29710
3760b2
diff --git a/include/use-case.h b/include/use-case.h
3760b2
index ec1a97b0..7890358b 100644
3760b2
--- a/include/use-case.h
3760b2
+++ b/include/use-case.h
3760b2
@@ -258,6 +258,7 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr,
3760b2
  *   - _verb		- return current verb
3760b2
  *   - _file		- return configuration file loaded for current card
3760b2
  *   - _alibcfg		- return private alsa-lib's configuration for current card
3760b2
+ *   - _alibpref	- return private alsa-lib's configuration device prefix for current card
3760b2
  *
3760b2
  *   - [=]{NAME}[/[{modifier}|{/device}][/{verb}]]
3760b2
  *                      - value identifier {NAME}
3760b2
diff --git a/src/ucm/main.c b/src/ucm/main.c
3760b2
index 361952f6..3c9ea15d 100644
3760b2
--- a/src/ucm/main.c
3760b2
+++ b/src/ucm/main.c
3760b2
@@ -2138,6 +2138,25 @@ static int get_alibcfg(snd_use_case_mgr_t *uc_mgr, char **str)
c4a1f5
 	return 0;
c4a1f5
 }
c4a1f5
 
3760b2
+/**
3760b2
+ * \brief Get device prefix for private alsa-lib configuration
3760b2
+ * \param uc_mgr Use case manager
3760b2
+ * \param str Returned value string
3760b2
+ * \return Zero on success (value is filled), otherwise a negative error code
3760b2
+ */
3760b2
+static int get_alibpref(snd_use_case_mgr_t *uc_mgr, char **str)
c4a1f5
+{
3760b2
+	const size_t l = 9;
3760b2
+	char *s;
c4a1f5
+
3760b2
+	s = malloc(l);
3760b2
+	if (s == NULL)
3760b2
+		return -ENOMEM;
3760b2
+	snprintf(s, l, "_ucm%04X", uc_mgr->ucm_card_number);
3760b2
+	*str = s;
3760b2
+	return 0;
3760b2
+}
c4a1f5
+
3760b2
 /**
3760b2
  * \brief Get current - string
3760b2
  * \param uc_mgr Use case manager
3760b2
@@ -2193,6 +2212,8 @@ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
3760b2
 
3760b2
 	} else if (strcmp(identifier, "_alibcfg") == 0) {
3760b2
 		err = get_alibcfg(uc_mgr, (char **)value);
3760b2
+	} else if (strcmp(identifier, "_alibpref") == 0) {
3760b2
+		err = get_alibpref(uc_mgr, (char **)value);
3760b2
 	} else if (identifier[0] == '_') {
3760b2
 		err = -ENOENT;
3760b2
 	} else {
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 9621d0bff2e60b43e329ffa5059ab19f2914ec14 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 11:21:54 +0200
1fd7ba
Subject: [PATCH 03/28] ucm: fix _alibpref string (add '.' delimiter to the
3760b2
 end)
f29710
3760b2
Fixes: 0e4ba2ea ("ucm: add _alibpref to get the private device prefix")
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/ucm/main.c | 4 ++--
3760b2
 1 file changed, 2 insertions(+), 2 deletions(-)
f29710
3760b2
diff --git a/src/ucm/main.c b/src/ucm/main.c
3760b2
index 3c9ea15d..c9b37b68 100644
3760b2
--- a/src/ucm/main.c
3760b2
+++ b/src/ucm/main.c
3760b2
@@ -2146,13 +2146,13 @@ static int get_alibcfg(snd_use_case_mgr_t *uc_mgr, char **str)
3760b2
  */
3760b2
 static int get_alibpref(snd_use_case_mgr_t *uc_mgr, char **str)
3760b2
 {
3760b2
-	const size_t l = 9;
3760b2
+	const size_t l = 10;
3760b2
 	char *s;
3760b2
 
3760b2
 	s = malloc(l);
3760b2
 	if (s == NULL)
3760b2
 		return -ENOMEM;
3760b2
-	snprintf(s, l, "_ucm%04X", uc_mgr->ucm_card_number);
3760b2
+	snprintf(s, l, "_ucm%04X.", uc_mgr->ucm_card_number);
3760b2
 	*str = s;
f29710
 	return 0;
f29710
 }
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 2a1dafdbe5932260aeb4db359ce5d630b8106889 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:26:47 +0200
1fd7ba
Subject: [PATCH 04/28] conf: remove dead code in snd_config_get_card()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/confmisc.c | 6 +++---
3760b2
 1 file changed, 3 insertions(+), 3 deletions(-)
3760b2
3760b2
diff --git a/src/confmisc.c b/src/confmisc.c
3760b2
index 3663d164..a561040c 100644
3760b2
--- a/src/confmisc.c
3760b2
+++ b/src/confmisc.c
3760b2
@@ -154,10 +154,10 @@ int snd_config_get_card(const snd_config_t *conf)
3760b2
 	long v;
3760b2
 	int err;
f29710
 
3760b2
-	if ((err = snd_config_get_integer(conf, &v)) < 0) {
3760b2
+	if (snd_config_get_integer(conf, &v) < 0) {
3760b2
 		if ((err = snd_config_get_string(conf, &str)) < 0) {
3760b2
-			snd_config_get_id(conf, &id;;
3760b2
-			SNDERR("Invalid field %s", id);
3760b2
+			if (snd_config_get_id(conf, &id) >= 0)
3760b2
+				SNDERR("Invalid field %s", id);
3760b2
 			return -EINVAL;
3760b2
 		}
3760b2
 		err = snd_card_get_index(str);
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 013ec607db9de11b682f2b85d843be062ca0d046 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:28:32 +0200
1fd7ba
Subject: [PATCH 05/28] control: remap - fix uninitialized value in
3760b2
 parse_map_vindex()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/control/control_remap.c | 2 +-
3760b2
 1 file changed, 1 insertion(+), 1 deletion(-)
3760b2
3760b2
diff --git a/src/control/control_remap.c b/src/control/control_remap.c
3760b2
index f3d65010..17c6558a 100644
3760b2
--- a/src/control/control_remap.c
3760b2
+++ b/src/control/control_remap.c
3760b2
@@ -1040,7 +1040,7 @@ static int parse_map_vindex(struct snd_ctl_map_ctl *mctl, snd_config_t *conf)
3760b2
 
3760b2
 	snd_config_for_each(i, next, conf) {
3760b2
 		snd_config_t *n = snd_config_iterator_entry(i);
3760b2
-		long idx, chn;
3760b2
+		long idx = -1, chn = -1;
3760b2
 		const char *id;
3760b2
 		if (snd_config_get_id(n, &id) < 0)
3760b2
 			continue;
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 2fee6af9b6e157475159d284af8de1e879bb7a36 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:35:44 +0200
1fd7ba
Subject: [PATCH 06/28] pcm: direct - fix pcmp error path in
3760b2
 _snd_pcm_direct_new()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/pcm/pcm_direct.c | 21 ++++++++++++---------
3760b2
 1 file changed, 12 insertions(+), 9 deletions(-)
3760b2
3760b2
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
3760b2
index 0e5e0421..361805bd 100644
3760b2
--- a/src/pcm/pcm_direct.c
3760b2
+++ b/src/pcm/pcm_direct.c
3760b2
@@ -2126,24 +2126,20 @@ int _snd_pcm_direct_new(snd_pcm_t **pcmp, snd_pcm_direct_t **_dmix, int type,
3760b2
 	dmix->type = type;
f29710
 
3760b2
 	ret = snd_pcm_new(pcmp, type, name, stream, mode);
3760b2
-	if (ret < 0) {
3760b2
-_err_nosem:
3760b2
-		free(dmix->bindings);
3760b2
-		free(dmix);
3760b2
-		return ret;
3760b2
-	}
3760b2
+	if (ret < 0)
3760b2
+		goto _err_nosem;
3760b2
 
3760b2
 	while (1) {
3760b2
 		ret = snd_pcm_direct_semaphore_create_or_connect(dmix);
3760b2
 		if (ret < 0) {
3760b2
 			SNDERR("unable to create IPC semaphore");
3760b2
-			goto _err_nosem;
3760b2
+			goto _err_nosem_free;
3760b2
 		}
3760b2
 		ret = snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT);
3760b2
 		if (ret < 0) {
3760b2
 			snd_pcm_direct_semaphore_discard(dmix);
3760b2
 			if (--fail_sem_loop <= 0)
3760b2
-				goto _err_nosem;
3760b2
+				goto _err_nosem_free;
3760b2
 			continue;
3760b2
 		}
3760b2
 		break;
3760b2
@@ -2153,10 +2149,17 @@ _err_nosem:
3760b2
 	if (ret < 0) {
3760b2
 		SNDERR("unable to create IPC shm instance");
3760b2
 		snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
3760b2
-		goto _err_nosem;
3760b2
+		goto _err_nosem_free;
3760b2
 	} else {
3760b2
 		*_dmix = dmix;
3760b2
 	}
c4a1f5
 
3760b2
+	return ret;
3760b2
+_err_nosem_free:
3760b2
+	snd_pcm_free(*pcmp);
3760b2
+	*pcmp = NULL;
3760b2
+_err_nosem:
3760b2
+	free(dmix->bindings);
3760b2
+	free(dmix);
3760b2
 	return ret;
3760b2
 }
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From eb95cad4e22a0bf2577f1fa4a3f6fd18caed3362 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:37:53 +0200
1fd7ba
Subject: [PATCH 07/28] pcm: remove extra NULL checks in snd_pcm_dmix_open()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/pcm/pcm_dmix.c | 11 ++++-------
3760b2
 1 file changed, 4 insertions(+), 7 deletions(-)
3760b2
3760b2
diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c
3760b2
index 8747450f..608593f1 100644
3760b2
--- a/src/pcm/pcm_dmix.c
3760b2
+++ b/src/pcm/pcm_dmix.c
3760b2
@@ -998,7 +998,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
3760b2
 		      snd_config_t *root, snd_config_t *sconf,
3760b2
 		      snd_pcm_stream_t stream, int mode)
3760b2
 {
3760b2
-	snd_pcm_t *pcm = NULL, *spcm = NULL;
3760b2
+	snd_pcm_t *pcm, *spcm = NULL;
3760b2
 	snd_pcm_direct_t *dmix;
3760b2
 	int ret, first_instance;
3760b2
 
3760b2
@@ -1154,12 +1154,9 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
3760b2
 	} else
3760b2
 		snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
3760b2
  _err_nosem:
3760b2
-	if (dmix) {
3760b2
-		free(dmix->bindings);
3760b2
-		free(dmix);
3760b2
-	}
3760b2
-	if (pcm)
3760b2
-		snd_pcm_free(pcm);
3760b2
+	free(dmix->bindings);
3760b2
+	free(dmix);
3760b2
+	snd_pcm_free(pcm);
3760b2
 	return ret;
f29710
 }
3760b2
 
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 01a45aec6fcd5a5378a5b5e0ae0f9dacde2068e4 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:39:32 +0200
1fd7ba
Subject: [PATCH 08/28] pcm: remove extra NULL checks in snd_pcm_dsnoop_open()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/pcm/pcm_dsnoop.c | 13 +++++--------
3760b2
 1 file changed, 5 insertions(+), 8 deletions(-)
f29710
3760b2
diff --git a/src/pcm/pcm_dsnoop.c b/src/pcm/pcm_dsnoop.c
3760b2
index fb1b02c2..2c3b9f43 100644
3760b2
--- a/src/pcm/pcm_dsnoop.c
3760b2
+++ b/src/pcm/pcm_dsnoop.c
3760b2
@@ -564,8 +564,8 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
3760b2
 			snd_config_t *root, snd_config_t *sconf,
3760b2
 			snd_pcm_stream_t stream, int mode)
3760b2
 {
3760b2
-	snd_pcm_t *pcm = NULL, *spcm = NULL;
3760b2
-	snd_pcm_direct_t *dsnoop = NULL;
3760b2
+	snd_pcm_t *pcm, *spcm = NULL;
3760b2
+	snd_pcm_direct_t *dsnoop;
3760b2
 	int ret, first_instance;
3760b2
 
3760b2
 	assert(pcmp);
3760b2
@@ -708,12 +708,9 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
3760b2
 		snd_pcm_direct_semaphore_up(dsnoop, DIRECT_IPC_SEM_CLIENT);
3760b2
 
3760b2
  _err_nosem:
3760b2
-	if (dsnoop) {
3760b2
-		free(dsnoop->bindings);
3760b2
-		free(dsnoop);
3760b2
-	}
3760b2
-	if (pcm)
3760b2
-		snd_pcm_free(pcm);
3760b2
+	free(dsnoop->bindings);
3760b2
+	free(dsnoop);
3760b2
+	snd_pcm_free(pcm);
3760b2
 	return ret;
3760b2
 }
f29710
 
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 74c6382df6cf18b801659d8c5c53407a7ea1f02b Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:46:46 +0200
1fd7ba
Subject: [PATCH 09/28] pcm: remove extra NULL checks in snd_pcm_dshare_open()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/pcm/pcm_dshare.c | 13 +++++--------
3760b2
 1 file changed, 5 insertions(+), 8 deletions(-)
3760b2
3760b2
diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c
3760b2
index 0f5238a6..a918512b 100644
3760b2
--- a/src/pcm/pcm_dshare.c
3760b2
+++ b/src/pcm/pcm_dshare.c
3760b2
@@ -690,8 +690,8 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
3760b2
 			snd_config_t *root, snd_config_t *sconf,
3760b2
 			snd_pcm_stream_t stream, int mode)
3760b2
 {
3760b2
-	snd_pcm_t *pcm = NULL, *spcm = NULL;
3760b2
-	snd_pcm_direct_t *dshare = NULL;
3760b2
+	snd_pcm_t *pcm, *spcm = NULL;
3760b2
+	snd_pcm_direct_t *dshare;
3760b2
 	int ret, first_instance;
3760b2
 	unsigned int chn;
3760b2
 
3760b2
@@ -851,12 +851,9 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
3760b2
 	} else
3760b2
 		snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
3760b2
  _err_nosem:
3760b2
-	if (dshare) {
3760b2
-		free(dshare->bindings);
3760b2
-		free(dshare);
3760b2
-	}
3760b2
-	if (pcm)
3760b2
-		snd_pcm_free(pcm);
3760b2
+	free(dshare->bindings);
3760b2
+	free(dshare);
3760b2
+	snd_pcm_free(pcm);
3760b2
 	return ret;
3760b2
 }
3760b2
 
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From eabadf545c51d4c88c5f359db73726ec3ac653ba Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:49:29 +0200
1fd7ba
Subject: [PATCH 10/28] pcm: softvol - fix early exit in add_tlv_info()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/pcm/pcm_softvol.c | 4 ++--
3760b2
 1 file changed, 2 insertions(+), 2 deletions(-)
f29710
3760b2
diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c
3760b2
index e2bdd31a..eea322ca 100644
3760b2
--- a/src/pcm/pcm_softvol.c
3760b2
+++ b/src/pcm/pcm_softvol.c
3760b2
@@ -711,13 +711,13 @@ static int add_tlv_info(snd_pcm_softvol_t *svol, snd_ctl_elem_info_t *cinfo,
3760b2
 			unsigned int *old_tlv, size_t old_tlv_size)
3760b2
 {
3760b2
 	unsigned int tlv[4];
3760b2
-	if (sizeof(tlv) <= old_tlv_size && memcmp(tlv, old_tlv, sizeof(tlv)) == 0)
3760b2
-		return 0;
3760b2
 	tlv[SNDRV_CTL_TLVO_TYPE] = SND_CTL_TLVT_DB_SCALE;
3760b2
 	tlv[SNDRV_CTL_TLVO_LEN] = 2 * sizeof(int);
3760b2
 	tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] = (int)(svol->min_dB * 100);
3760b2
 	tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] =
3760b2
 		(int)((svol->max_dB - svol->min_dB) * 100 / svol->max_val);
3760b2
+	if (sizeof(tlv) <= old_tlv_size && memcmp(tlv, old_tlv, sizeof(tlv)) == 0)
3760b2
+		return 0;
3760b2
 	return snd_ctl_elem_tlv_write(svol->ctl, &cinfo->id, tlv);
3760b2
 }
f29710
 
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From cf3846d46053b23006e6a9042b586fc78e81af55 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:50:17 +0200
1fd7ba
Subject: [PATCH 11/28] timer: remove dead code in _snd_timer_hw_open()
f29710
f29710
---
3760b2
 src/timer/timer_hw.c | 2 --
3760b2
 1 file changed, 2 deletions(-)
f29710
3760b2
diff --git a/src/timer/timer_hw.c b/src/timer/timer_hw.c
3760b2
index cfb77463..fe4e40bb 100644
3760b2
--- a/src/timer/timer_hw.c
3760b2
+++ b/src/timer/timer_hw.c
3760b2
@@ -330,8 +330,6 @@ int _snd_timer_hw_open(snd_timer_t **timer, char *name,
3760b2
 		SNDERR("Unexpected field %s", id);
3760b2
 		return -EINVAL;
3760b2
 	}
3760b2
-	if (card < 0)
3760b2
-		return -EINVAL;
3760b2
 	return snd_timer_hw_open(timer, name, dev_class, dev_sclass, card, device, subdevice, mode);
3760b2
 }
3760b2
 SND_DLSYM_BUILD_VERSION(_snd_timer_hw_open, SND_TIMER_DLSYM_VERSION);
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 200d18cda7a700607c21ad5dc9faaea2a1e27dbd Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:51:13 +0200
1fd7ba
Subject: [PATCH 12/28] ucm: fix error path in execute_cfgsave()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/ucm/main.c | 4 +++-
3760b2
 1 file changed, 3 insertions(+), 1 deletion(-)
f29710
3760b2
diff --git a/src/ucm/main.c b/src/ucm/main.c
3760b2
index c9b37b68..42fdaa1d 100644
3760b2
--- a/src/ucm/main.c
3760b2
+++ b/src/ucm/main.c
3760b2
@@ -605,8 +605,10 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename)
3760b2
 		uc_error("unable to open file '%s': %s", file, snd_strerror(err));
3760b2
 		goto _err;
3760b2
 	}
3760b2
-	if (!config || snd_config_is_empty(config))
3760b2
+	if (!config || snd_config_is_empty(config)) {
3760b2
+		snd_output_close(out);
3760b2
 		goto _err;
3760b2
+	}
3760b2
 	if (with_root) {
3760b2
 		snd_output_printf(out, "%s ", root);
3760b2
 		err = _snd_config_save_node_value(config, out, 0);
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 9b71d53bde21c8bb0d900c17863664e12753d844 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:52:12 +0200
1fd7ba
Subject: [PATCH 13/28] ucm: fix use after free in if_eval_regex_match()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/ucm/ucm_cond.c | 3 ++-
f29710
 1 file changed, 2 insertions(+), 1 deletion(-)
f29710
3760b2
diff --git a/src/ucm/ucm_cond.c b/src/ucm/ucm_cond.c
3760b2
index 59d1a155..adb0ecd9 100644
3760b2
--- a/src/ucm/ucm_cond.c
3760b2
+++ b/src/ucm/ucm_cond.c
3760b2
@@ -160,11 +160,12 @@ static int if_eval_regex_match(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
3760b2
 	if (err < 0)
3760b2
 		return err;
3760b2
 	err = regcomp(&re, s, options);
3760b2
-	free(s);
3760b2
 	if (err) {
3760b2
 		uc_error("Regex '%s' compilation failed (code %d)", s, err);
f29710
+		free(s);
3760b2
 		return -EINVAL;
f29710
 	}
3760b2
+	free(s);
3760b2
 
3760b2
 	err = uc_mgr_get_substituted_value(uc_mgr, &s, string);
3760b2
 	if (err < 0) {
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 7764e3e621a4c8a52327833d44e32c8b6fe3a131 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:53:24 +0200
1fd7ba
Subject: [PATCH 14/28] ucm: fix if_eval_path() - access NULL pointer
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/ucm/ucm_cond.c | 2 +-
3760b2
 1 file changed, 1 insertion(+), 1 deletion(-)
3760b2
3760b2
diff --git a/src/ucm/ucm_cond.c b/src/ucm/ucm_cond.c
3760b2
index adb0ecd9..0ed0b690 100644
3760b2
--- a/src/ucm/ucm_cond.c
3760b2
+++ b/src/ucm/ucm_cond.c
3760b2
@@ -272,7 +272,7 @@ static int if_eval_control_exists(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval
3760b2
 
3760b2
 static int if_eval_path(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
3760b2
 {
3760b2
-	const char *path, *mode = NULL;
3760b2
+	const char *path, *mode = "";
3760b2
 	int err, amode = F_OK;
c4a1f5
 
3760b2
 	if (uc_mgr->conf_format < 4) {
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 7fcb1aadd56e94f03e51c4747e72d77279151c22 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:56:01 +0200
1fd7ba
Subject: [PATCH 15/28] ucm: find_exec() - fix memory leak (dir)
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/ucm/ucm_exec.c | 1 +
f29710
 1 file changed, 1 insertion(+)
f29710
3760b2
diff --git a/src/ucm/ucm_exec.c b/src/ucm/ucm_exec.c
3760b2
index a22df8fe..1cdb2633 100644
3760b2
--- a/src/ucm/ucm_exec.c
3760b2
+++ b/src/ucm/ucm_exec.c
3760b2
@@ -73,6 +73,7 @@ static int find_exec(const char *name, char *out, size_t len)
3760b2
 				    || !(st.st_mode & S_IEXEC))
3760b2
 					continue;
3760b2
 				snd_strlcpy(out, bin, len);
3760b2
+				closedir(dir);
3760b2
 				return 1;
3760b2
 			}
3760b2
 			closedir(dir);
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 26ab7fc3e4cba416cf51aa0fb48fdddaa0d861ee Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:58:04 +0200
1fd7ba
Subject: [PATCH 16/28] ucm: fix possible NULL pointer dereference in
3760b2
 uc_mgr_exec()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/ucm/ucm_exec.c | 6 +++++-
3760b2
 1 file changed, 5 insertions(+), 1 deletion(-)
3760b2
3760b2
diff --git a/src/ucm/ucm_exec.c b/src/ucm/ucm_exec.c
3760b2
index 1cdb2633..d83206d0 100644
3760b2
--- a/src/ucm/ucm_exec.c
3760b2
+++ b/src/ucm/ucm_exec.c
3760b2
@@ -185,7 +185,11 @@ int uc_mgr_exec(const char *prog)
3760b2
 		return -EINVAL;
c4a1f5
 
3760b2
 	prog = argv[0];
3760b2
-	if (argv[0][0] != '/' && argv[0][0] != '.') {
3760b2
+	if (prog == NULL) {
3760b2
+		err = -EINVAL;
3760b2
+		goto __error;
3760b2
+	}
3760b2
+	if (prog[0] != '/' && prog[0] != '.') {
3760b2
 		if (!find_exec(argv[0], bin, sizeof(bin))) {
3760b2
 			err = -ENOEXEC;
3760b2
 			goto __error;
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 64a6d4d1e827732bef7c68e1e6d2cb6863b4597c Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 19:59:10 +0200
1fd7ba
Subject: [PATCH 17/28] ucm: check error value in parse_lookup_query()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/ucm/ucm_subs.c | 6 +++++-
3760b2
 1 file changed, 5 insertions(+), 1 deletion(-)
f29710
3760b2
diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c
3760b2
index c56730c5..0bc4e63f 100644
3760b2
--- a/src/ucm/ucm_subs.c
3760b2
+++ b/src/ucm/ucm_subs.c
3760b2
@@ -224,7 +224,11 @@ static snd_config_t *parse_lookup_query(const char *query)
3760b2
 		uc_error("unable to create memory input buffer");
3760b2
 		return NULL;
3760b2
 	}
3760b2
-	snd_config_top(&config);
3760b2
+	err = snd_config_top(&config);
3760b2
+	if (err < 0) {
3760b2
+		snd_input_close(input);
3760b2
+		return NULL;
3760b2
+	}
3760b2
 	err = snd_config_load(config, input);
3760b2
 	snd_input_close(input);
3760b2
 	if (err < 0) {
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 30d1d256e792fbabf14c57efb98c489541b19f37 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Wed, 2 Jun 2021 20:01:08 +0200
1fd7ba
Subject: [PATCH 18/28] ucm: fix out-of-array access in
3760b2
 rval_device_lookup_init()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/ucm/ucm_subs.c | 2 +-
3760b2
 1 file changed, 1 insertion(+), 1 deletion(-)
f29710
3760b2
diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c
3760b2
index 0bc4e63f..20905c3f 100644
3760b2
--- a/src/ucm/ucm_subs.c
3760b2
+++ b/src/ucm/ucm_subs.c
3760b2
@@ -489,7 +489,7 @@ static int rval_device_lookup_init(snd_use_case_mgr_t *uc_mgr,
3760b2
 		uc_error("Missing device type!");
3760b2
 		return -EINVAL;
3760b2
 	}
3760b2
-	for (t = types; t; t++)
3760b2
+	for (t = types; t->name; t++)
3760b2
 		if (strcasecmp(t->name, s) == 0)
3760b2
 			return t->init(iter, config);
3760b2
 	uc_error("Device type '%s' is invalid", s);
3760b2
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 42c0ccf3275fef523471fa7ea4feecd7b1052357 Mon Sep 17 00:00:00 2001
3760b2
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Thu, 3 Jun 2021 07:29:11 +0200
1fd7ba
Subject: [PATCH 19/28] conf: snd_config_get_card() remove unused assignment
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/confmisc.c | 2 +-
3760b2
 1 file changed, 1 insertion(+), 1 deletion(-)
f29710
3760b2
diff --git a/src/confmisc.c b/src/confmisc.c
3760b2
index a561040c..64af96fa 100644
3760b2
--- a/src/confmisc.c
3760b2
+++ b/src/confmisc.c
3760b2
@@ -155,7 +155,7 @@ int snd_config_get_card(const snd_config_t *conf)
3760b2
 	int err;
f29710
 
3760b2
 	if (snd_config_get_integer(conf, &v) < 0) {
3760b2
-		if ((err = snd_config_get_string(conf, &str)) < 0) {
3760b2
+		if (snd_config_get_string(conf, &str)) {
3760b2
 			if (snd_config_get_id(conf, &id) >= 0)
3760b2
 				SNDERR("Invalid field %s", id);
3760b2
 			return -EINVAL;
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From a154cb29043a4db2fa92bc146fd4cf94c9851892 Mon Sep 17 00:00:00 2001
3760b2
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Thu, 3 Jun 2021 07:29:43 +0200
1fd7ba
Subject: [PATCH 20/28] pcm: direct - remove dead code
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/pcm/pcm_direct.c | 2 --
3760b2
 1 file changed, 2 deletions(-)
f29710
3760b2
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
3760b2
index 361805bd..d50503e3 100644
3760b2
--- a/src/pcm/pcm_direct.c
3760b2
+++ b/src/pcm/pcm_direct.c
3760b2
@@ -1857,8 +1857,6 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root,
3760b2
 			continue;
3760b2
 		}
3760b2
 	}
3760b2
-	if (card < 0)
3760b2
-		card = 0;
3760b2
 	if (device < 0)
3760b2
 		device = 0;
3760b2
 	if (subdevice < 0)
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From e2133090603a74c0b08cd45b689063071bc90c81 Mon Sep 17 00:00:00 2001
3760b2
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Thu, 3 Jun 2021 07:30:27 +0200
1fd7ba
Subject: [PATCH 21/28] ucm: fix possible memory leak in parse_verb_file()
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/ucm/parser.c | 2 +-
3760b2
 1 file changed, 1 insertion(+), 1 deletion(-)
3760b2
3760b2
diff --git a/src/ucm/parser.c b/src/ucm/parser.c
3760b2
index ed261fa2..fccf5791 100644
3760b2
--- a/src/ucm/parser.c
3760b2
+++ b/src/ucm/parser.c
3760b2
@@ -1779,7 +1779,7 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
3760b2
 			err = parse_libconfig(uc_mgr, n);
3760b2
 			if (err < 0) {
3760b2
 				uc_error("error: failed to parse LibConfig");
3760b2
-				return err;
3760b2
+				goto _err;
3760b2
 			}
3760b2
 			continue;
3760b2
 		}
f29710
-- 
3760b2
2.30.2
f29710
f29710
3760b2
From 0325f4357d25f262400038f074512e1887c8e5f1 Mon Sep 17 00:00:00 2001
f29710
From: Jaroslav Kysela <perex@perex.cz>
3760b2
Date: Thu, 3 Jun 2021 09:00:51 +0200
1fd7ba
Subject: [PATCH 22/28] ucm: compound_merge() - fix use after free (and logic)
f29710
f29710
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
f29710
---
3760b2
 src/ucm/ucm_include.c | 8 +++++---
3760b2
 1 file changed, 5 insertions(+), 3 deletions(-)
3760b2
3760b2
diff --git a/src/ucm/ucm_include.c b/src/ucm/ucm_include.c
3760b2
index 6945dd2e..a3a584a1 100644
3760b2
--- a/src/ucm/ucm_include.c
3760b2
+++ b/src/ucm/ucm_include.c
3760b2
@@ -108,7 +108,7 @@ static int find_position_node(snd_config_t **res, snd_config_t *dst,
f29710
 	return 0;
f29710
 }
c4a1f5
 
3760b2
-static int merge_it(snd_config_t *dst, snd_config_t *n)
3760b2
+static int merge_it(snd_config_t *dst, snd_config_t *n, snd_config_t **_dn)
3760b2
 {
3760b2
 	snd_config_t *dn;
3760b2
 	const char *id;
3760b2
@@ -123,6 +123,8 @@ static int merge_it(snd_config_t *dst, snd_config_t *n)
3760b2
 	err = snd_config_merge(dn, n, 0); /* merge / append mode */
3760b2
 	if (err < 0)
3760b2
 		snd_config_delete(n);
3760b2
+	else
3760b2
+		*_dn = dn;
3760b2
 	return err;
f29710
 }
f29710
 
3760b2
@@ -198,7 +200,7 @@ static int compound_merge(const char *id,
3760b2
 		if (_before) {
3760b2
 			err = snd_config_add_before(_before, n);
3760b2
 			if (err == -EEXIST)
3760b2
-				err = merge_it(dst, n);
3760b2
+				err = merge_it(dst, n, &n);
3760b2
 			if (err < 0)
3760b2
 				return err;
3760b2
 			_before = NULL;
3760b2
@@ -206,7 +208,7 @@ static int compound_merge(const char *id,
3760b2
 		} else if (_after) {
3760b2
 			err = snd_config_add_after(_after, n);
3760b2
 			if (err == -EEXIST)
3760b2
-				err = merge_it(dst, n);
3760b2
+				err = merge_it(dst, n, &n);
3760b2
 			if (err < 0)
3760b2
 				return err;
3760b2
 			_after = n;
3760b2
-- 
3760b2
2.30.2
f29710
1fd7ba
1fd7ba
From abe805ed6c7f38e48002e575535afd1f673b9bcd Mon Sep 17 00:00:00 2001
1fd7ba
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
1fd7ba
Date: Thu, 3 Jun 2021 12:29:03 +0200
1fd7ba
Subject: [PATCH 23/28] ucm_exec.c: Include limits.h explicitly to fix build on
1fd7ba
 musl
1fd7ba
MIME-Version: 1.0
1fd7ba
Content-Type: text/plain; charset=UTF-8
1fd7ba
Content-Transfer-Encoding: 8bit
1fd7ba
1fd7ba
Fixes:
1fd7ba
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c: In function 'find_exec':
1fd7ba
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c:43:18: error: 'PATH_MAX' undeclared (first use in this function)
1fd7ba
|    43 |         char bin[PATH_MAX];
1fd7ba
|       |                  ^~~~~~~~
1fd7ba
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c:43:18: note: each undeclared identifier is reported only once for each function it appears in
1fd7ba
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c: In function 'uc_mgr_exec':
1fd7ba
| ../../../alsa-lib-1.2.5/src/ucm/ucm_exec.c:177:18: error: 'PATH_MAX' undeclared (first use in this function)
1fd7ba
|   177 |         char bin[PATH_MAX];
1fd7ba
|       |                  ^~~~~~~~
1fd7ba
1fd7ba
Fixes: https://github.com/alsa-project/alsa-lib/pull/145
1fd7ba
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
1fd7ba
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1fd7ba
---
1fd7ba
 src/ucm/ucm_exec.c | 1 +
1fd7ba
 1 file changed, 1 insertion(+)
1fd7ba
1fd7ba
diff --git a/src/ucm/ucm_exec.c b/src/ucm/ucm_exec.c
1fd7ba
index d83206d0..4ddf5d15 100644
1fd7ba
--- a/src/ucm/ucm_exec.c
1fd7ba
+++ b/src/ucm/ucm_exec.c
1fd7ba
@@ -30,6 +30,7 @@
1fd7ba
 #include "ucm_local.h"
1fd7ba
 #include <sys/stat.h>
1fd7ba
 #include <sys/wait.h>
1fd7ba
+#include <limits.h>
1fd7ba
 #include <dirent.h>
1fd7ba
 
1fd7ba
 static pthread_mutex_t fork_lock = PTHREAD_MUTEX_INITIALIZER;
1fd7ba
-- 
1fd7ba
2.30.2
1fd7ba
1fd7ba
1fd7ba
From 01960fa85699686763e42eab537100909e8e6607 Mon Sep 17 00:00:00 2001
1fd7ba
From: Chih-Wei Huang <cwhuang@linux.org.tw>
1fd7ba
Date: Mon, 14 Jun 2021 12:21:35 +0800
1fd7ba
Subject: [PATCH 24/28] ucm: include sys/wait.h to fix build on Android
1fd7ba
1fd7ba
    src/ucm/main.c:788:8: error: implicit declaration of function 'WIFSIGNALED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
1fd7ba
                        if (WIFSIGNALED(err)) {
1fd7ba
                            ^
1fd7ba
    src/ucm/main.c:790:10: error: implicit declaration of function 'WIFEXITED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
1fd7ba
                        } if (WIFEXITED(err)) {
1fd7ba
                              ^
1fd7ba
    src/ucm/main.c:791:34: error: implicit declaration of function 'WEXITSTATUS' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
1fd7ba
                                if (ignore_error == false && WEXITSTATUS(err) != 0) {
1fd7ba
1fd7ba
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
1fd7ba
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1fd7ba
---
1fd7ba
 src/ucm/main.c | 1 +
1fd7ba
 1 file changed, 1 insertion(+)
1fd7ba
1fd7ba
diff --git a/src/ucm/main.c b/src/ucm/main.c
1fd7ba
index 42fdaa1d..d4645e4a 100644
1fd7ba
--- a/src/ucm/main.c
1fd7ba
+++ b/src/ucm/main.c
1fd7ba
@@ -37,6 +37,7 @@
1fd7ba
 #include <stdarg.h>
1fd7ba
 #include <pthread.h>
1fd7ba
 #include <sys/stat.h>
1fd7ba
+#include <sys/wait.h>
1fd7ba
 #include <limits.h>
1fd7ba
 
1fd7ba
 /*
1fd7ba
-- 
1fd7ba
2.30.2
1fd7ba
1fd7ba
1fd7ba
From 76d1aa0cd7635f903bb1d48bb9c18279d46ec624 Mon Sep 17 00:00:00 2001
1fd7ba
From: Chih-Wei Huang <cwhuang@linux.org.tw>
1fd7ba
Date: Mon, 14 Jun 2021 12:24:10 +0800
1fd7ba
Subject: [PATCH 25/28] configure: check if eaccess() is available
1fd7ba
1fd7ba
To fix the build error on Android:
1fd7ba
  src/ucm/parser.c:2521:7: error: implicit declaration of function 'eaccess' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
1fd7ba
                if (eaccess(filename, R_OK))
1fd7ba
                    ^
1fd7ba
  src/ucm/parser.c:2521:7: note: did you mean 'access'?
1fd7ba
1fd7ba
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
1fd7ba
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1fd7ba
---
1fd7ba
 configure.ac       | 1 +
1fd7ba
 src/ucm/parser.c   | 4 ++++
1fd7ba
 src/ucm/ucm_cond.c | 4 ++++
1fd7ba
 3 files changed, 9 insertions(+)
1fd7ba
1fd7ba
diff --git a/configure.ac b/configure.ac
1fd7ba
index 60271b8a..635bfeae 100644
1fd7ba
--- a/configure.ac
1fd7ba
+++ b/configure.ac
1fd7ba
@@ -50,6 +50,7 @@ AC_HEADER_TIME
1fd7ba
 dnl Checks for library functions.
1fd7ba
 AC_PROG_GCC_TRADITIONAL
1fd7ba
 AC_CHECK_FUNCS([uselocale])
1fd7ba
+AC_CHECK_FUNCS([eaccess])
1fd7ba
 
1fd7ba
 SAVE_LIBRARY_VERSION
1fd7ba
 AC_SUBST(LIBTOOL_VERSION_INFO)
1fd7ba
diff --git a/src/ucm/parser.c b/src/ucm/parser.c
1fd7ba
index fccf5791..ee997800 100644
1fd7ba
--- a/src/ucm/parser.c
1fd7ba
+++ b/src/ucm/parser.c
1fd7ba
@@ -2518,7 +2518,11 @@ int uc_mgr_scan_master_configs(const char **_list[])
1fd7ba
 
1fd7ba
 		snprintf(fn, sizeof(fn), "%s.conf", d_name);
1fd7ba
 		ucm_filename(filename, sizeof(filename), 2, d_name, fn);
1fd7ba
+#ifdef HAVE_EACCESS
1fd7ba
 		if (eaccess(filename, R_OK))
1fd7ba
+#else
1fd7ba
+		if (access(filename, R_OK))
1fd7ba
+#endif
1fd7ba
 			continue;
1fd7ba
 
1fd7ba
 		err = uc_mgr_config_load(2, filename, &cfg;;
1fd7ba
diff --git a/src/ucm/ucm_cond.c b/src/ucm/ucm_cond.c
1fd7ba
index 0ed0b690..985a366b 100644
1fd7ba
--- a/src/ucm/ucm_cond.c
1fd7ba
+++ b/src/ucm/ucm_cond.c
1fd7ba
@@ -305,7 +305,11 @@ static int if_eval_path(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
1fd7ba
 		return -EINVAL;
1fd7ba
 	}
1fd7ba
 
1fd7ba
+#ifdef HAVE_EACCESS
1fd7ba
 	if (eaccess(path, amode))
1fd7ba
+#else
1fd7ba
+	if (access(path, amode))
1fd7ba
+#endif
1fd7ba
 		return 0;
1fd7ba
 
1fd7ba
 	return 1;
1fd7ba
-- 
1fd7ba
2.30.2
1fd7ba
1fd7ba
1fd7ba
From 8253c1c1f9095901c7dbfbb8ca5147d05828651a Mon Sep 17 00:00:00 2001
1fd7ba
From: Chih-Wei Huang <cwhuang@linux.org.tw>
1fd7ba
Date: Mon, 14 Jun 2021 12:41:11 +0800
1fd7ba
Subject: [PATCH 26/28] Fix EXPORT_SYMBOL attribute for clang
1fd7ba
1fd7ba
Clang doesn't have the externally_visible attribute.
1fd7ba
1fd7ba
    src/pcm/pcm.c:1503:1: error: unknown attribute 'externally_visible' ignored [-Werror,-Wunknown-attributes]
1fd7ba
    #define EXPORT_SYMBOL __attribute__((visibility("default"),externally_visible))                                                         ^
1fd7ba
1fd7ba
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
1fd7ba
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1fd7ba
---
1fd7ba
 include/alsa-symbols.h | 4 ++++
1fd7ba
 1 file changed, 4 insertions(+)
1fd7ba
1fd7ba
diff --git a/include/alsa-symbols.h b/include/alsa-symbols.h
1fd7ba
index bba9a9d4..344f021a 100644
1fd7ba
--- a/include/alsa-symbols.h
1fd7ba
+++ b/include/alsa-symbols.h
1fd7ba
@@ -34,7 +34,11 @@
1fd7ba
 #define default_symbol_version(real, name, version) \
1fd7ba
 	__asm__ (".symver " ASM_NAME(#real) "," ASM_NAME(#name) "@@" #version)
1fd7ba
 
1fd7ba
+#ifdef __clang__
1fd7ba
+#define EXPORT_SYMBOL __attribute__((visibility("default")))
1fd7ba
+#else
1fd7ba
 #define EXPORT_SYMBOL __attribute__((visibility("default"),externally_visible))
1fd7ba
+#endif
1fd7ba
 
1fd7ba
 #ifdef USE_VERSIONED_SYMBOLS
1fd7ba
 #define use_symbol_version(real, name, version) \
1fd7ba
-- 
1fd7ba
2.30.2
1fd7ba
1fd7ba
1fd7ba
From f4c061f349188c548497607efd4622c6e6a43270 Mon Sep 17 00:00:00 2001
1fd7ba
From: Chih-Wei Huang <cwhuang@linux.org.tw>
1fd7ba
Date: Mon, 14 Jun 2021 13:08:08 +0800
1fd7ba
Subject: [PATCH 27/28] control: remap - fix an infinite recursive call in the
1fd7ba
 async callback
1fd7ba
1fd7ba
The function snd_ctl_remap_async will call itself infinitely. Looks like
1fd7ba
a typo.
1fd7ba
1fd7ba
Fixes: a64391a42 ("control: remap plugin - initial version")
1fd7ba
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
1fd7ba
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1fd7ba
---
1fd7ba
 src/control/control_remap.c | 2 +-
1fd7ba
 1 file changed, 1 insertion(+), 1 deletion(-)
1fd7ba
1fd7ba
diff --git a/src/control/control_remap.c b/src/control/control_remap.c
1fd7ba
index 17c6558a..a85c1725 100644
1fd7ba
--- a/src/control/control_remap.c
1fd7ba
+++ b/src/control/control_remap.c
1fd7ba
@@ -323,7 +323,7 @@ static int snd_ctl_remap_nonblock(snd_ctl_t *ctl, int nonblock)
1fd7ba
 static int snd_ctl_remap_async(snd_ctl_t *ctl, int sig, pid_t pid)
1fd7ba
 {
1fd7ba
 	snd_ctl_remap_t *priv = ctl->private_data;
1fd7ba
-	return snd_ctl_remap_async(priv->child, sig, pid);
1fd7ba
+	return snd_ctl_async(priv->child, sig, pid);
1fd7ba
 }
1fd7ba
 
1fd7ba
 static int snd_ctl_remap_subscribe_events(snd_ctl_t *ctl, int subscribe)
1fd7ba
-- 
1fd7ba
2.30.2
1fd7ba
1fd7ba