alsa/0044-topology-add-snd_tplg_create-with-flags.patch

110 lines
3.0 KiB
Diff
Raw Normal View History

Accepting request 766329 from home:tiwai:branches:multimedia:libs - Backport upstream fixes: more topology fixes, a memory leak fix in mixer API, alsactl string handling fix, UCM config fixes: 0032-Update-the-attributes.m4-macro-file-from-xine.patch 0033-topology-avoid-to-use-the-atoi-directly-when-expecte.patch 0034-topology-use-snd_config_get_bool-instead-own-impleme.patch 0035-topology-fix-tplg_get_integer-handle-errno-ERANGE.patch 0036-topology-add-tplg_get_unsigned-function.patch 0037-topology-convert-builder-to-use-the-mallocated-memor.patch 0038-topology-add-binary-output-from-the-builder.patch 0039-topology-parser-recode-tplg_parse_config.patch 0040-topology-add-snd_tplg_load-remove-snd_tplg_build_bin.patch 0041-topology-move-the-topology-element-table-from-builde.patch 0042-topology-add-parser-to-the-tplg_table.patch 0043-topology-add-snd_tplg_save.patch 0044-topology-add-snd_tplg_create-with-flags.patch 0045-topology-add-snd_tplg_version-function.patch 0046-topology-cleanup-the-SNDERR-calls.patch 0047-topology-dapm-fix-the-SNDERR-Undefined.patch 0048-topology-fix-the-unitialized-tuples.patch 0049-topology-implement-shorter-hexa-uuid-00-00-parser.patch 0050-topology-fix-the-TPLG_DEBUG-compilation.patch 0051-topology-fix-the-ops-parser-accept-integer-hexa-valu.patch 0052-topology-fix-the-wrong-memory-access-object-realloc.patch 0053-topology-implement-snd_tplg_decode.patch 0054-topology-move-the-elem-list-delete-to-tplg_elem_free.patch 0055-topology-unify-the-log-mechanism.patch 0056-topology-tplg_dbg-cleanups.patch 0057-topology-cosmetic-changes-functions.patch 0058-mixer-Fix-memory-leak-for-more-than-16-file-descript.patch OBS-URL: https://build.opensuse.org/request/show/766329 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=265
2020-01-22 14:27:43 +00:00
From b336aea507b80493cdae439f09f710eec4bcd4ae Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Fri, 20 Dec 2019 14:59:00 +0100
Subject: [PATCH 44/63] topology: add snd_tplg_create() with flags
Add SND_TPLG_CREATE_VERBOSE and SND_TPLG_CREATE_DAPM_NOSORT
flags for the special operations.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
include/topology.h | 10 ++++++++++
src/topology/dapm.c | 5 ++++-
src/topology/parser.c | 10 +++++++++-
src/topology/tplg_local.h | 1 +
4 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/include/topology.h b/include/topology.h
index 69aa5ed733e3..63c13a9885e9 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -771,12 +771,22 @@ enum snd_tplg_type {
/** Fit for all user cases */
#define SND_TPLG_INDEX_ALL 0
+/** Flags for the snd_tplg_create */
+#define SND_TPLG_CREATE_VERBOSE (1<<0) /*!< Verbose output */
+#define SND_TPLG_CREATE_DAPM_NOSORT (1<<1) /*!< Do not sort DAPM objects by index */
+
/**
* \brief Create a new topology parser instance.
* \return New topology parser instance
*/
snd_tplg_t *snd_tplg_new(void);
+/**
+ * \brief Create a new topology parser instance.
+ * \return New topology parser instance
+ */
+snd_tplg_t *snd_tplg_create(int flags);
+
/**
* \brief Free a topology parser instance.
* \param tplg Topology parser instance
diff --git a/src/topology/dapm.c b/src/topology/dapm.c
index 2bdacedca125..d6c15fc1dfaa 100644
--- a/src/topology/dapm.c
+++ b/src/topology/dapm.c
@@ -268,7 +268,10 @@ struct tplg_elem *tplg_elem_new_route(snd_tplg_t *tplg, int index)
return NULL;
elem->index = index;
- tplg_elem_insert(elem, &tplg->route_list);
+ if (tplg->dapm_sort)
+ tplg_elem_insert(elem, &tplg->route_list);
+ else
+ list_add_tail(&elem->list, &tplg->route_list);
strcpy(elem->id, "line");
elem->type = SND_TPLG_TYPE_DAPM_GRAPH;
elem->size = sizeof(*line);
diff --git a/src/topology/parser.c b/src/topology/parser.c
index de5edd1b6591..8f810f751533 100644
--- a/src/topology/parser.c
+++ b/src/topology/parser.c
@@ -432,7 +432,7 @@ static bool is_little_endian(void)
return false;
}
-snd_tplg_t *snd_tplg_new(void)
+snd_tplg_t *snd_tplg_create(int flags)
{
snd_tplg_t *tplg;
@@ -445,6 +445,9 @@ snd_tplg_t *snd_tplg_new(void)
if (!tplg)
return NULL;
+ tplg->verbose = !!(flags & SND_TPLG_CREATE_VERBOSE);
+ tplg->dapm_sort = (flags & SND_TPLG_CREATE_DAPM_NOSORT) == 0;
+
tplg->manifest.size = sizeof(struct snd_soc_tplg_manifest);
INIT_LIST_HEAD(&tplg->tlv_list);
@@ -469,6 +472,11 @@ snd_tplg_t *snd_tplg_new(void)
return tplg;
}
+snd_tplg_t *snd_tplg_new(void)
+{
+ return snd_tplg_create(0);
+}
+
void snd_tplg_free(snd_tplg_t *tplg)
{
free(tplg->bin);
diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
index 42a3aa96ba0e..74b3a55cada4 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -66,6 +66,7 @@ struct snd_tplg {
size_t bin_size;
int verbose;
+ unsigned int dapm_sort: 1;
unsigned int version;
/* runtime state */
--
2.16.4