From 4522e2008f675f2c53524edb3d61959dae1e6d8e Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 18 May 2021 10:57:17 +0200 Subject: [PATCH] conf: fix snd_config_merge() - merge schema All child compounds must be traversed and merged. Signed-off-by: Jaroslav Kysela --- src/conf.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/conf.c b/src/conf.c index 857f7181..1a526a2d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -2180,7 +2180,10 @@ int snd_config_add_before(snd_config_t *before, snd_config_t *child) * \return Zero if successful, otherwise a negative error code. * * This function merges all fields from the source compound to the destination compound. - * When the overwrite flag is set, the related subtree in dst is replaced from src. + * When the \a override flag is set, the related subtree in \a dst is replaced from \a src. + * + * When \a override is not set, the child compounds are traversed and merged. The configuration + * elements other than compounds are always substituted (overwritten) from the \a src tree. * * The src compound is deleted. * @@ -2207,11 +2210,17 @@ int snd_config_merge(snd_config_t *dst, snd_config_t *src, int override) snd_config_for_each(di, dnext, dst) { snd_config_t *dn = snd_config_iterator_entry(di); if (strcmp(sn->id, dn->id) == 0) { - if (override) { + if (override || + sn->type != SND_CONFIG_TYPE_COMPOUND || + dn->type != SND_CONFIG_TYPE_COMPOUND) { snd_config_remove(sn); err = snd_config_substitute(dn, sn); if (err < 0) return err; + } else { + err = snd_config_merge(dn, sn, 0); + if (err < 0) + return err; } found = true; break; -- 2.47.1