OSDN Git Service

Encapsulated conf API
authorAbramo Bagnara <abramo@alsa-project.org>
Wed, 7 Feb 2001 11:34:33 +0000 (11:34 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Wed, 7 Feb 2001 11:34:33 +0000 (11:34 +0000)
26 files changed:
aserver/aserver.c
include/conf.h
include/list.h
src/conf.c
src/control/control.c
src/control/control_hw.c
src/control/control_shm.c
src/pcm/pcm.c
src/pcm/pcm_adpcm.c
src/pcm/pcm_alaw.c
src/pcm/pcm_copy.c
src/pcm/pcm_file.c
src/pcm/pcm_hw.c
src/pcm/pcm_linear.c
src/pcm/pcm_mulaw.c
src/pcm/pcm_multi.c
src/pcm/pcm_null.c
src/pcm/pcm_plug.c
src/pcm/pcm_rate.c
src/pcm/pcm_route.c
src/pcm/pcm_share.c
src/pcm/pcm_shm.c
src/rawmidi/rawmidi.c
src/rawmidi/rawmidi_hw.c
src/seq/seq.c
src/seq/seq_hw.c

index 6f87982..5ad6826 100644 (file)
@@ -970,34 +970,35 @@ int main(int argc, char **argv)
                return 1;
        }
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "host") == 0) {
-                       err = snd_config_string_get(n, &host);
+               if (strcmp(id, "host") == 0) {
+                       err = snd_config_get_string(n, &host);
                        if (err < 0) {
-                               ERROR("Invalid type for %s", n->id);
+                               ERROR("Invalid type for %s", id);
                                return 1;
                        }
                        continue;
                }
-               if (strcmp(n->id, "socket") == 0) {
-                       err = snd_config_string_get(n, &socket);
+               if (strcmp(id, "socket") == 0) {
+                       err = snd_config_get_string(n, &socket);
                        if (err < 0) {
-                               ERROR("Invalid type for %s", n->id);
+                               ERROR("Invalid type for %s", id);
                                return 1;
                        }
                        continue;
                }
-               if (strcmp(n->id, "port") == 0) {
-                       err = snd_config_integer_get(n, &port);
+               if (strcmp(id, "port") == 0) {
+                       err = snd_config_get_integer(n, &port);
                        if (err < 0) {
-                               ERROR("Invalid type for %s", n->id);
+                               ERROR("Invalid type for %s", id);
                                return 1;
                        }
                        continue;
                }
-               ERROR("Unknown field %s", n->id);
+               ERROR("Unknown field %s", id);
                return 1;
        }
        if (!host) {
index 178be79..8ad0d24 100644 (file)
@@ -1,18 +1,4 @@
 
-#define LIST_HEAD_IS_DEFINED
-struct list_head {
-        struct list_head *next, *prev;
-};        
-
-/**
- * list_entry - get the struct for this entry
- * @ptr:        the &struct list_head pointer.
- * @type:       the type of the struct this is embedded in.
- * @member:     the name of the list_struct within the struct.
- */
-#define list_entry(ptr, type, member) \
-        ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
-
 enum _snd_config_type {
         SND_CONFIG_TYPE_INTEGER,
         SND_CONFIG_TYPE_REAL,
@@ -32,32 +18,14 @@ typedef enum _snd_config_type snd_config_type_t;
 #define SND_CONFIG_TYPE_COMPOUND ((snd_config_type_t) SND_CONFIG_TYPE_COMPOUND)
 
 typedef struct _snd_config snd_config_t;
+typedef struct _snd_config_iterator *snd_config_iterator_t;
 
-struct _snd_config {
-       char *id;
-       snd_config_type_t type;
-       union {
-               long integer;
-               char *string;
-               double real;
-               struct {
-                       struct list_head fields;
-                       int join;
-               } compound;
-       } u;
-       struct list_head list;
-       snd_config_t *father;
-};
-
-static inline snd_config_type_t snd_config_type(snd_config_t *config)
-{
-       return config->type;
-}
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-static inline char *snd_config_id(snd_config_t *config)
-{
-       return config->id;
-}
+snd_config_type_t snd_config_get_type(snd_config_t *config);
+char *snd_config_get_id(snd_config_t *config);
 
 int snd_config_top(snd_config_t **config);
 
@@ -74,28 +42,33 @@ int snd_config_delete(snd_config_t *config);
 
 int snd_config_make(snd_config_t **config, const char *key,
                    snd_config_type_t type);
-int snd_config_integer_make(snd_config_t **config, const char *key);
-int snd_config_real_make(snd_config_t **config, const char *key);
-int snd_config_string_make(snd_config_t **config, const char *key);
-int snd_config_compound_make(snd_config_t **config, const char *key, int join);
-
-int snd_config_integer_set(snd_config_t *config, long value);
-int snd_config_real_set(snd_config_t *config, double value);
-int snd_config_string_set(snd_config_t *config, const char *value);
-int snd_config_integer_get(snd_config_t *config, long *value);
-int snd_config_real_get(snd_config_t *config, double *value);
-int snd_config_string_get(snd_config_t *config, const char **value);
-
-typedef struct list_head *snd_config_iterator_t;
+int snd_config_make_integer(snd_config_t **config, const char *key);
+int snd_config_make_real(snd_config_t **config, const char *key);
+int snd_config_make_string(snd_config_t **config, const char *key);
+int snd_config_make_compound(snd_config_t **config, const char *key, int join);
+
+int snd_config_set_integer(snd_config_t *config, long value);
+int snd_config_set_real(snd_config_t *config, double value);
+int snd_config_set_string(snd_config_t *config, const char *value);
+int snd_config_get_integer(snd_config_t *config, long *value);
+int snd_config_get_real(snd_config_t *config, double *value);
+int snd_config_get_string(snd_config_t *config, const char **value);
+
+snd_config_iterator_t snd_config_iterator_first(snd_config_t *node);
+snd_config_iterator_t snd_config_iterator_next(snd_config_iterator_t iterator);
+snd_config_iterator_t snd_config_iterator_end(snd_config_t *node);
+snd_config_t *snd_config_iterator_entry(snd_config_iterator_t iterator);
 
 #define snd_config_foreach(iterator, node) \
-       assert((node)->type == SND_CONFIG_TYPE_COMPOUND); \
-       for (iterator = (node)->u.compound.fields.next; iterator != &(node)->u.compound.fields; iterator = iterator->next)
-
-#define snd_config_entry(iterator) list_entry(iterator, snd_config_t, list)
+       for (iterator = snd_config_iterator_first(node); iterator != snd_config_iterator_end(node); iterator = snd_config_iterator_next(iterator))
 
-snd_config_type_t snd_config_type(snd_config_t *config);
-char *snd_config_id(snd_config_t *config);
+snd_config_type_t snd_config_get_type(snd_config_t *config);
+char *snd_config_get_id(snd_config_t *config);
 
 extern snd_config_t *snd_config;
 int snd_config_update();
+
+#ifdef __cplusplus
+}
+#endif
+
index b7d74a3..5f4da88 100644 (file)
@@ -144,4 +144,14 @@ static __inline__ void list_splice(struct list_head *list, struct list_head *hea
 #define list_for_each(pos, head) \
        for (pos = (head)->next; pos != (head); pos = pos->next)
 
+/**
+ * list_entry - get the struct for this entry
+ * @ptr:       the &struct list_head pointer.
+ * @type:      the type of the struct this is embedded in.
+ * @member:    the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+       ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+
+
 #endif /* _LIST_H */
index 82077e4..a43ea1b 100644 (file)
  *
  */
 
+#define _snd_config_iterator list_head
+
 #include <stdarg.h>
 #include <sys/stat.h>
 #include "local.h"
 #include "list.h"
 
+struct _snd_config {
+       char *id;
+       snd_config_type_t type;
+       union {
+               long integer;
+               char *string;
+               double real;
+               struct {
+                       struct list_head fields;
+                       int join;
+               } compound;
+       } u;
+       struct list_head list;
+       snd_config_t *father;
+};
+
 #define SYS_ASOUNDRC "/etc/asound.conf"
 #define USR_ASOUNDRC ".asoundrc"
 
@@ -319,6 +337,16 @@ static int get_string(char **string, int id, input_t *input)
        }
 }
 
+snd_config_type_t snd_config_get_type(snd_config_t *config)
+{
+       return config->type;
+}
+
+char *snd_config_get_id(snd_config_t *config)
+{
+       return config->id;
+}
+
 static int _snd_config_make(snd_config_t **config, char *id,
                            snd_config_type_t type)
 {
@@ -357,7 +385,7 @@ static int _snd_config_search(snd_config_t *config, const char *id, int len, snd
 {
        snd_config_iterator_t i;
        snd_config_foreach(i, config) {
-               snd_config_t *n = snd_config_entry(i);
+               snd_config_t *n = snd_config_iterator_entry(i);
                if (len < 0) {
                        if (strcmp(n->id, id) == 0) {
                                *result = n;
@@ -637,7 +665,7 @@ int snd_config_add(snd_config_t *father, snd_config_t *leaf)
        snd_config_iterator_t i;
        assert(father && leaf);
        snd_config_foreach(i, father) {
-               snd_config_t *n = snd_config_entry(i);
+               snd_config_t *n = snd_config_iterator_entry(i);
                if (strcmp(leaf->id, n->id) == 0)
                        return -EEXIST;
        }
@@ -657,7 +685,7 @@ int snd_config_delete(snd_config_t *config)
                i = config->u.compound.fields.next;
                while (i != &config->u.compound.fields) {
                        struct list_head *nexti = i->next;
-                       snd_config_t *leaf = snd_config_entry(i);
+                       snd_config_t *leaf = snd_config_iterator_entry(i);
                        err = snd_config_delete(leaf);
                        if (err < 0)
                                return err;
@@ -691,22 +719,22 @@ int snd_config_make(snd_config_t **config, const char *id,
        return _snd_config_make(config, id1, type);
 }
 
-int snd_config_integer_make(snd_config_t **config, const char *id)
+int snd_config_make_integer(snd_config_t **config, const char *id)
 {
        return snd_config_make(config, id, SND_CONFIG_TYPE_INTEGER);
 }
 
-int snd_config_real_make(snd_config_t **config, const char *id)
+int snd_config_make_real(snd_config_t **config, const char *id)
 {
        return snd_config_make(config, id, SND_CONFIG_TYPE_REAL);
 }
 
-int snd_config_string_make(snd_config_t **config, const char *id)
+int snd_config_make_string(snd_config_t **config, const char *id)
 {
        return snd_config_make(config, id, SND_CONFIG_TYPE_STRING);
 }
 
-int snd_config_compound_make(snd_config_t **config, const char *id,
+int snd_config_make_compound(snd_config_t **config, const char *id,
                             int join)
 {
        int err;
@@ -717,7 +745,7 @@ int snd_config_compound_make(snd_config_t **config, const char *id,
        return 0;
 }
 
-int snd_config_integer_set(snd_config_t *config, long value)
+int snd_config_set_integer(snd_config_t *config, long value)
 {
        assert(config);
        if (config->type != SND_CONFIG_TYPE_INTEGER)
@@ -726,7 +754,7 @@ int snd_config_integer_set(snd_config_t *config, long value)
        return 0;
 }
 
-int snd_config_real_set(snd_config_t *config, double value)
+int snd_config_set_real(snd_config_t *config, double value)
 {
        assert(config);
        if (config->type != SND_CONFIG_TYPE_REAL)
@@ -735,7 +763,7 @@ int snd_config_real_set(snd_config_t *config, double value)
        return 0;
 }
 
-int snd_config_string_set(snd_config_t *config, const char *value)
+int snd_config_set_string(snd_config_t *config, const char *value)
 {
        assert(config);
        if (config->type != SND_CONFIG_TYPE_STRING)
@@ -748,7 +776,7 @@ int snd_config_string_set(snd_config_t *config, const char *value)
        return 0;
 }
 
-int snd_config_integer_get(snd_config_t *config, long *ptr)
+int snd_config_get_integer(snd_config_t *config, long *ptr)
 {
        assert(config && ptr);
        if (config->type != SND_CONFIG_TYPE_INTEGER)
@@ -757,7 +785,7 @@ int snd_config_integer_get(snd_config_t *config, long *ptr)
        return 0;
 }
 
-int snd_config_real_get(snd_config_t *config, double *ptr)
+int snd_config_get_real(snd_config_t *config, double *ptr)
 {
        assert(config && ptr);
        if (config->type != SND_CONFIG_TYPE_REAL)
@@ -766,7 +794,7 @@ int snd_config_real_get(snd_config_t *config, double *ptr)
        return 0;
 }
 
-int snd_config_string_get(snd_config_t *config, const char **ptr)
+int snd_config_get_string(snd_config_t *config, const char **ptr)
 {
        assert(config && ptr);
        if (config->type != SND_CONFIG_TYPE_STRING)
@@ -905,7 +933,7 @@ static int _snd_config_save_leaves(snd_config_t *config, snd_output_t *out, unsi
        snd_config_iterator_t i;
        assert(config && out);
        snd_config_foreach(i, config) {
-               snd_config_t *n = snd_config_entry(i);
+               snd_config_t *n = snd_config_iterator_entry(i);
                if (n->type == SND_CONFIG_TYPE_COMPOUND &&
                    n->u.compound.join) {
                        err = _snd_config_save_leaves(n, out, level, joins + 1);
@@ -1052,3 +1080,26 @@ int snd_config_update()
        }
        return 0;
 }
+
+snd_config_iterator_t snd_config_iterator_first(snd_config_t *node)
+{
+       assert(node->type == SND_CONFIG_TYPE_COMPOUND);
+       return node->u.compound.fields.next;
+}
+
+snd_config_iterator_t snd_config_iterator_next(snd_config_iterator_t iterator)
+{
+       return iterator->next;
+}
+
+snd_config_iterator_t snd_config_iterator_end(snd_config_t *node)
+{
+       assert(node->type == SND_CONFIG_TYPE_COMPOUND);
+       return &node->u.compound.fields;
+}
+
+snd_config_t *snd_config_iterator_entry(snd_config_iterator_t iterator)
+{
+       return list_entry(iterator, snd_config_t, list);
+}
+
index ce856d3..2f17507 100644 (file)
@@ -197,27 +197,28 @@ int snd_ctl_open(snd_ctl_t **ctlp, char *name)
                ERR("Unknown control %s", name);
                return -ENOENT;
        }
-       if (snd_config_type(ctl_conf) != SND_CONFIG_TYPE_COMPOUND)
+       if (snd_config_get_type(ctl_conf) != SND_CONFIG_TYPE_COMPOUND)
                return -EINVAL;
        err = snd_config_search(ctl_conf, "type", &conf);
        if (err < 0)
                return err;
-       err = snd_config_string_get(conf, &str);
+       err = snd_config_get_string(conf, &str);
        if (err < 0)
                return err;
        err = snd_config_searchv(snd_config, &type_conf, "ctltype", str, 0);
        snd_config_foreach(i, type_conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "lib") == 0) {
-                       err = snd_config_string_get(n, &lib);
+               if (strcmp(id, "lib") == 0) {
+                       err = snd_config_get_string(n, &lib);
                        if (err < 0)
                                return -EINVAL;
                        continue;
                }
-               if (strcmp(n->id, "open") == 0) {
-                       err = snd_config_string_get(n, &open);
+               if (strcmp(id, "open") == 0) {
+                       err = snd_config_get_string(n, &open);
                        if (err < 0)
                                return -EINVAL;
                        continue;
index cc51b47..f40c672 100644 (file)
@@ -235,15 +235,16 @@ int _snd_ctl_hw_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
        const char *str;
        int err;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "card") == 0) {
-                       err = snd_config_integer_get(n, &card);
+               if (strcmp(id, "card") == 0) {
+                       err = snd_config_get_integer(n, &card);
                        if (err < 0) {
-                               err = snd_config_string_get(n, &str);
+                               err = snd_config_get_string(n, &str);
                                if (err < 0)
                                        return -EINVAL;
                                card = snd_card_get_index(str);
index 45f04b3..5ee3d99 100644 (file)
@@ -479,28 +479,29 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
        int local;
        struct hostent *h;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "server") == 0) {
-                       err = snd_config_string_get(n, &server);
+               if (strcmp(id, "server") == 0) {
+                       err = snd_config_get_string(n, &server);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
@@ -517,34 +518,35 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
                return -EINVAL;
        }
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "host") == 0) {
-                       err = snd_config_string_get(n, &host);
+               if (strcmp(id, "host") == 0) {
+                       err = snd_config_get_string(n, &host);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "socket") == 0) {
-                       err = snd_config_string_get(n, &socket);
+               if (strcmp(id, "socket") == 0) {
+                       err = snd_config_get_string(n, &socket);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "port") == 0) {
-                       err = snd_config_integer_get(n, &port);
+               if (strcmp(id, "port") == 0) {
+                       err = snd_config_get_integer(n, &port);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
 
index 78f01c4..4d5478c 100644 (file)
@@ -591,15 +591,16 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
                ERR("Unknown PCM %s", name);
                return -ENOENT;
        }
-       if (snd_config_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
+       if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
                ERR("Invalid type for PCM %s definition", name);
                return -EINVAL;
        }
        err = snd_config_search(pcm_conf, "stream", &conf);
        if (err >= 0) {
-               err = snd_config_string_get(conf, &str);
+               const char *id = snd_config_get_id(conf);
+               err = snd_config_get_string(conf, &str);
                if (err < 0) {
-                       ERR("Invalid type for %s", conf->id);
+                       ERR("Invalid type for %s", id);
                        return err;
                }
                if (strcmp(str, "playback") == 0) {
@@ -609,7 +610,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
                        if (stream != SND_PCM_STREAM_CAPTURE)
                                return -EINVAL;
                } else {
-                       ERR("Invalid value for %s", conf->id);
+                       ERR("Invalid value for %s", id);
                        return -EINVAL;
                }
        }
@@ -618,9 +619,9 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
                ERR("type is not defined");
                return err;
        }
-       err = snd_config_string_get(conf, &str);
+       err = snd_config_get_string(conf, &str);
        if (err < 0) {
-               ERR("Invalid type for %s", conf->id);
+               ERR("Invalid type for %s", snd_config_get_id(conf));
                return err;
        }
        err = snd_config_searchv(snd_config, &type_conf, "pcmtype", str, 0);
@@ -629,25 +630,26 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
                return err;
        }
        snd_config_foreach(i, type_conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "lib") == 0) {
-                       err = snd_config_string_get(n, &lib);
+               if (strcmp(id, "lib") == 0) {
+                       err = snd_config_get_string(n, &lib);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "open") == 0) {
-                       err = snd_config_string_get(n, &open);
+               if (strcmp(id, "open") == 0) {
+                       err = snd_config_get_string(n, &open);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
-                       ERR("Unknown field %s", n->id);
+                       ERR("Unknown field %s", id);
                        return -EINVAL;
                }
        }
index 7347ce6..92a3d53 100644 (file)
@@ -602,26 +602,27 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name,
        snd_pcm_t *spcm;
        snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "sformat") == 0) {
+               if (strcmp(id, "sformat") == 0) {
                        const char *f;
-                       err = snd_config_string_get(n, &f);
+                       err = snd_config_get_string(n, &f);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        sformat = snd_pcm_format_value(f);
@@ -636,7 +637,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name,
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
index 1f30951..dfbedad 100644 (file)
@@ -475,26 +475,27 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name,
        snd_pcm_t *spcm;
        snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "sformat") == 0) {
+               if (strcmp(id, "sformat") == 0) {
                        const char *f;
-                       err = snd_config_string_get(n, &f);
+                       err = snd_config_get_string(n, &f);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        sformat = snd_pcm_format_value(f);
@@ -509,7 +510,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name,
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
index f0e2b9e..cc3b1cd 100644 (file)
@@ -232,22 +232,23 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, char *name,
        int err;
        snd_pcm_t *spcm;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
index 10d6686..21a6ee0 100644 (file)
@@ -471,41 +471,42 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, char *name,
        const char *format = NULL;
        long fd = -1;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "format") == 0) {
-                       err = snd_config_string_get(n, &format);
+               if (strcmp(id, "format") == 0) {
+                       err = snd_config_get_string(n, &format);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "file") == 0) {
-                       err = snd_config_string_get(n, &fname);
+               if (strcmp(id, "file") == 0) {
+                       err = snd_config_get_string(n, &fname);
                        if (err < 0) {
-                               err = snd_config_integer_get(n, &fd);
+                               err = snd_config_get_integer(n, &fd);
                                if (err < 0) {
-                                       ERR("Invalid type for %s", n->id);
+                                       ERR("Invalid type for %s", id);
                                        return -EINVAL;
                                }
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
index edcdf9b..071e721 100644 (file)
@@ -681,46 +681,47 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
        const char *str;
        int err;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "card") == 0) {
-                       err = snd_config_integer_get(n, &card);
+               if (strcmp(id, "card") == 0) {
+                       err = snd_config_get_integer(n, &card);
                        if (err < 0) {
-                               err = snd_config_string_get(n, &str);
+                               err = snd_config_get_string(n, &str);
                                if (err < 0) {
-                                       ERR("Invalid type for %s", n->id);
+                                       ERR("Invalid type for %s", id);
                                        return -EINVAL;
                                }
                                card = snd_card_get_index(str);
                                if (card < 0) {
-                                       ERR("Invalid value for %s", n->id);
+                                       ERR("Invalid value for %s", id);
                                        return card;
                                }
                        }
                        continue;
                }
-               if (strcmp(n->id, "device") == 0) {
-                       err = snd_config_integer_get(n, &device);
+               if (strcmp(id, "device") == 0) {
+                       err = snd_config_get_integer(n, &device);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return err;
                        }
                        continue;
                }
-               if (strcmp(n->id, "subdevice") == 0) {
-                       err = snd_config_integer_get(n, &subdevice);
+               if (strcmp(id, "subdevice") == 0) {
+                       err = snd_config_get_integer(n, &subdevice);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return err;
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (card < 0) {
index 1e9639f..f4eb570 100644 (file)
@@ -373,26 +373,27 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name,
        snd_pcm_t *spcm;
        snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "sformat") == 0) {
+               if (strcmp(id, "sformat") == 0) {
                        const char *f;
-                       err = snd_config_string_get(n, &f);
+                       err = snd_config_get_string(n, &f);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        sformat = snd_pcm_format_value(f);
@@ -406,7 +407,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name,
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
index 5e9c287..c9d6373 100644 (file)
@@ -490,26 +490,27 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name,
        snd_pcm_t *spcm;
        snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "sformat") == 0) {
+               if (strcmp(id, "sformat") == 0) {
                        const char *f;
-                       err = snd_config_string_get(n, &f);
+                       err = snd_config_get_string(n, &f);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        sformat = snd_pcm_format_value(f);
@@ -524,7 +525,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name,
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
index 551b0ea..28d82fb 100644 (file)
@@ -597,30 +597,31 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
        unsigned int slaves_count = 0;
        unsigned int channels_count = 0;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "slave") == 0) {
-                       if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
-                               ERR("Invalid type for %s", n->id);
+               if (strcmp(id, "slave") == 0) {
+                       if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        slave = n;
                        continue;
                }
-               if (strcmp(n->id, "binding") == 0) {
-                       if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
-                               ERR("Invalid type for %s", n->id);
+               if (strcmp(id, "binding") == 0) {
+                       if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        binding = n;
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!slave) {
@@ -637,11 +638,12 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
        snd_config_foreach(i, binding) {
                int cchannel = -1;
                char *p;
-               snd_config_t *m = snd_config_entry(i);
+               snd_config_t *m = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(m);
                errno = 0;
-               cchannel = strtol(m->id, &p, 10);
+               cchannel = strtol(id, &p, 10);
                if (errno || *p || cchannel < 0) {
-                       ERR("Invalid channel number: %s", m->id);
+                       ERR("Invalid channel number: %s", id);
                        return -EINVAL;
                }
                if ((unsigned)cchannel >= channels_count)
@@ -662,31 +664,32 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
                channels_sidx[idx] = -1;
        idx = 0;
        snd_config_foreach(i, slave) {
-               snd_config_t *m = snd_config_entry(i);
+               snd_config_t *m = snd_config_iterator_entry(i);
                const char *name = NULL;
                long channels = -1;
-               slaves_id[idx] = m->id;
+               slaves_id[idx] = snd_config_get_id(m);
                snd_config_foreach(j, m) {
-                       snd_config_t *n = snd_config_entry(j);
-                       if (strcmp(n->id, "comment") == 0)
+                       snd_config_t *n = snd_config_iterator_entry(j);
+                       const char *id = snd_config_get_id(n);
+                       if (strcmp(id, "comment") == 0)
                                continue;
-                       if (strcmp(n->id, "name") == 0) {
-                               err = snd_config_string_get(n, &name);
+                       if (strcmp(id, "name") == 0) {
+                               err = snd_config_get_string(n, &name);
                                if (err < 0) {
-                                       ERR("Invalid type for %s", n->id);
+                                       ERR("Invalid type for %s", id);
                                        goto _free;
                                }
                                continue;
                        }
-                       if (strcmp(n->id, "channels") == 0) {
-                               err = snd_config_integer_get(n, &channels);
+                       if (strcmp(id, "channels") == 0) {
+                               err = snd_config_get_integer(n, &channels);
                                if (err < 0) {
-                                       ERR("Invalid type for %s", n->id);
+                                       ERR("Invalid type for %s", id);
                                        goto _free;
                                }
                                continue;
                        }
-                       ERR("Unknown field %s", n->id);
+                       ERR("Unknown field %s", id);
                        err = -EINVAL;
                        goto _free;
                }
@@ -706,30 +709,32 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
        }
 
        snd_config_foreach(i, binding) {
-               snd_config_t *m = snd_config_entry(i);
+               snd_config_t *m = snd_config_iterator_entry(i);
                long cchannel = -1;
                long schannel = -1;
                int slave = -1;
                long val;
                const char *str;
-               cchannel = strtol(m->id, 0, 10);
+               const char *id = snd_config_get_id(m);
+               cchannel = strtol(id, 0, 10);
                if (cchannel < 0) {
-                       ERR("Invalid channel number: %s", m->id);
+                       ERR("Invalid channel number: %s", id);
                        err = -EINVAL;
                        goto _free;
                }
                snd_config_foreach(j, m) {
-                       snd_config_t *n = snd_config_entry(j);
-                       if (strcmp(n->id, "comment") == 0)
+                       snd_config_t *n = snd_config_iterator_entry(j);
+                       const char *id = snd_config_get_id(n);
+                       if (strcmp(id, "comment") == 0)
                                continue;
-                       if (strcmp(n->id, "sidx") == 0) {
+                       if (strcmp(id, "sidx") == 0) {
                                char buf[32];
                                unsigned int k;
-                               err = snd_config_string_get(n, &str);
+                               err = snd_config_get_string(n, &str);
                                if (err < 0) {
-                                       err = snd_config_integer_get(n, &val);
+                                       err = snd_config_get_integer(n, &val);
                                        if (err < 0) {
-                                               ERR("Invalid value for %s", n->id);
+                                               ERR("Invalid value for %s", id);
                                                goto _free;
                                        }
                                        sprintf(buf, "%ld", val);
@@ -741,15 +746,15 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
                                }
                                continue;
                        }
-                       if (strcmp(n->id, "schannel") == 0) {
-                               err = snd_config_integer_get(n, &schannel);
+                       if (strcmp(id, "schannel") == 0) {
+                               err = snd_config_get_integer(n, &schannel);
                                if (err < 0) {
-                                       ERR("Invalid type for %s", n->id);
+                                       ERR("Invalid type for %s", id);
                                        goto _free;
                                }
                                continue;
                        }
-                       ERR("Unknown field %s", n->id);
+                       ERR("Unknown field %s", id);
                        err = -EINVAL;
                        goto _free;
                }
index e45c916..6196252 100644 (file)
@@ -376,14 +376,15 @@ int _snd_pcm_null_open(snd_pcm_t **pcmp, char *name,
 {
        snd_config_iterator_t i;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        return snd_pcm_null_open(pcmp, name, stream, mode);
index c32260e..e794fc3 100644 (file)
@@ -712,30 +712,31 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
        snd_pcm_route_ttable_entry_t *ttable = NULL;
        unsigned int cused, sused;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "ttable") == 0) {
-                       if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
-                               ERR("Invalid type for %s", n->id);
+               if (strcmp(id, "ttable") == 0) {
+                       if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        tt = n;
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
index b72f552..7edb85c 100644 (file)
@@ -628,26 +628,27 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name,
        snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
        long srate = -1;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "sname") == 0) { 
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) { 
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "sformat") == 0) {
+               if (strcmp(id, "sformat") == 0) {
                        const char *f;
-                       err = snd_config_string_get(n, &f);
+                       err = snd_config_get_string(n, &f);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        sformat = snd_pcm_format_value(f);
@@ -661,15 +662,15 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name,
                        }
                        continue;
                }
-               if (strcmp(n->id, "srate") == 0) {
-                       err = snd_config_integer_get(n, &srate);
+               if (strcmp(id, "srate") == 0) {
+                       err = snd_config_get_integer(n, &srate);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
index 49f56f6..4fc62b0 100644 (file)
@@ -828,38 +828,39 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
        for (k = 0; k < tt_csize * tt_ssize; ++k)
                ttable[k] = 0.0;
        snd_config_foreach(i, tt) {
-               snd_config_t *in = snd_config_entry(i);
+               snd_config_t *in = snd_config_iterator_entry(i);
                snd_config_iterator_t j;
                char *p;
                long cchannel;
                errno = 0;
-               cchannel = strtol(in->id, &p, 10);
+               cchannel = strtol(snd_config_get_id(in), &p, 10);
                if (errno || *p || 
                    cchannel < 0 || (unsigned int) cchannel > tt_csize) {
-                       ERR("Invalid client channel: %s", in->id);
+                       ERR("Invalid client channel: %s", snd_config_get_id(in));
                        return -EINVAL;
                }
-               if (snd_config_type(in) != SND_CONFIG_TYPE_COMPOUND)
+               if (snd_config_get_type(in) != SND_CONFIG_TYPE_COMPOUND)
                        return -EINVAL;
                snd_config_foreach(j, in) {
-                       snd_config_t *jn = snd_config_entry(j);
+                       snd_config_t *jn = snd_config_iterator_entry(j);
                        double value;
                        long schannel;
                        int err;
+                       const char *id = snd_config_get_id(jn);
                        errno = 0;
-                       schannel = strtol(jn->id, &p, 10);
+                       schannel = strtol(id, &p, 10);
                        if (errno || *p || 
                            schannel < 0 || (unsigned int) schannel > tt_ssize || 
                            (schannels > 0 && schannel >= schannels)) {
-                               ERR("Invalid slave channel: %s", jn->id);
+                               ERR("Invalid slave channel: %s", id);
                                return -EINVAL;
                        }
-                       err = snd_config_real_get(jn, &value);
+                       err = snd_config_get_real(jn, &value);
                        if (err < 0) {
                                long v;
-                               err = snd_config_integer_get(jn, &v);
+                               err = snd_config_get_integer(jn, &v);
                                if (err < 0) {
-                                       ERR("Invalid type for %s", jn->id);
+                                       ERR("Invalid type for %s", id);
                                        return -EINVAL;
                                }
                                value = v;
@@ -892,26 +893,27 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
        snd_pcm_route_ttable_entry_t ttable[MAX_CHANNELS*MAX_CHANNELS];
        unsigned int cused, sused;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "sformat") == 0) {
+               if (strcmp(id, "sformat") == 0) {
                        const char *f;
-                       err = snd_config_string_get(n, &f);
+                       err = snd_config_get_string(n, &f);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        sformat = snd_pcm_format_value(f);
@@ -925,23 +927,23 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
                        }
                        continue;
                }
-               if (strcmp(n->id, "schannels") == 0) {
-                       err = snd_config_integer_get(n, &schannels);
+               if (strcmp(id, "schannels") == 0) {
+                       err = snd_config_get_integer(n, &schannels);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "ttable") == 0) {
-                       if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
-                               ERR("Invalid type for %s", n->id);
+               if (strcmp(id, "ttable") == 0) {
+                       if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        tt = n;
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
index 1e806c0..b0e4094 100644 (file)
@@ -1374,26 +1374,27 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
        long srate = -1;
        
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "sformat") == 0) {
+               if (strcmp(id, "sformat") == 0) {
                        const char *f;
-                       err = snd_config_string_get(n, &f);
+                       err = snd_config_get_string(n, &f);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        sformat = snd_pcm_format_value(f);
@@ -1403,31 +1404,31 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
                        }
                        continue;
                }
-               if (strcmp(n->id, "schannels") == 0) {
-                       err = snd_config_integer_get(n, &schannels_count);
+               if (strcmp(id, "schannels") == 0) {
+                       err = snd_config_get_integer(n, &schannels_count);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "srate") == 0) {
-                       err = snd_config_integer_get(n, &srate);
+               if (strcmp(id, "srate") == 0) {
+                       err = snd_config_get_integer(n, &srate);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "binding") == 0) {
-                       if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
-                               ERR("Invalid type for %s", n->id);
+               if (strcmp(id, "binding") == 0) {
+                       if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        binding = n;
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
@@ -1441,11 +1442,12 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
        snd_config_foreach(i, binding) {
                int cchannel = -1;
                char *p;
-               snd_config_t *n = snd_config_entry(i);
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
                errno = 0;
-               cchannel = strtol(n->id, &p, 10);
+               cchannel = strtol(id, &p, 10);
                if (errno || *p || cchannel < 0) {
-                       ERR("Invalid client channel in binding: %s", n->id);
+                       ERR("Invalid client channel in binding: %s", id);
                        return -EINVAL;
                }
                if ((unsigned)cchannel >= channels_count)
@@ -1460,11 +1462,12 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
                channels_map[idx] = -1;
 
        snd_config_foreach(i, binding) {
-               snd_config_t *n = snd_config_entry(i);
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
                long cchannel;
                long schannel = -1;
-               cchannel = strtol(n->id, 0, 10);
-               err = snd_config_integer_get(n, &schannel);
+               cchannel = strtol(id, 0, 10);
+               err = snd_config_get_integer(n, &schannel);
                if (err < 0)
                        goto _free;
                assert(schannels_count <= 0 || schannel < schannels_count);
index 5fe9d5a..b608e1a 100644 (file)
@@ -730,30 +730,31 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
        int local;
        struct hostent *h;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "stream") == 0)
+               if (strcmp(id, "stream") == 0)
                        continue;
-               if (strcmp(n->id, "server") == 0) {
-                       err = snd_config_string_get(n, &server);
+               if (strcmp(id, "server") == 0) {
+                       err = snd_config_get_string(n, &server);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "sname") == 0) {
-                       err = snd_config_string_get(n, &sname);
+               if (strcmp(id, "sname") == 0) {
+                       err = snd_config_get_string(n, &sname);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
        if (!sname) {
@@ -770,34 +771,35 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
                return -EINVAL;
        }
        snd_config_foreach(i, sconfig) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "host") == 0) {
-                       err = snd_config_string_get(n, &host);
+               if (strcmp(id, "host") == 0) {
+                       err = snd_config_get_string(n, &host);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "socket") == 0) {
-                       err = snd_config_string_get(n, &socket);
+               if (strcmp(id, "socket") == 0) {
+                       err = snd_config_get_string(n, &socket);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "port") == 0) {
-                       err = snd_config_integer_get(n, &port);
+               if (strcmp(id, "port") == 0) {
+                       err = snd_config_get_integer(n, &port);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               ERR("Unknown field %s", n->id);
+               ERR("Unknown field %s", id);
                return -EINVAL;
        }
 
index db8caf4..5ad69ba 100644 (file)
@@ -187,15 +187,16 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
                ERR("Unknown RAWMIDI %s", name);
                return -ENOENT;
        }
-       if (snd_config_type(rawmidi_conf) != SND_CONFIG_TYPE_COMPOUND) {
+       if (snd_config_get_type(rawmidi_conf) != SND_CONFIG_TYPE_COMPOUND) {
                ERR("Invalid type for RAWMIDI %s definition", name);
                return -EINVAL;
        }
        err = snd_config_search(rawmidi_conf, "streams", &conf);
        if (err >= 0) {
-               err = snd_config_string_get(conf, &str);
+               const char *id = snd_config_get_id(conf);
+               err = snd_config_get_string(conf, &str);
                if (err < 0) {
-                       ERR("Invalid type for %s", conf->id);
+                       ERR("Invalid type for %s", id);
                        return err;
                }
                if (strcmp(str, "output") == 0) {
@@ -208,7 +209,7 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
                        if (streams != SND_RAWMIDI_OPEN_DUPLEX)
                                return -EINVAL;
                } else {
-                       ERR("Invalid value for %s", conf->id);
+                       ERR("Invalid value for %s", id);
                        return -EINVAL;
                }
        }
@@ -217,9 +218,9 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
                ERR("type is not defined");
                return err;
        }
-       err = snd_config_string_get(conf, &str);
+       err = snd_config_get_string(conf, &str);
        if (err < 0) {
-               ERR("Invalid type for %s", conf->id);
+               ERR("Invalid type for %s", snd_config_get_id(conf));
                return err;
        }
        err = snd_config_searchv(snd_config, &type_conf, "rawmiditype", str, 0);
@@ -228,25 +229,26 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
                return err;
        }
        snd_config_foreach(i, type_conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "lib") == 0) {
-                       err = snd_config_string_get(n, &lib);
+               if (strcmp(id, "lib") == 0) {
+                       err = snd_config_get_string(n, &lib);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "open") == 0) {
-                       err = snd_config_string_get(n, &open);
+               if (strcmp(id, "open") == 0) {
+                       err = snd_config_get_string(n, &open);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
-                       ERR("Unknown field %s", n->id);
+                       ERR("Unknown field %s", id);
                        return -EINVAL;
                }
        }
index 4677775..722d460 100644 (file)
@@ -278,17 +278,18 @@ int _snd_rawmidi_hw_open(snd_rawmidi_t **handlep, char *name, snd_config_t *conf
        const char *str;
        int err;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "streams") == 0)
+               if (strcmp(id, "streams") == 0)
                        continue;
-               if (strcmp(n->id, "card") == 0) {
-                       err = snd_config_integer_get(n, &card);
+               if (strcmp(id, "card") == 0) {
+                       err = snd_config_get_integer(n, &card);
                        if (err < 0) {
-                               err = snd_config_string_get(n, &str);
+                               err = snd_config_get_string(n, &str);
                                if (err < 0)
                                        return -EINVAL;
                                card = snd_card_get_index(str);
@@ -297,14 +298,14 @@ int _snd_rawmidi_hw_open(snd_rawmidi_t **handlep, char *name, snd_config_t *conf
                        }
                        continue;
                }
-               if (strcmp(n->id, "device") == 0) {
-                       err = snd_config_integer_get(n, &device);
+               if (strcmp(id, "device") == 0) {
+                       err = snd_config_get_integer(n, &device);
                        if (err < 0)
                                return err;
                        continue;
                }
-               if (strcmp(n->id, "subdevice") == 0) {
-                       err = snd_config_integer_get(n, &subdevice);
+               if (strcmp(id, "subdevice") == 0) {
+                       err = snd_config_get_integer(n, &subdevice);
                        if (err < 0)
                                return err;
                        continue;
index 3e7e241..0d62f81 100644 (file)
@@ -46,15 +46,16 @@ int snd_seq_open(snd_seq_t **seqp, char *name,
                ERR("Unknown SEQ %s", name);
                return -ENOENT;
        }
-       if (snd_config_type(seq_conf) != SND_CONFIG_TYPE_COMPOUND) {
+       if (snd_config_get_type(seq_conf) != SND_CONFIG_TYPE_COMPOUND) {
                ERR("Invalid type for SEQ %s definition", name);
                return -EINVAL;
        }
        err = snd_config_search(seq_conf, "streams", &conf);
        if (err >= 0) {
-               err = snd_config_string_get(conf, &str);
+               const char *id = snd_config_get_id(conf);
+               err = snd_config_get_string(conf, &str);
                if (err < 0) {
-                       ERR("Invalid type for %s", conf->id);
+                       ERR("Invalid type for %s", id);
                        return err;
                }
                if (strcmp(str, "output") == 0) {
@@ -67,7 +68,7 @@ int snd_seq_open(snd_seq_t **seqp, char *name,
                        if (streams != SND_SEQ_OPEN_DUPLEX)
                                return -EINVAL;
                } else {
-                       ERR("Invalid value for %s", conf->id);
+                       ERR("Invalid value for %s", id);
                        return -EINVAL;
                }
        }
@@ -76,9 +77,9 @@ int snd_seq_open(snd_seq_t **seqp, char *name,
                ERR("type is not defined");
                return err;
        }
-       err = snd_config_string_get(conf, &str);
+       err = snd_config_get_string(conf, &str);
        if (err < 0) {
-               ERR("Invalid type for %s", conf->id);
+               ERR("Invalid type for %s", snd_config_get_id(conf));
                return err;
        }
        err = snd_config_searchv(snd_config, &type_conf, "seqtype", str, 0);
@@ -87,25 +88,26 @@ int snd_seq_open(snd_seq_t **seqp, char *name,
                return err;
        }
        snd_config_foreach(i, type_conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "lib") == 0) {
-                       err = snd_config_string_get(n, &lib);
+               if (strcmp(id, "lib") == 0) {
+                       err = snd_config_get_string(n, &lib);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
                }
-               if (strcmp(n->id, "open") == 0) {
-                       err = snd_config_string_get(n, &open);
+               if (strcmp(id, "open") == 0) {
+                       err = snd_config_get_string(n, &open);
                        if (err < 0) {
-                               ERR("Invalid type for %s", n->id);
+                               ERR("Invalid type for %s", id);
                                return -EINVAL;
                        }
                        continue;
-                       ERR("Unknown field %s", n->id);
+                       ERR("Unknown field %s", id);
                        return -EINVAL;
                }
        }
index b8b78d3..a5b4131 100644 (file)
@@ -530,12 +530,13 @@ int _snd_seq_hw_open(snd_seq_t **handlep, char *name, snd_config_t *conf,
 {
        snd_config_iterator_t i;
        snd_config_foreach(i, conf) {
-               snd_config_t *n = snd_config_entry(i);
-               if (strcmp(n->id, "comment") == 0)
+               snd_config_t *n = snd_config_iterator_entry(i);
+               const char *id = snd_config_get_id(n);
+               if (strcmp(id, "comment") == 0)
                        continue;
-               if (strcmp(n->id, "type") == 0)
+               if (strcmp(id, "type") == 0)
                        continue;
-               if (strcmp(n->id, "streams") == 0)
+               if (strcmp(id, "streams") == 0)
                        continue;
                return -EINVAL;
        }