]> git.alsa-project.org Git - alsa-lib.git/commitdiff
conf: fix snd_config_merge() - merge schema
authorJaroslav Kysela <perex@perex.cz>
Tue, 18 May 2021 08:57:17 +0000 (10:57 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 18 May 2021 09:30:15 +0000 (11:30 +0200)
All child compounds must be traversed and merged.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/conf.c

index 857f7181596d0a3ff9268e79d422e10902ee886a..1a526a2d62d6b7f967eaa934dca4c04c744c8fb5 100644 (file)
@@ -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;