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;
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);
#
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
}
}
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
}
}
pcm.plug {
- args [ SLAVE ]
- args.SLAVE {
+ @args [ SLAVE ]
+ @args.SLAVE {
type string
}
type plug
}
pcm.shm {
- args [ SOCKET PCM ]
- args.SOCKET {
+ @args [ SOCKET PCM ]
+ @args.SOCKET {
type string
}
- args.PCM {
+ @args.PCM {
type string
}
type 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
}
}
pcm.file {
- args [ FILE FORMAT ]
- args.FILE {
+ @args [ FILE FORMAT ]
+ @args.FILE {
type string
}
- args.FORMAT {
+ @args.FORMAT {
type string
default raw
}
}
pcm.front {
- args [ CARD DEV ]
- args.CARD {
+ @args [ CARD DEV ]
+ @args.CARD {
type integer
default {
@func getenv
default 0
}
}
- args.DEV {
+ @args.DEV {
type integer
default {
@func getenv
default 0
}
}
- refer {
+ @refer {
filename {
@func concat
strings [
}
pcm.rear {
- args [ CARD DEV ]
- args.CARD {
+ @args [ CARD DEV ]
+ @args.CARD {
type integer
default {
@func getenv
default 0
}
}
- args.DEV {
+ @args.DEV {
type integer
default {
@func getenv
default 0
}
}
- refer {
+ @refer {
filename {
@func concat
strings [
}
pcm.center_lfe {
- args [ CARD DEV ]
- args.CARD {
+ @args [ CARD DEV ]
+ @args.CARD {
type integer
default {
@func getenv
default 0
}
}
- args.DEV {
+ @args.DEV {
type integer
default {
@func getenv
default 0
}
}
- refer {
+ @refer {
filename {
@func concat
strings [
}
pcm.surround40 {
- args [ CARD DEV ]
- args.CARD {
+ @args [ CARD DEV ]
+ @args.CARD {
type integer
default {
@func getenv
default 0
}
}
- args.DEV {
+ @args.DEV {
type integer
default {
@func getenv
default 0
}
}
- refer {
+ @refer {
filename {
@func concat
strings [
}
pcm.surround51 {
- args [ CARD DEV ]
- args.CARD {
+ @args [ CARD DEV ]
+ @args.CARD {
type integer
default {
@func getenv
default 0
}
}
- args.DEV {
+ @args.DEV {
type integer
default {
@func getenv
default 0
}
}
- refer {
+ @refer {
filename {
@func concat
strings [
}
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
default 0
}
}
- args.DEV {
+ @args.DEV {
type integer
default {
@func getenv
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 [
#
ctl.hw {
- args[ CARD ]
- args.CARD {
+ @args[ CARD ]
+ @args.CARD {
type integer
}
type hw
}
ctl.shm {
- args [ SOCKET CTL ]
- args.SOCKET {
+ @args [ SOCKET CTL ]
+ @args.SOCKET {
type string
}
- args.CTL {
+ @args.CTL {
type string
}
type shm
#
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
}
#
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
}
}
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
}
}
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
}
}
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
}
pcm.surround51_0 {
- args [ CARD ]
- args.CARD {
+ @args [ CARD ]
+ @args.CARD {
type integer
}
type multi
}
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
#
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
}
}
pcm.front_0 {
- args [ CARD ]
- args.CARD {
+ @args [ CARD ]
+ @args.CARD {
type integer
}
redir {
}
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
}
}
pcm.rear_0 {
- args [ CARD ]
- args.CARD {
+ @args [ CARD ]
+ @args.CARD {
type integer
}
redir {
}
pcm.surround40_0 {
- args [ CARD ]
- args.CARD {
+ @args [ CARD ]
+ @args.CARD {
type integer
}
type multi
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)
{
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)
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 */
* 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);
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);
}
#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;
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);
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;
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);
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;
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);
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);
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ goto _err;
}
continue;
}
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;
}
}
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);
{
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);
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);
err = snd_config_get_string(n, &host);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ goto _err;
}
continue;
}
err = snd_config_get_string(n, &sockname);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ goto _err;
}
continue;
}
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;
}
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);
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ goto _err;
}
continue;
}
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;
}
}
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);
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) {
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;
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");
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;
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;
}
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;
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);
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ goto _err;
}
continue;
}
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;
}
}
}
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;
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;
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);
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ goto _err1;
}
continue;
}
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) {
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;
}
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;
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,
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);
err = snd_config_get_string(n, &host);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ goto _err;
}
continue;
}
err = snd_config_get_string(n, &sockname);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ goto _err;
}
continue;
}
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;
}
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);
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ goto _err;
}
continue;
}
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;
}
}
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);
{
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;
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);
err = snd_config_get_string(n, &lib);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ goto _err;
}
continue;
}
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;
}
}
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);
{
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);