]> git.alsa-project.org Git - alsa-lib.git/commitdiff
control: remap - assign right name to the child handle for no-op (2nd case)
authorJaroslav Kysela <perex@perex.cz>
Tue, 29 Jun 2021 17:31:28 +0000 (19:31 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 29 Jun 2021 17:31:35 +0000 (19:31 +0200)
Fixes: https://github.com/alsa-project/alsa-utils/issues/100
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/control/control_remap.c

index 81524014aca5caa26da23d4840dec455bce6fd3c..4914f9607414725356bae312006debee55d7cd49 100644 (file)
@@ -1154,6 +1154,10 @@ int snd_ctl_remap_open(snd_ctl_t **handlep, const char *name, snd_config_t *rema
        snd_ctl_t *ctl;
        int result, err;
 
+       /* no-op, remove the plugin */
+       if (!remap && !map)
+               goto _noop;
+
        priv = calloc(1, sizeof(*priv));
        if (priv == NULL)
                return -ENOMEM;
@@ -1173,6 +1177,7 @@ int snd_ctl_remap_open(snd_ctl_t **handlep, const char *name, snd_config_t *rema
        /* no-op check, remove the plugin */
        if (priv->map_items == 0 && priv->remap_items == 0) {
                remap_free(priv);
+ _noop:
                free(child->name);
                child->name = name ? strdup(name) : NULL;
                if (name && !child->name)
@@ -1316,11 +1321,6 @@ int _snd_ctl_remap_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd
        err = _snd_ctl_open_child(&cctl, root, child, mode, conf);
        if (err < 0)
                return err;
-       /* no-op, remove the plugin */
-       if (!remap && !map) {
-               *handlep = cctl;
-               return 0;
-       }
        err = snd_ctl_remap_open(handlep, name, remap, map, cctl, mode);
        if (err < 0)
                snd_ctl_close(cctl);