OSDN Git Service

Extended parameterization. Marked with @ all fields with special use
authorAbramo Bagnara <abramo@alsa-project.org>
Fri, 15 Jun 2001 14:00:19 +0000 (14:00 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Fri, 15 Jun 2001 14:00:19 +0000 (14:00 +0000)
16 files changed:
aserver/aserver.c
include/conf.h
src/alsa.conf
src/cards/EMU10K1.conf
src/cards/SI_7018.conf
src/conf.c
src/confmisc.c
src/control/control.c
src/control/control_shm.c
src/pcm/pcm.c
src/pcm/pcm_hooks.c
src/pcm/pcm_meter.c
src/pcm/pcm_share.c
src/pcm/pcm_shm.c
src/rawmidi/rawmidi.c
src/seq/seq.c

index 793f7e4..68fdf5d 100644 (file)
@@ -975,7 +975,7 @@ int main(int argc, char **argv)
                return 1;
        }
        srvname = argv[optind];
-       err = snd_config_search_alias(snd_config, "server", srvname, &conf);
+       err = snd_config_search_definition(snd_config, "server", srvname, &conf);
        if (err < 0) {
                ERROR("Missing definition for server %s", srvname);
                return 1;
index 3dec818..12c115f 100644 (file)
@@ -34,9 +34,9 @@ int snd_config_search(snd_config_t *config, const char *key,
                      snd_config_t **result);
 int snd_config_searchv(snd_config_t *config, 
                       snd_config_t **result, ...);
-int snd_config_search_alias(snd_config_t *config,
-                           const char *base, const char *key,
-                           snd_config_t **result);
+int snd_config_search_definition(snd_config_t *config,
+                                const char *base, const char *key,
+                                snd_config_t **result);
 
 int snd_config_expand(snd_config_t *config, const char *args,
                      void *private_data, snd_config_t **result);
index d15cc27..ef984de 100644 (file)
@@ -7,14 +7,14 @@
 #
 
 pcm.hw {
-       args [ CARD DEV SUBDEV ]
-       args.CARD {
+       @args [ CARD DEV SUBDEV ]
+       @args.CARD {
                type integer
        }
-       args.DEV {
+       @args.DEV {
                type integer
        }
-       args.SUBDEV {
+       @args.SUBDEV {
                type integer
                default -1
        }               
@@ -25,14 +25,14 @@ pcm.hw {
 }
 
 pcm.plughw {
-       args [ CARD DEV SUBDEV ]
-       args.CARD {
+       @args [ CARD DEV SUBDEV ]
+       @args.CARD {
                type integer
        }
-       args.DEV {
+       @args.DEV {
                type integer
        }
-       args.SUBDEV {
+       @args.SUBDEV {
                type integer
                default -1
        }               
@@ -46,8 +46,8 @@ pcm.plughw {
 }
 
 pcm.plug {
-       args [ SLAVE ]
-       args.SLAVE {
+       @args [ SLAVE ]
+       @args.SLAVE {
                type string
        }
        type plug
@@ -55,11 +55,11 @@ pcm.plug {
 }
 
 pcm.shm {
-       args [ SOCKET PCM ]
-       args.SOCKET {
+       @args [ SOCKET PCM ]
+       @args.SOCKET {
                type string
        }
-       args.PCM {
+       @args.PCM {
                type string
        }
        type shm
@@ -68,14 +68,14 @@ pcm.shm {
 }
 
 pcm.tee {
-       args [ SLAVE FILE FORMAT ]
-       args.SLAVE {
+       @args [ SLAVE FILE FORMAT ]
+       @args.SLAVE {
                type string
        }
-       args.FILE {
+       @args.FILE {
                type string
        }
-       args.FORMAT {
+       @args.FORMAT {
                type string
                default raw
        }
@@ -86,11 +86,11 @@ pcm.tee {
 }
 
 pcm.file {
-       args [ FILE FORMAT ]
-       args.FILE {
+       @args [ FILE FORMAT ]
+       @args.FILE {
                type string
        }
-       args.FORMAT {
+       @args.FORMAT {
                type string
                default raw
        }
@@ -130,8 +130,8 @@ pcm.default {
 }
 
 pcm.front {
-       args [ CARD DEV ]
-       args.CARD {
+       @args [ CARD DEV ]
+       @args.CARD {
                type integer
                default {
                        @func getenv
@@ -144,7 +144,7 @@ pcm.front {
                        default 0
                }
        }
-       args.DEV {
+       @args.DEV {
                type integer
                default {
                        @func getenv
@@ -155,7 +155,7 @@ pcm.front {
                        default 0
                }
        }
-       refer {
+       @refer {
                filename {
                        @func concat
                        strings [
@@ -180,8 +180,8 @@ pcm.front {
 }
        
 pcm.rear {
-       args [ CARD DEV ]
-       args.CARD {
+       @args [ CARD DEV ]
+       @args.CARD {
                type integer
                default {
                        @func getenv
@@ -194,7 +194,7 @@ pcm.rear {
                        default 0
                }
        }
-       args.DEV {
+       @args.DEV {
                type integer
                default {
                        @func getenv
@@ -205,7 +205,7 @@ pcm.rear {
                        default 0
                }
        }
-       refer {
+       @refer {
                filename {
                        @func concat
                        strings [
@@ -230,8 +230,8 @@ pcm.rear {
 }
        
 pcm.center_lfe {
-       args [ CARD DEV ]
-       args.CARD {
+       @args [ CARD DEV ]
+       @args.CARD {
                type integer
                default {
                        @func getenv
@@ -244,7 +244,7 @@ pcm.center_lfe {
                        default 0
                }
        }
-       args.DEV {
+       @args.DEV {
                type integer
                default {
                        @func getenv
@@ -255,7 +255,7 @@ pcm.center_lfe {
                        default 0
                }
        }
-       refer {
+       @refer {
                filename {
                        @func concat
                        strings [
@@ -280,8 +280,8 @@ pcm.center_lfe {
 }
        
 pcm.surround40 {
-       args [ CARD DEV ]
-       args.CARD {
+       @args [ CARD DEV ]
+       @args.CARD {
                type integer
                default {
                        @func getenv
@@ -294,7 +294,7 @@ pcm.surround40 {
                        default 0
                }
        }
-       args.DEV {
+       @args.DEV {
                type integer
                default {
                        @func getenv
@@ -305,7 +305,7 @@ pcm.surround40 {
                        default 0
                }
        }
-       refer {
+       @refer {
                filename {
                        @func concat
                        strings [
@@ -330,8 +330,8 @@ pcm.surround40 {
 }
        
 pcm.surround51 {
-       args [ CARD DEV ]
-       args.CARD {
+       @args [ CARD DEV ]
+       @args.CARD {
                type integer
                default {
                        @func getenv
@@ -344,7 +344,7 @@ pcm.surround51 {
                        default 0
                }
        }
-       args.DEV {
+       @args.DEV {
                type integer
                default {
                        @func getenv
@@ -355,7 +355,7 @@ pcm.surround51 {
                        default 0
                }
        }
-       refer {
+       @refer {
                filename {
                        @func concat
                        strings [
@@ -380,8 +380,8 @@ pcm.surround51 {
 }
        
 pcm.iec958 {
-       args [ CARD DEV AES0 AES1 AES2 AES3 ]
-       args.CARD {
+       @args [ CARD DEV AES0 AES1 AES2 AES3 ]
+       @args.CARD {
                type integer
                default {
                        @func getenv
@@ -394,7 +394,7 @@ pcm.iec958 {
                        default 0
                }
        }
-       args.DEV {
+       @args.DEV {
                type integer
                default {
                        @func getenv
@@ -405,27 +405,27 @@ pcm.iec958 {
                        default 0
                }
        }
-       args.AES0 {
+       @args.AES0 {
                type integer
                # consumer, not-copyright, emphasis-none, mode=0
                default 0x04
        }
-       args.AES1 {
+       @args.AES1 {
                type integer
                # original, PCM coder
                default 0x82
        }
-       args.AES2 {
+       @args.AES2 {
                type integer
                # source and channel
                default 0x00
        }
-       args.AES3 {
+       @args.AES3 {
                type integer
                # fs=48000Hz, clock accuracy=1000ppm
                default 0x02
        }
-       refer {
+       @refer {
                filename {
                        @func concat
                        strings [
@@ -461,8 +461,8 @@ pcm.spdif pcm.iec958
 #
        
 ctl.hw {
-       args[ CARD ]
-       args.CARD {
+       @args[ CARD ]
+       @args.CARD {
                type integer
        }
        type hw
@@ -470,11 +470,11 @@ ctl.hw {
 }
 
 ctl.shm {
-       args [ SOCKET CTL ]
-       args.SOCKET {
+       @args [ SOCKET CTL ]
+       @args.SOCKET {
                type string
        }
-       args.CTL {
+       @args.CTL {
                type string
        }
        type shm
@@ -498,14 +498,14 @@ ctl.default {
 #
 
 rawmidi.hw {
-       args [ CARD DEV SUBDEV ]
-       args.CARD {
+       @args [ CARD DEV SUBDEV ]
+       @args.CARD {
                type integer
        }
-       args.DEV {
+       @args.DEV {
                type integer
        }
-       args.SUBDEV {
+       @args.SUBDEV {
                type integer
                default -1
        }
index 16e6b06..e89202b 100644 (file)
@@ -3,14 +3,14 @@
 #
 
 pcm.emu10k1_front {
-       args [ CARD DEV SUBDEV ]
-       args.CARD {
+       @args [ CARD DEV SUBDEV ]
+       @args.CARD {
                type integer
        }
-       args.DEV {
+       @args.DEV {
                type integer
        }
-       args.SUBDEV {
+       @args.SUBDEV {
                type integer
                default -1
        }
@@ -21,25 +21,25 @@ pcm.emu10k1_front {
 }      
 
 pcm.front_0 {
-       args [ CARD ]
-       args.CARD {
+       @args [ CARD ]
+       @args.CARD {
                type integer
        }
-       refer {
+       @refer {
                @func concat
                strings [ "pcm.emu10k1_front:" $(CARD) ",0,-1" ]
        }
 }
 
 pcm.emu10k1_rear {
-       args [ CARD DEV SUBDEV ]
-       args.CARD {
+       @args [ CARD DEV SUBDEV ]
+       @args.CARD {
                type integer
        }
-       args.DEV {
+       @args.DEV {
                type integer
        }
-       args.SUBDEV {
+       @args.SUBDEV {
                type integer
                default -1
        }
@@ -70,25 +70,25 @@ pcm.emu10k1_rear {
 }      
 
 pcm.rear_0 {
-       args [ CARD ]
-       args.CARD {
+       @args [ CARD ]
+       @args.CARD {
                type integer
        }
-       refer {
+       @refer {
                @func concat
                strings [ "pcm.emu10k1_rear:" $(CARD) ",0,-1" ]
        }
 }
 
 pcm.emu10k1_center_lfe {
-       args [ CARD DEV SUBDEV ]
-       args.CARD {
+       @args [ CARD DEV SUBDEV ]
+       @args.CARD {
                type integer
        }
-       args.DEV {
+       @args.DEV {
                type integer
        }
-       args.SUBDEV {
+       @args.SUBDEV {
                type integer
                default -1
        }
@@ -131,19 +131,19 @@ pcm.emu10k1_center_lfe {
 }      
 
 pcm.center_lfe_0 {
-       args [ CARD ]
-       args.CARD {
+       @args [ CARD ]
+       @args.CARD {
                type integer
        }
-       refer {
+       @refer {
                @func concat
                strings [ "pcm.emu10k1_center_lfe:" $(CARD) ",0,-1" ]
        }
 }
 
 pcm.surround40_0 {
-       args [ CARD ]
-       args.CARD {
+       @args [ CARD ]
+       @args.CARD {
                type integer
        }
        type multi
@@ -176,8 +176,8 @@ pcm.surround40_0 {
 }
 
 pcm.surround51_0 {
-       args [ CARD ]
-       args.CARD {
+       @args [ CARD ]
+       @args.CARD {
                type integer
        }
        type multi
@@ -221,23 +221,23 @@ pcm.surround51_0 {
 }
 
 pcm.iec958_0 {
-       args [ CARD DEV AES0 AES1 AES2 AES3 ]
-       args.CARD {
+       @args [ CARD DEV AES0 AES1 AES2 AES3 ]
+       @args.CARD {
                type integer
        }
-       args.DEV {
+       @args.DEV {
                type integer
        }
-       args.AES0 {
+       @args.AES0 {
                type integer
        }
-       args.AES1 {
+       @args.AES1 {
                type integer
        }
-       args.AES2 {
+       @args.AES2 {
                type integer
        }
-       args.AES3 {
+       @args.AES3 {
                type integer
        }
        type hooks
index 799768c..5b29343 100644 (file)
@@ -3,14 +3,14 @@
 #
 
 pcm.si7018_front {
-       args [ CARD DEV SUBDEV ]
-       args.CARD {
+       @args [ CARD DEV SUBDEV ]
+       @args.CARD {
                type integer
        }
-       args.DEV {
+       @args.DEV {
                type integer
        }
-       args.SUBDEV {
+       @args.SUBDEV {
                type integer
                default -1
        }
@@ -21,8 +21,8 @@ pcm.si7018_front {
 }      
 
 pcm.front_0 {
-       args [ CARD ]
-       args.CARD {
+       @args [ CARD ]
+       @args.CARD {
                type integer
        }
        redir {
@@ -32,14 +32,14 @@ pcm.front_0 {
 }
 
 pcm.si7010_rear {
-       args [ CARD DEV SUBDEV ]
-       args.CARD {
+       @args [ CARD DEV SUBDEV ]
+       @args.CARD {
                type integer
        }
-       args.DEV {
+       @args.DEV {
                type integer
        }
-       args.SUBDEV {
+       @args.SUBDEV {
                type integer
                default -1
        }
@@ -50,8 +50,8 @@ pcm.si7010_rear {
 }      
 
 pcm.rear_0 {
-       args [ CARD ]
-       args.CARD {
+       @args [ CARD ]
+       @args.CARD {
                type integer
        }
        redir {
@@ -61,8 +61,8 @@ pcm.rear_0 {
 }
 
 pcm.surround40_0 {
-       args [ CARD ]
-       args.CARD {
+       @args [ CARD ]
+       @args.CARD {
                type integer
        }
        type multi
index 17244a8..e7e58af 100644 (file)
@@ -1788,7 +1788,7 @@ static int _snd_config_expand(snd_config_t *src,
        switch (pass) {
        case SND_CONFIG_WALK_PASS_PRE:
        {
-               if (strcmp(id, "args") == 0)
+               if (strcmp(id, "@args") == 0)
                        return 0;
                err = snd_config_make_compound(dst, id, src->u.compound.join);
                if (err < 0)
@@ -2439,7 +2439,7 @@ int snd_config_expand(snd_config_t *config, const char *args,
 {
        int err;
        snd_config_t *defs, *subs = NULL, *res;
-       err = snd_config_search(config, "args", &defs);
+       err = snd_config_search(config, "@args", &defs);
        if (err < 0) {
                err = snd_config_copy(&res, config);
                if (err < 0)
@@ -2478,6 +2478,43 @@ int snd_config_expand(snd_config_t *config, const char *args,
        return err;
 }
        
+/**
+ * \brief Search a node inside a config tree using alias
+ * \param config Config node handle
+ * \param base Key base (or NULL)
+ * \param key Key suffix
+ * \param result Pointer to expanded found node
+ * \return 0 on success otherwise a negative error code
+ *
+ * First key is tried and if nothing is found is tried base.key.
+ * If the value found is a string this is recursively tried in the
+ * same way.
+ */
+int snd_config_search_definition(snd_config_t *config,
+                                const char *base, const char *name,
+                                snd_config_t **result)
+{
+       snd_config_t *conf;
+       char *key;
+       const char *args = strchr(name, ':');
+       int err;
+       if (args) {
+               args++;
+               key = alloca(args - name);
+               memcpy(key, name, args - name - 1);
+               key[args - name - 1] = '\0';
+       } else {
+               key = (char *) base;
+       } 
+       err = snd_config_search_alias(config, base, key, &conf);
+       if (err < 0)
+               return err;
+       err = snd_config_expand(conf, args, NULL, result);
+       if (err < 0)
+               return err;
+       
+}
+
 
 #if 0
 /* Not strictly needed, but useful to check for memory leaks */
index 5684070..96356a6 100644 (file)
@@ -303,14 +303,14 @@ int snd_config_refer_load(snd_config_t *root,
  *  Helper functions for the configuration file
  */
 
-int snd_func_getenv(snd_config_t **dst, snd_config_t *src, void *private_data ATTRIBUTE_UNUSED)
+int snd_func_getenv(snd_config_t **dst, snd_config_t *src, void *private_data)
 {
        snd_config_t *n, *d, *e;
        snd_config_iterator_t i, next;
        char *res, *def = NULL;
        int idx = 0, err;
        
-       err = snd_config_expand(src, NULL, NULL, &e);
+       err = snd_config_expand(src, NULL, private_data, &e);
        if (err < 0)
                return err;
        err = snd_config_search(e, "envname", &n);
@@ -373,14 +373,14 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *src, void *private_data AT
        return err;
 }
 
-int snd_func_concat(snd_config_t **dst, snd_config_t *src, void *private_data ATTRIBUTE_UNUSED)
+int snd_func_concat(snd_config_t **dst, snd_config_t *src, void *private_data)
 {
        snd_config_t *n, *e;
        snd_config_iterator_t i, next;
        char *res = NULL, *tmp;
        int idx = 0, len = 0, len1, err;
        
-       err = snd_config_expand(src, NULL, NULL, &e);
+       err = snd_config_expand(src, NULL, private_data, &e);
        if (err < 0)
                return err;
        err = snd_config_search(e, "strings", &n);
@@ -464,7 +464,7 @@ static int string_from_integer(char **dst, long v)
 }
 #endif
 
-int snd_func_card_strtype(snd_config_t **dst, snd_config_t *src, void *private_data ATTRIBUTE_UNUSED)
+int snd_func_card_strtype(snd_config_t **dst, snd_config_t *src, void *private_data)
 {
        snd_config_t *n, *e;
        char *res = NULL;
@@ -473,7 +473,7 @@ int snd_func_card_strtype(snd_config_t **dst, snd_config_t *src, void *private_d
        long v;
        int err;
        
-       err = snd_config_expand(src, NULL, NULL, &e);
+       err = snd_config_expand(src, NULL, private_data, &e);
        if (err < 0)
                return err;
        err = snd_config_search(e, "card", &n);
@@ -513,7 +513,7 @@ int snd_func_card_strtype(snd_config_t **dst, snd_config_t *src, void *private_d
        return err;
 }
 
-int snd_func_card_id(snd_config_t **dst, snd_config_t *src, void *private_data ATTRIBUTE_UNUSED)
+int snd_func_card_id(snd_config_t **dst, snd_config_t *src, void *private_data)
 {
        snd_config_t *n, *e;
        char *res = NULL;
@@ -522,7 +522,7 @@ int snd_func_card_id(snd_config_t **dst, snd_config_t *src, void *private_data A
        long v;
        int err;
        
-       err = snd_config_expand(src, NULL, NULL, &e);
+       err = snd_config_expand(src, NULL, private_data, &e);
        if (err < 0)
                return err;
        err = snd_config_search(e, "card", &n);
@@ -562,7 +562,7 @@ int snd_func_card_id(snd_config_t **dst, snd_config_t *src, void *private_data A
        return err;
 }
 
-int snd_func_pcm_id(snd_config_t **dst, snd_config_t *src, void *private_data ATTRIBUTE_UNUSED)
+int snd_func_pcm_id(snd_config_t **dst, snd_config_t *src, void *private_data)
 {
        snd_config_t *n, *e;
        char *res = NULL;
@@ -571,7 +571,7 @@ int snd_func_pcm_id(snd_config_t **dst, snd_config_t *src, void *private_data AT
        long card, device, subdevice = 0;
        int err;
        
-       err = snd_config_expand(src, NULL, NULL, &e);
+       err = snd_config_expand(src, NULL, private_data, &e);
        if (err < 0)
                return err;
        err = snd_config_search(e, "card", &n);
index 71b45a6..75ce33d 100644 (file)
@@ -408,11 +408,11 @@ int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
                SNDERR("Invalid type for %s", snd_config_get_id(conf));
                return err;
        }
-       err = snd_config_search_alias(snd_config, "ctl_type", str, &type_conf);
+       err = snd_config_search_definition(snd_config, "ctl_type", str, &type_conf);
        if (err >= 0) {
                if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for CTL type %s definition", str);
-                       return -EINVAL;
+                       goto _err;
                }
                snd_config_for_each(i, next, type_conf) {
                        snd_config_t *n = snd_config_iterator_entry(i);
@@ -423,7 +423,7 @@ int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
                                err = snd_config_get_string(n, &lib);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err;
                                }
                                continue;
                        }
@@ -431,11 +431,13 @@ int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
                                err = snd_config_get_string(n, &open_name);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err;
                                }
                                continue;
                        }
                        SNDERR("Unknown field %s", id);
+               _err:
+                       snd_config_delete(type_conf);
                        return -EINVAL;
                }
        }
@@ -446,11 +448,14 @@ int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
        if (!lib)
                lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
+       if (h)
+               open_func = dlsym(h, open_name);
+       if (type_conf)
+               snd_config_delete(type_conf);
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
                return -ENOENT;
        }
-       open_func = dlsym(h, open_name);
        if (!open_func) {
                SNDERR("symbol %s is not defined inside %s", open_name, lib);
                dlclose(h);
@@ -463,42 +468,9 @@ int snd_ctl_open_noupdate(snd_ctl_t **ctlp, snd_config_t *root, const char *name
 {
        int err;
        snd_config_t *ctl_conf;
-       char *base, *key;
-       const char *args = strchr(name, ':');
-
-       if (args) {
-               args++;
-               base = alloca(args - name);
-               memcpy(base, name, args - name - 1);
-               base[args - name - 1] = '\0';
-               key = strchr(base, '.');
-               if (key)
-                       *key++ = '\0';
-       } else {
-               key = strchr(name, '.');
-               if (key) {
-                       key++;
-                       base = alloca(key - name);
-                       memcpy(base, name, key - name - 1);
-                       base[key - name - 1] = '\0';
-               } else
-                       base = (char *) name;
-       }
-       if (key == NULL) {
-               key = base;
-               base = NULL;
-       }
-       err = snd_config_search_alias(root, base, key, &ctl_conf);
-       if (err < 0) {
-               (void)(base == NULL && (err = snd_config_search_alias(root, "ctl", key, &ctl_conf)));
-               if (err < 0) {
-                       SNDERR("Unknown PCM %s", name);
-                       return err;
-               }
-       }
-       err = snd_config_expand(ctl_conf, args, NULL, &ctl_conf);
+       err = snd_config_search_definition(root, "ctl", name, &ctl_conf);
        if (err < 0) {
-               SNDERR("Could not expand configuration for %s: %s", name, snd_strerror(err));
+               SNDERR("Invalid CTL %s", name);
                return err;
        }
        err = snd_ctl_open_conf(ctlp, name, ctl_conf, mode);
index 6554d08..04875b0 100644 (file)
@@ -570,14 +570,14 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf, int m
                SNDERR("server is not defined");
                return -EINVAL;
        }
-       err = snd_config_search_alias(snd_config, "server", server, &sconfig);
+       err = snd_config_search_definition(snd_config, "server", server, &sconfig);
        if (err < 0) {
                SNDERR("Unknown server %s", server);
                return -EINVAL;
        }
        if (snd_config_get_type(sconfig) != SND_CONFIG_TYPE_COMPOUND) {
                SNDERR("Invalid type for server %s definition", server);
-               return -EINVAL;
+               goto _err;
        }
        snd_config_for_each(i, next, conf) {
                snd_config_t *n = snd_config_iterator_entry(i);
@@ -588,7 +588,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf, int m
                        err = snd_config_get_string(n, &host);
                        if (err < 0) {
                                SNDERR("Invalid type for %s", id);
-                               return -EINVAL;
+                               goto _err;
                        }
                        continue;
                }
@@ -596,7 +596,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf, int m
                        err = snd_config_get_string(n, &sockname);
                        if (err < 0) {
                                SNDERR("Invalid type for %s", id);
-                               return -EINVAL;
+                               goto _err;
                        }
                        continue;
                }
@@ -604,32 +604,36 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf, int m
                        err = snd_config_get_integer(n, &port);
                        if (err < 0) {
                                SNDERR("Invalid type for %s", id);
-                               return -EINVAL;
+                               goto _err;
                        }
                        continue;
                }
                SNDERR("Unknown field %s", id);
+       _err:
+               snd_config_delete(sconfig);
                return -EINVAL;
        }
 
        if (!host) {
                SNDERR("host is not defined");
-               return -EINVAL;
+               goto _err;
        }
        if (!sockname) {
                SNDERR("socket is not defined");
-               return -EINVAL;
+               goto _err;
        }
        h = gethostbyname(host);
        if (!h) {
                SNDERR("Cannot resolve %s", host);
-               return -EINVAL;
+               goto _err;
        }
        local = is_local(h);
        if (!local) {
                SNDERR("%s is not the local host", host);
-               return -EINVAL;
+               goto _err;
        }
-       return snd_ctl_shm_open(handlep, name, sockname, ctl_name, mode);
+       err = snd_ctl_shm_open(handlep, name, sockname, ctl_name, mode);
+       snd_config_delete(sconfig);
+       return err;
 }
                                
index 9478c0f..393d7c0 100644 (file)
@@ -942,11 +942,11 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
                SNDERR("Invalid type for %s", snd_config_get_id(conf));
                return err;
        }
-       err = snd_config_search_alias(snd_config, "pcm_type", str, &type_conf);
+       err = snd_config_search_definition(snd_config, "pcm_type", str, &type_conf);
        if (err >= 0) {
                if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for PCM type %s definition", str);
-                       return -EINVAL;
+                       goto _err;
                }
                snd_config_for_each(i, next, type_conf) {
                        snd_config_t *n = snd_config_iterator_entry(i);
@@ -957,7 +957,7 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
                                err = snd_config_get_string(n, &lib);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err;
                                }
                                continue;
                        }
@@ -965,11 +965,13 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
                                err = snd_config_get_string(n, &open_name);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err;
                                }
                                continue;
                        }
                        SNDERR("Unknown field %s", id);
+               _err:
+                       snd_config_delete(type_conf);
                        return -EINVAL;
                }
        }
@@ -980,11 +982,14 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
        if (!lib)
                lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
+       if (h)
+               open_func = dlsym(h, open_name);
+       if (type_conf)
+               snd_config_delete(type_conf);
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
                return -ENOENT;
        }
-       open_func = dlsym(h, open_name);
        if (!open_func) {
                SNDERR("symbol %s is not defined inside %s", open_name, lib);
                dlclose(h);
@@ -1000,43 +1005,10 @@ static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, snd_config_t *root,
                                 const char *name, snd_pcm_stream_t stream, int mode)
 {
        int err;
-       snd_config_t *pcm_conf;
-       char *base, *key;
-       const char *args = strchr(name, ':');
-       snd_config_t *conf;
-       if (args) {
-               args++;
-               base = alloca(args - name);
-               memcpy(base, name, args - name - 1);
-               base[args - name - 1] = '\0';
-               key = strchr(base, '.');
-               if (key)
-                       *key++ = '\0';
-       } else {
-               key = strchr(name, '.');
-               if (key) {
-                       key++;
-                       base = alloca(key - name);
-                       memcpy(base, name, key - name - 1);
-                       base[key - name - 1] = '\0';
-               } else
-                       base = (char *) name;
-       }
-       if (key == NULL) {
-               key = base;
-               base = NULL;
-       }
-       err = snd_config_search_alias(root, base, key, &pcm_conf);
+       snd_config_t *pcm_conf, *conf;
+       err = snd_config_search_definition(root, "pcm", name, &pcm_conf);
        if (err < 0) {
-               (void)(base == NULL && (err = snd_config_search_alias(root, "pcm", key, &pcm_conf)));
-               if (err < 0) {
-                       SNDERR("Unknown PCM %s", name);
-                       return err;
-               }
-       }
-       err = snd_config_expand(pcm_conf, args, NULL, &pcm_conf);
-       if (err < 0) {
-               SNDERR("Could not expand configuration for %s: %s", name, snd_strerror(err));
+               SNDERR("Unknown PCM %s", name);
                return err;
        }
        if (snd_config_search(pcm_conf, "refer", &conf) >= 0) {
@@ -1044,8 +1016,7 @@ static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, snd_config_t *root,
                int conf_free_tmp;
                char *refer_name = NULL;
                err = snd_config_refer_load(root, conf, &refer_name, &tmp_conf, &conf_free_tmp);
-               if (args)
-                       snd_config_delete(pcm_conf);
+               snd_config_delete(pcm_conf);
                if (err < 0) {
                        SNDERR("Refer load error for %s: %s", name, snd_strerror(err));
                        return err;
@@ -4318,16 +4289,18 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
        unsigned int k;
        snd_config_t *pcm_conf = NULL;
        int err;
+       int to_free = 0;
        va_list args;
        assert(root);
        assert(conf);
        assert(_pcm_conf);
        if (snd_config_get_string(conf, &str) >= 0) {
-               err = snd_config_search_alias(conf, "pcm_slave", str, &conf);
+               err = snd_config_search_definition(root, "pcm_slave", str, &conf);
                if (err < 0) {
-                       SNDERR("Configuration pcm_slave.%s was not found\n", str);
+                       SNDERR("Invalid slave definition");
                        return -EINVAL;
                }
+               to_free = 1;
        }
        if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
                SNDERR("Invalid slave definition");
@@ -4365,12 +4338,13 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
                                if (err < 0) {
                                _invalid:
                                        SNDERR("invalid type for %s", id);
-                                       return err;
+                                       goto _err;
                                }
                                f = snd_pcm_format_value(str);
                                if (f == SND_PCM_FORMAT_UNKNOWN) {
                                        SNDERR("unknown format");
-                                       return -EINVAL;
+                                       err = -EINVAL;
+                                       goto _err;
                                }
                                *(snd_pcm_format_t*)fields[k].ptr = f;
                                break;
@@ -4388,20 +4362,27 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
                if (k < count)
                        continue;
                SNDERR("Unknown field %s", id);
-               // return -EINVAL;
+               err = -EINVAL;
+               goto _err;
        }
        if (!pcm_conf) {
                SNDERR("missing field pcm");
-               return -EINVAL;
+               err = -EINVAL;
+               goto _err;
        }
        for (k = 0; k < count; ++k) {
                if (fields[k].mandatory && !fields[k].valid) {
                        SNDERR("missing field %s", names[fields[k].index]);
-                       return -EINVAL;
+                       err = -EINVAL;
+                       goto _err;
                }
        }
        *_pcm_conf = pcm_conf;
        return 0;
+ _err:
+       if (to_free)
+               snd_config_delete(conf);
+       return err;
 }
                
 
index 3acaf22..5618cf4 100644 (file)
@@ -335,13 +335,6 @@ int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
        snd_config_iterator_t i, next;
        int (*install_func)(snd_pcm_t *pcm, snd_config_t *args);
        void *h;
-       if (snd_config_get_string(conf, &str) >= 0) {
-               err = snd_config_search_alias(snd_config, "pcm_hook", str, &conf);
-               if (err < 0) {
-                       SNDERR("unknown pcm_hook %s", str);
-                       return err;
-               }
-       }
        if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
                SNDERR("Invalid hook definition");
                return -EINVAL;
@@ -371,11 +364,11 @@ int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
                SNDERR("Invalid type for %s", snd_config_get_id(type));
                return err;
        }
-       err = snd_config_search_alias(snd_config, "pcm_hook_type", str, &type);
+       err = snd_config_search_definition(snd_config, "pcm_hook_type", str, &type);
        if (err >= 0) {
                if (snd_config_get_type(type) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for PCM type %s definition", str);
-                       return -EINVAL;
+                       goto _err;
                }
                snd_config_for_each(i, next, type) {
                        snd_config_t *n = snd_config_iterator_entry(i);
@@ -386,7 +379,7 @@ int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
                                err = snd_config_get_string(n, &lib);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err;
                                }
                                continue;
                        }
@@ -394,11 +387,13 @@ int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
                                err = snd_config_get_string(n, &install);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err;
                                }
                                continue;
                        }
                        SNDERR("Unknown field %s", id);
+               _err:
+                       snd_config_delete(type);
                        return -EINVAL;
                }
        }
@@ -408,25 +403,30 @@ int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
        }
        if (!lib)
                lib = ALSA_LIB;
-       if (args && snd_config_get_string(args, &str) >= 0) {
-               err = snd_config_search_alias(snd_config, "hook_args", str, &args);
-               if (err < 0) {
-                       SNDERR("unknown hook_args %s", str);
-                       return err;
-               }
-       }
        h = dlopen(lib, RTLD_NOW);
+       if (h)
+               install_func = dlsym(h, install);
+       if (type)
+               snd_config_delete(type);
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
                return -ENOENT;
        }
-       install_func = dlsym(h, install);
        if (!install_func) {
                SNDERR("symbol %s is not defined inside %s", install, lib);
                dlclose(h);
                return -ENXIO;
        }
-       err = install_func(pcm, args);
+       if (args && snd_config_get_string(args, &str) >= 0) {
+               err = snd_config_search_definition(snd_config, "hook_args", str, &args);
+               if (err < 0) {
+                       SNDERR("unknown hook_args %s", str);
+                       return err;
+               }
+               err = install_func(pcm, args);
+               snd_config_delete(args);
+       } else
+               err = install_func(pcm, args);
        if (err < 0)
                return err;
        return 0;
@@ -480,7 +480,17 @@ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name,
                return 0;
        snd_config_for_each(i, next, hooks) {
                snd_config_t *n = snd_config_iterator_entry(i);
-               err = snd_pcm_hook_add_conf(*pcmp, n);
+               const char *str;
+               if (snd_config_get_string(n, &str) >= 0) {
+                       err = snd_config_search_definition(snd_config, "pcm_hook", str, &n);
+                       if (err < 0) {
+                               SNDERR("unknown pcm_hook %s", str);
+                               return err;
+                       }
+                       err = snd_pcm_hook_add_conf(*pcmp, n);
+                       snd_config_delete(n);
+               } else
+                       err = snd_pcm_hook_add_conf(*pcmp, n);
                if (err < 0) {
                        snd_pcm_close(*pcmp);
                        return err;
index 622fc25..803c0ad 100644 (file)
@@ -663,29 +663,23 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
                         snd_config_t *);
        void *h;
        int err;
-       err = snd_config_get_string(conf, &str);
-       if (err >= 0) {
-               err = snd_config_search_alias(snd_config, "pcm_scope", str, &conf);
-               if (err < 0) {
-                       SNDERR("unknown pcm_scope %s", str);
-                       return err;
-               }
-       }
+       int to_free = 0;
        if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
                SNDERR("Invalid type for scope %s", str);
-               return -EINVAL;
+               err = -EINVAL;
+               goto _err;
        }
        err = snd_config_search(conf, "type", &c);
        if (err < 0) {
                SNDERR("type is not defined");
-               return err;
+               goto _err;
        }
        err = snd_config_get_string(c, &str);
        if (err < 0) {
                SNDERR("Invalid type for %s", snd_config_get_id(c));
-               return err;
+               goto _err;
        }
-       err = snd_config_search_alias(snd_config, "pcm_scope_type", str, &type_conf);
+       err = snd_config_search_definition(snd_config, "pcm_scope_type", str, &type_conf);
        if (err >= 0) {
                snd_config_for_each(i, next, type_conf) {
                        snd_config_t *n = snd_config_iterator_entry(i);
@@ -696,7 +690,7 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
                                err = snd_config_get_string(n, &lib);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err1;
                                }
                                continue;
                        }
@@ -704,12 +698,13 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
                                err = snd_config_get_string(n, &open_name);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err1;
                                }
                                continue;
                        }
                        SNDERR("Unknown field %s", id);
-                       return -EINVAL;
+                       err = -EINVAL;
+                       goto _err1;
                }
        }
        if (!open_name) {
@@ -721,15 +716,24 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
        h = dlopen(lib, RTLD_NOW);
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
-               return -ENOENT;
+               err = -ENOENT;
+               goto _err1;
        }
        open_func = dlsym(h, open_name);
+       if (type_conf)
+               snd_config_delete(type_conf);
        if (!open_func) {
                SNDERR("symbol %s is not defined inside %s", open_name, lib);
                dlclose(h);
-               return -ENXIO;
+               goto _err;
        }
        return open_func(pcm, name, conf);
+ _err1:
+       snd_config_delete(type_conf);
+ _err:
+       if (to_free)
+               snd_config_delete(conf);
+       return err;
 }
 
                        
@@ -791,7 +795,17 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
        snd_config_for_each(i, next, scopes) {
                snd_config_t *n = snd_config_iterator_entry(i);
                const char *id = snd_config_get_id(n);
-               err = snd_pcm_meter_add_scope_conf(*pcmp, id, n);
+               const char *str;
+               if (snd_config_get_string(n, &str) >= 0) {
+                       err = snd_config_search_definition(snd_config, "pcm_scope", str, &n);
+                       if (err < 0) {
+                               SNDERR("unknown pcm_scope %s", str);
+                               return err;
+                       }
+                       err = snd_pcm_meter_add_scope_conf(*pcmp, id, n);
+                       snd_config_delete(n);
+               } else
+                       err = snd_pcm_meter_add_scope_conf(*pcmp, id, n);
                if (err < 0) {
                        snd_pcm_close(*pcmp);
                        return err;
index dca7779..9d37a41 100644 (file)
@@ -1414,7 +1414,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name,
                SNDERR("slave is not defined");
                return -EINVAL;
        }
-       err = snd_pcm_slave_conf(root, slave, &sconf, NULL, 5,
+       err = snd_pcm_slave_conf(root, slave, &sconf, 5,
                                 SND_PCM_HW_PARAM_CHANNELS, 0, &schannels,
                                 SND_PCM_HW_PARAM_FORMAT, 0, &sformat,
                                 SND_PCM_HW_PARAM_RATE, 0, &srate,
index efddcf1..5233376 100644 (file)
@@ -765,14 +765,14 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
                SNDERR("server is not defined");
                return -EINVAL;
        }
-       err = snd_config_search_alias(snd_config, "server", server, &sconfig);
+       err = snd_config_search_definition(snd_config, "server", server, &sconfig);
        if (err < 0) {
                SNDERR("Unknown server %s", server);
                return -EINVAL;
        }
        if (snd_config_get_type(sconfig) != SND_CONFIG_TYPE_COMPOUND) {
                SNDERR("Invalid type for server %s definition", server);
-               return -EINVAL;
+               goto _err;
        }
        snd_config_for_each(i, next, sconfig) {
                snd_config_t *n = snd_config_iterator_entry(i);
@@ -783,7 +783,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
                        err = snd_config_get_string(n, &host);
                        if (err < 0) {
                                SNDERR("Invalid type for %s", id);
-                               return -EINVAL;
+                               goto _err;
                        }
                        continue;
                }
@@ -791,7 +791,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
                        err = snd_config_get_string(n, &sockname);
                        if (err < 0) {
                                SNDERR("Invalid type for %s", id);
-                               return -EINVAL;
+                               goto _err;
                        }
                        continue;
                }
@@ -799,32 +799,36 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
                        err = snd_config_get_integer(n, &port);
                        if (err < 0) {
                                SNDERR("Invalid type for %s", id);
-                               return -EINVAL;
+                               goto _err;
                        }
                        continue;
                }
                SNDERR("Unknown field %s", id);
+       _err:
+               snd_config_delete(sconfig);
                return -EINVAL;
        }
 
        if (!host) {
                SNDERR("host is not defined");
-               return -EINVAL;
+               goto _err;
        }
        if (!sockname) {
                SNDERR("socket is not defined");
-               return -EINVAL;
+               goto _err;
        }
        h = gethostbyname(host);
        if (!h) {
                SNDERR("Cannot resolve %s", host);
-               return -EINVAL;
+               goto _err;
        }
        local = is_local(h);
        if (!local) {
                SNDERR("%s is not the local host", host);
                return -EINVAL;
        }
-       return snd_pcm_shm_open(pcmp, name, sockname, pcm_name, stream, mode);
+       err = snd_pcm_shm_open(pcmp, name, sockname, pcm_name, stream, mode);
+       snd_config_delete(sconfig);
+       return err;
 }
                                
index a34b977..5e3e14d 100644 (file)
@@ -91,11 +91,11 @@ int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
                SNDERR("Invalid type for %s", snd_config_get_id(conf));
                return err;
        }
-       err = snd_config_search_alias(snd_config, "rawmidi_type", str, &type_conf);
+       err = snd_config_search_definition(snd_config, "rawmidi_type", str, &type_conf);
        if (err >= 0) {
                if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for RAWMIDI type %s definition", str);
-                       return -EINVAL;
+                       goto _err;
                }
                snd_config_for_each(i, next, type_conf) {
                        snd_config_t *n = snd_config_iterator_entry(i);
@@ -106,7 +106,7 @@ int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
                                err = snd_config_get_string(n, &lib);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err;
                                }
                                continue;
                        }
@@ -114,11 +114,13 @@ int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
                                err = snd_config_get_string(n, &open_name);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err;
                                }
                                continue;
                        }
                        SNDERR("Unknown field %s", id);
+               _err:
+                       snd_config_delete(type_conf);
                        return -EINVAL;
                }
        }
@@ -129,11 +131,14 @@ int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
        if (!lib)
                lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
+       if (h)
+               open_func = dlsym(h, open_name);
+       if (type_conf)
+               snd_config_delete(type_conf);
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
                return -ENOENT;
        }
-       open_func = dlsym(h, open_name);
        if (!open_func) {
                SNDERR("symbol %s is not defined inside %s", open_name, lib);
                dlclose(h);
@@ -160,44 +165,11 @@ int snd_rawmidi_open_noupdate(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
 {
        int err;
        snd_config_t *rawmidi_conf;
-       char *base, *key;
-       const char *args = strchr(name, ':');
-
-       if (args) {
-               args++;
-               base = alloca(args - name);
-               memcpy(base, name, args - name - 1);
-               base[args - name - 1] = '\0';
-               key = strchr(base, '.');
-               if (key)
-                       *key++ = '\0';
-       } else {
-               key = strchr(name, '.');
-               if (key) {
-                       key++;
-                       base = alloca(key - name);
-                       memcpy(base, name, key - name - 1);
-                       base[key - name - 1] = '\0';
-               } else
-                       base = (char *) name;
-       }
-       if (key == NULL) {
-               key = base;
-               base = NULL;
-       }
-       err = snd_config_search_alias(root, base, key, &rawmidi_conf);
+       err = snd_config_search_definition(root, "rawmidi", name, &rawmidi_conf);
        if (err < 0) {
-               (void)(base == NULL && (err = snd_config_search_alias(root, "rawmidi", key, &rawmidi_conf)));
-               if (err < 0) {
-                       SNDERR("Unknown RawMidi %s", name);
-                       return err;
-               }
-       }
-       err = snd_config_expand(rawmidi_conf, args, NULL, &rawmidi_conf);
-       if (err < 0) {
-               SNDERR("Could not expand configuration for %s: %s", name, snd_strerror(err));
+               SNDERR("Unknown RawMidi %s", name);
                return err;
-        }
+       }
        err = snd_rawmidi_open_conf(inputp, outputp, name, rawmidi_conf, mode);
        snd_config_delete(rawmidi_conf);
        return err;
index 23a5d99..43f7740 100644 (file)
@@ -90,11 +90,11 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name,
                SNDERR("Invalid type for %s", snd_config_get_id(conf));
                return err;
        }
-       err = snd_config_search_alias(snd_config, "seq_type", str, &type_conf);
+       err = snd_config_search_definition(snd_config, "seq_type", str, &type_conf);
        if (err >= 0) {
                if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for SEQ type %s definition", str);
-                       return -EINVAL;
+                       goto _err;
                }
                snd_config_for_each(i, next, type_conf) {
                        snd_config_t *n = snd_config_iterator_entry(i);
@@ -105,7 +105,7 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name,
                                err = snd_config_get_string(n, &lib);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err;
                                }
                                continue;
                        }
@@ -113,11 +113,13 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name,
                                err = snd_config_get_string(n, &open_name);
                                if (err < 0) {
                                        SNDERR("Invalid type for %s", id);
-                                       return -EINVAL;
+                                       goto _err;
                                }
                                continue;
                        }
                        SNDERR("Unknown field %s", id);
+               _err:
+                       snd_config_delete(type_conf);
                        return -EINVAL;
                }
        }
@@ -128,11 +130,14 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name,
        if (!lib)
                lib = ALSA_LIB;
        h = dlopen(lib, RTLD_NOW);
+       if (h)
+               open_func = dlsym(h, open_name);
+       if (type_conf)
+               snd_config_delete(type_conf);
        if (!h) {
                SNDERR("Cannot open shared library %s", lib);
                return -ENOENT;
        }
-       open_func = dlsym(h, open_name);
        if (!open_func) {
                SNDERR("symbol %s is not defined inside %s", open_name, lib);
                dlclose(h);
@@ -146,42 +151,9 @@ static int snd_seq_open_noupdate(snd_seq_t **seqp, snd_config_t *root,
 {
        int err;
        snd_config_t *seq_conf;
-       char *base, *key;
-       const char *args = strchr(name, ':');
-
-       if (args) {
-               args++;
-               base = alloca(args - name);
-               memcpy(base, name, args - name - 1);
-               base[args - name - 1] = '\0';
-               key = strchr(base, '.');
-               if (key)
-                       *key++ = '\0';
-       } else {
-               key = strchr(name, '.');
-               if (key) {
-                       key++;
-                       base = alloca(key - name);
-                       memcpy(base, name, key - name - 1);
-                       base[key - name - 1] = '\0';
-               } else
-                       base = (char *) name;
-       }
-       if (key == NULL) {
-               key = base;
-               base = NULL;
-       }
-       err = snd_config_search_alias(root, base, key, &seq_conf);
-       if (err < 0) {
-               (void)(base == NULL && (err = snd_config_search_alias(root, "seq", key, &seq_conf)));
-               if (err < 0) {
-                       SNDERR("Unknown PCM %s", name);
-                       return err;
-               }
-       }
-       err = snd_config_expand(seq_conf, args, NULL, &seq_conf);
+       err = snd_config_search_definition(root, "seq", name, &seq_conf);
        if (err < 0) {
-               SNDERR("Could not expand configuration for %s: %s", name, snd_strerror(err));
+               SNDERR("Unknown SEQ %s", name);
                return err;
        }
        err = snd_seq_open_conf(seqp, name, seq_conf, streams, mode);