mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-10 13:30:01 -05:00
Added context handling for snd_config_expand.
PCM slave configuration is now dynamic.
This commit is contained in:
parent
43455a9268
commit
1e0c53a11c
26 changed files with 259 additions and 218 deletions
|
|
@ -912,7 +912,7 @@ ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, int samples)
|
|||
}
|
||||
|
||||
static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
|
||||
snd_config_t *root, snd_config_t *pcm_conf,
|
||||
snd_config_t *pcm_root, snd_config_t *pcm_conf,
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
const char *str;
|
||||
|
|
@ -923,7 +923,7 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
|
|||
const char *lib = NULL, *open_name = NULL;
|
||||
int (*open_func)(snd_pcm_t **, const char *,
|
||||
snd_config_t *, snd_config_t *,
|
||||
snd_pcm_stream_t, int);
|
||||
snd_pcm_stream_t, int) = NULL;
|
||||
void *h;
|
||||
if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
if (name)
|
||||
|
|
@ -942,7 +942,7 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
|
|||
SNDERR("Invalid type for %s", snd_config_get_id(conf));
|
||||
return err;
|
||||
}
|
||||
err = snd_config_search_definition(snd_config, "pcm_type", str, &type_conf);
|
||||
err = snd_config_search_definition(pcm_root, "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);
|
||||
|
|
@ -970,9 +970,8 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
|
|||
continue;
|
||||
}
|
||||
SNDERR("Unknown field %s", id);
|
||||
_err:
|
||||
snd_config_delete(type_conf);
|
||||
return -EINVAL;
|
||||
err = -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
if (!open_name) {
|
||||
|
|
@ -982,23 +981,20 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
|
|||
if (!lib)
|
||||
lib = ALSA_LIB;
|
||||
h = dlopen(lib, RTLD_NOW);
|
||||
if (h)
|
||||
open_func = dlsym(h, open_name);
|
||||
if (type_conf)
|
||||
snd_config_delete(type_conf);
|
||||
open_func = h ? dlsym(h, open_name) : NULL;
|
||||
err = 0;
|
||||
if (!h) {
|
||||
SNDERR("Cannot open shared library %s", lib);
|
||||
return -ENOENT;
|
||||
}
|
||||
if (!open_func) {
|
||||
err = -ENOENT;
|
||||
} else if (!open_func) {
|
||||
SNDERR("symbol %s is not defined inside %s", open_name, lib);
|
||||
dlclose(h);
|
||||
return -ENXIO;
|
||||
err = -ENXIO;
|
||||
}
|
||||
err = open_func(pcmp, name, root, pcm_conf, stream, mode);
|
||||
if (err < 0)
|
||||
return err;
|
||||
return 0;
|
||||
_err:
|
||||
if (type_conf)
|
||||
snd_config_delete(type_conf);
|
||||
return err >= 0 ? open_func(pcmp, name, pcm_root, pcm_conf, stream, mode) : err;
|
||||
}
|
||||
|
||||
static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, snd_config_t *root,
|
||||
|
|
@ -4287,7 +4283,8 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
|
|||
}
|
||||
if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
SNDERR("Invalid slave definition");
|
||||
return -EINVAL;
|
||||
err = -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
va_start(args, count);
|
||||
for (k = 0; k < count; ++k) {
|
||||
|
|
@ -4303,7 +4300,10 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
|
|||
if (strcmp(id, "comment") == 0)
|
||||
continue;
|
||||
if (strcmp(id, "pcm") == 0) {
|
||||
pcm_conf = n;
|
||||
if (pcm_conf != NULL)
|
||||
snd_config_delete(pcm_conf);
|
||||
if ((err = snd_config_copy(&pcm_conf, n)) < 0)
|
||||
goto _err;
|
||||
continue;
|
||||
}
|
||||
for (k = 0; k < count; ++k) {
|
||||
|
|
@ -4361,8 +4361,11 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
|
|||
}
|
||||
}
|
||||
*_pcm_conf = pcm_conf;
|
||||
return 0;
|
||||
pcm_conf = NULL;
|
||||
err = 0;
|
||||
_err:
|
||||
if (pcm_conf)
|
||||
snd_config_delete(pcm_conf);
|
||||
if (to_free)
|
||||
snd_config_delete(conf);
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -578,10 +578,12 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
|
|||
return err;
|
||||
if (snd_pcm_format_linear(sformat) != 1 &&
|
||||
sformat != SND_PCM_FORMAT_IMA_ADPCM) {
|
||||
snd_config_delete(sconf);
|
||||
SNDERR("invalid slave format");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_adpcm_open(pcmp, name, sformat, spcm, 1);
|
||||
|
|
|
|||
|
|
@ -451,10 +451,12 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
|
|||
return err;
|
||||
if (snd_pcm_format_linear(sformat) != 1 &&
|
||||
sformat != SND_PCM_FORMAT_A_LAW) {
|
||||
snd_config_delete(sconf);
|
||||
SNDERR("invalid slave format");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_alaw_open(pcmp, name, sformat, spcm, 1);
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_copy_open(pcmp, name, spcm, 1);
|
||||
|
|
|
|||
|
|
@ -505,10 +505,12 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (err < 0)
|
||||
return err;
|
||||
if (!fname && fd < 0) {
|
||||
snd_config_delete(sconf);
|
||||
SNDERR("file is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_file_open(pcmp, name, fname, fd, format, spcm, 1);
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ int snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
|
||||
int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_t *conf)
|
||||
{
|
||||
int err;
|
||||
char buf[256];
|
||||
|
|
@ -333,7 +333,7 @@ int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
|
|||
const char *lib = NULL, *install = NULL;
|
||||
snd_config_t *type = NULL, *args = NULL;
|
||||
snd_config_iterator_t i, next;
|
||||
int (*install_func)(snd_pcm_t *pcm, snd_config_t *args);
|
||||
int (*install_func)(snd_pcm_t *pcm, snd_config_t *args) = NULL;
|
||||
void *h;
|
||||
if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
SNDERR("Invalid hook definition");
|
||||
|
|
@ -364,7 +364,7 @@ int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
|
|||
SNDERR("Invalid type for %s", snd_config_get_id(type));
|
||||
return err;
|
||||
}
|
||||
err = snd_config_search_definition(snd_config, "pcm_hook_type", str, &type);
|
||||
err = snd_config_search_definition(root, "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);
|
||||
|
|
@ -392,9 +392,8 @@ int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
|
|||
continue;
|
||||
}
|
||||
SNDERR("Unknown field %s", id);
|
||||
_err:
|
||||
snd_config_delete(type);
|
||||
return -EINVAL;
|
||||
err = -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
if (!install) {
|
||||
|
|
@ -404,27 +403,27 @@ int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *conf)
|
|||
if (!lib)
|
||||
lib = ALSA_LIB;
|
||||
h = dlopen(lib, RTLD_NOW);
|
||||
if (h)
|
||||
install_func = dlsym(h, install);
|
||||
if (type)
|
||||
snd_config_delete(type);
|
||||
install_func = h ? dlsym(h, install) : NULL;
|
||||
err = 0;
|
||||
if (!h) {
|
||||
SNDERR("Cannot open shared library %s", lib);
|
||||
return -ENOENT;
|
||||
}
|
||||
if (!install_func) {
|
||||
err = -ENOENT;
|
||||
} else if (!install_func) {
|
||||
SNDERR("symbol %s is not defined inside %s", install, lib);
|
||||
dlclose(h);
|
||||
return -ENXIO;
|
||||
err = -ENXIO;
|
||||
}
|
||||
if (args && snd_config_get_string(args, &str) >= 0) {
|
||||
err = snd_config_search_definition(snd_config, "hook_args", str, &args);
|
||||
_err:
|
||||
if (type)
|
||||
snd_config_delete(type);
|
||||
if (err >= 0 && args && snd_config_get_string(args, &str) >= 0) {
|
||||
err = snd_config_search_definition(root, "hook_args", str, &args);
|
||||
if (err < 0) {
|
||||
SNDERR("unknown hook_args %s", str);
|
||||
return err;
|
||||
} else {
|
||||
err = install_func(pcm, args);
|
||||
snd_config_delete(args);
|
||||
}
|
||||
err = install_func(pcm, args);
|
||||
snd_config_delete(args);
|
||||
} else
|
||||
err = install_func(pcm, args);
|
||||
if (err < 0)
|
||||
|
|
@ -469,6 +468,7 @@ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_hooks_open(pcmp, name, spcm, 1);
|
||||
|
|
@ -482,15 +482,15 @@ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name,
|
|||
snd_config_t *n = snd_config_iterator_entry(i);
|
||||
const char *str;
|
||||
if (snd_config_get_string(n, &str) >= 0) {
|
||||
err = snd_config_search_definition(snd_config, "pcm_hook", str, &n);
|
||||
err = snd_config_search_definition(root, "pcm_hook", str, &n);
|
||||
if (err < 0) {
|
||||
SNDERR("unknown pcm_hook %s", str);
|
||||
return err;
|
||||
} else {
|
||||
err = snd_pcm_hook_add_conf(*pcmp, root, n);
|
||||
snd_config_delete(n);
|
||||
}
|
||||
err = snd_pcm_hook_add_conf(*pcmp, n);
|
||||
snd_config_delete(n);
|
||||
} else
|
||||
err = snd_pcm_hook_add_conf(*pcmp, n);
|
||||
err = snd_pcm_hook_add_conf(*pcmp, root, n);
|
||||
if (err < 0) {
|
||||
snd_pcm_close(*pcmp);
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -355,10 +355,12 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (err < 0)
|
||||
return err;
|
||||
if (snd_pcm_format_linear(sformat) != 1) {
|
||||
snd_config_delete(sconf);
|
||||
SNDERR("slave format is not linear");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_linear_open(pcmp, name, sformat, spcm, 1);
|
||||
|
|
|
|||
|
|
@ -653,17 +653,16 @@ int snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, unsigned int frequenc
|
|||
|
||||
|
||||
static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
|
||||
snd_config_t *conf)
|
||||
snd_config_t *root, snd_config_t *conf)
|
||||
{
|
||||
char buf[256];
|
||||
snd_config_iterator_t i, next;
|
||||
const char *lib = NULL, *open_name = NULL, *str = NULL;
|
||||
snd_config_t *c, *type_conf;
|
||||
int (*open_func)(snd_pcm_t *, const char *,
|
||||
snd_config_t *);
|
||||
snd_config_t *, snd_config_t *) = NULL;
|
||||
void *h;
|
||||
int err;
|
||||
int to_free = 0;
|
||||
if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
SNDERR("Invalid type for scope %s", str);
|
||||
err = -EINVAL;
|
||||
|
|
@ -679,7 +678,7 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
|
|||
SNDERR("Invalid type for %s", snd_config_get_id(c));
|
||||
goto _err;
|
||||
}
|
||||
err = snd_config_search_definition(snd_config, "pcm_scope_type", str, &type_conf);
|
||||
err = snd_config_search_definition(root, "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);
|
||||
|
|
@ -690,7 +689,7 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
|
|||
err = snd_config_get_string(n, &lib);
|
||||
if (err < 0) {
|
||||
SNDERR("Invalid type for %s", id);
|
||||
goto _err1;
|
||||
goto _err;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -698,13 +697,13 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
|
|||
err = snd_config_get_string(n, &open_name);
|
||||
if (err < 0) {
|
||||
SNDERR("Invalid type for %s", id);
|
||||
goto _err1;
|
||||
goto _err;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
SNDERR("Unknown field %s", id);
|
||||
err = -EINVAL;
|
||||
goto _err1;
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
if (!open_name) {
|
||||
|
|
@ -714,26 +713,20 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name,
|
|||
if (!lib)
|
||||
lib = ALSA_LIB;
|
||||
h = dlopen(lib, RTLD_NOW);
|
||||
open_func = h ? dlsym(h, open_name) : NULL;
|
||||
err = 0;
|
||||
if (!h) {
|
||||
SNDERR("Cannot open shared library %s", lib);
|
||||
err = -ENOENT;
|
||||
goto _err1;
|
||||
}
|
||||
open_func = dlsym(h, open_name);
|
||||
if (type_conf)
|
||||
snd_config_delete(type_conf);
|
||||
if (!open_func) {
|
||||
} else if (!open_func) {
|
||||
SNDERR("symbol %s is not defined inside %s", open_name, lib);
|
||||
dlclose(h);
|
||||
goto _err;
|
||||
err = -ENXIO;
|
||||
}
|
||||
return open_func(pcm, name, conf);
|
||||
_err1:
|
||||
snd_config_delete(type_conf);
|
||||
_err:
|
||||
if (to_free)
|
||||
snd_config_delete(conf);
|
||||
return err;
|
||||
_err:
|
||||
if (type_conf)
|
||||
snd_config_delete(type_conf);
|
||||
return err >= 0 ? open_func(pcm, name, root, conf) : err;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -783,6 +776,7 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_meter_open(pcmp, name, frequency > 0 ? (unsigned int) frequency : FREQUENCY, spcm, 1);
|
||||
|
|
@ -797,15 +791,15 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
|
|||
const char *id = snd_config_get_id(n);
|
||||
const char *str;
|
||||
if (snd_config_get_string(n, &str) >= 0) {
|
||||
err = snd_config_search_definition(snd_config, "pcm_scope", str, &n);
|
||||
err = snd_config_search_definition(root, "pcm_scope", str, &n);
|
||||
if (err < 0) {
|
||||
SNDERR("unknown pcm_scope %s", str);
|
||||
return err;
|
||||
} else {
|
||||
err = snd_pcm_meter_add_scope_conf(*pcmp, id, root, n);
|
||||
snd_config_delete(n);
|
||||
}
|
||||
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);
|
||||
err = snd_pcm_meter_add_scope_conf(*pcmp, id, root, n);
|
||||
if (err < 0) {
|
||||
snd_pcm_close(*pcmp);
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -466,10 +466,12 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
|
|||
return err;
|
||||
if (snd_pcm_format_linear(sformat) != 1 &&
|
||||
sformat != SND_PCM_FORMAT_MU_LAW) {
|
||||
snd_config_delete(sconf);
|
||||
SNDERR("invalid slave format");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_mulaw_open(pcmp, name, sformat, spcm, 1);
|
||||
|
|
|
|||
|
|
@ -819,6 +819,8 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
|
|||
err = snd_pcm_open_slave(&slaves_pcm[idx], root, slaves_conf[idx], stream, mode);
|
||||
if (err < 0)
|
||||
goto _free;
|
||||
snd_config_delete(slaves_conf[idx]);
|
||||
slaves_conf[idx] = NULL;
|
||||
}
|
||||
err = snd_pcm_multi_open(pcmp, name, slaves_count, master_slave,
|
||||
slaves_pcm, slaves_channels,
|
||||
|
|
@ -832,8 +834,13 @@ _free:
|
|||
snd_pcm_close(slaves_pcm[idx]);
|
||||
}
|
||||
}
|
||||
if (slaves_conf)
|
||||
if (slaves_conf) {
|
||||
for (idx = 0; idx < slaves_count; ++idx) {
|
||||
if (slaves_conf[idx])
|
||||
snd_config_delete(slaves_conf[idx]);
|
||||
}
|
||||
free(slaves_conf);
|
||||
}
|
||||
if (slaves_pcm)
|
||||
free(slaves_pcm);
|
||||
if (slaves_channels)
|
||||
|
|
|
|||
|
|
@ -752,11 +752,14 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
|
|||
ttable = malloc(MAX_CHANNELS * MAX_CHANNELS * sizeof(*ttable));
|
||||
err = snd_pcm_route_load_ttable(tt, ttable, MAX_CHANNELS, MAX_CHANNELS,
|
||||
&cused, &sused, -1);
|
||||
if (err < 0)
|
||||
if (err < 0) {
|
||||
snd_config_delete(sconf);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_plug_open(pcmp, name, ttable, MAX_CHANNELS, cused, sused, spcm, 1);
|
||||
|
|
|
|||
|
|
@ -567,10 +567,12 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
|
|||
return err;
|
||||
if (sformat != SND_PCM_FORMAT_UNKNOWN &&
|
||||
snd_pcm_format_linear(sformat) != 1) {
|
||||
snd_config_delete(sconf);
|
||||
SNDERR("slave format is not linear");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_rate_open(pcmp, name,
|
||||
|
|
|
|||
|
|
@ -883,16 +883,20 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
|
|||
return err;
|
||||
if (sformat != SND_PCM_FORMAT_UNKNOWN &&
|
||||
snd_pcm_format_linear(sformat) != 1) {
|
||||
snd_config_delete(sconf);
|
||||
SNDERR("slave format is not linear");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = snd_pcm_route_load_ttable(tt, ttable, MAX_CHANNELS, MAX_CHANNELS,
|
||||
&cused, &sused, schannels);
|
||||
if (err < 0)
|
||||
if (err < 0) {
|
||||
snd_config_delete(sconf);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_route_open(pcmp, name, sformat, schannels,
|
||||
|
|
|
|||
|
|
@ -1426,6 +1426,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name,
|
|||
/* FIXME: nothing strictly forces to have named definition */
|
||||
err = snd_config_get_string(sconf, &sname);
|
||||
if (err < 0) {
|
||||
snd_config_delete(sconf);
|
||||
SNDERR("slave.pcm is not a string");
|
||||
return err;
|
||||
}
|
||||
|
|
@ -1440,6 +1441,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name,
|
|||
const char *id = snd_config_get_id(n);
|
||||
err = safe_strtol(id, &cchannel);
|
||||
if (err < 0 || cchannel < 0) {
|
||||
snd_config_delete(sconf);
|
||||
SNDERR("Invalid client channel in binding: %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -1447,6 +1449,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name,
|
|||
channels = cchannel + 1;
|
||||
}
|
||||
if (channels == 0) {
|
||||
snd_config_delete(sconf);
|
||||
SNDERR("No bindings defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -1459,8 +1462,10 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name,
|
|||
long schannel = -1;
|
||||
cchannel = atoi(id);
|
||||
err = snd_config_get_integer(n, &schannel);
|
||||
if (err < 0)
|
||||
if (err < 0) {
|
||||
snd_config_delete(sconf);
|
||||
goto _free;
|
||||
}
|
||||
assert(schannel >= 0);
|
||||
assert(schannels <= 0 || schannel < schannels);
|
||||
channels_map[cchannel] = schannel;
|
||||
|
|
@ -1473,6 +1478,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name,
|
|||
(unsigned int) schannels,
|
||||
speriod_time, sbuffer_time,
|
||||
channels, channels_map, stream, mode);
|
||||
snd_config_delete(sconf);
|
||||
_free:
|
||||
free(channels_map);
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -720,7 +720,7 @@ int is_local(struct hostent *hent)
|
|||
}
|
||||
|
||||
int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
|
||||
snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf,
|
||||
snd_config_t *root, snd_config_t *conf,
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
snd_config_iterator_t i, next;
|
||||
|
|
@ -765,7 +765,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
|
|||
SNDERR("server is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_config_search_definition(snd_config, "server", server, &sconfig);
|
||||
err = snd_config_search_definition(root, "server", server, &sconfig);
|
||||
if (err < 0) {
|
||||
SNDERR("Unknown server %s", server);
|
||||
return -EINVAL;
|
||||
|
|
@ -804,9 +804,9 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
|
|||
continue;
|
||||
}
|
||||
SNDERR("Unknown field %s", id);
|
||||
_err:
|
||||
snd_config_delete(sconfig);
|
||||
return -EINVAL;
|
||||
_err:
|
||||
err = -EINVAL;
|
||||
goto __error;
|
||||
}
|
||||
|
||||
if (!host) {
|
||||
|
|
@ -825,9 +825,10 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
|
|||
local = is_local(h);
|
||||
if (!local) {
|
||||
SNDERR("%s is not the local host", host);
|
||||
return -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
err = snd_pcm_shm_open(pcmp, name, sockname, pcm_name, stream, mode);
|
||||
__error:
|
||||
snd_config_delete(sconfig);
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue