Blame SOURCES/alsa-git.patch

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