Blame SOURCES/alsa-git.patch

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