mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Added embedded/anonymous slave PCM definition
This commit is contained in:
parent
00c749f080
commit
6cb24e0186
15 changed files with 197 additions and 204 deletions
|
|
@ -21,6 +21,8 @@ pcm_scope_type.NAME {
|
||||||
# Slave PCM definition
|
# Slave PCM definition
|
||||||
pcm_slave.NAME {
|
pcm_slave.NAME {
|
||||||
pcm STR # PCM name
|
pcm STR # PCM name
|
||||||
|
# or
|
||||||
|
pcm { } # PCM definition
|
||||||
format STR # Format
|
format STR # Format
|
||||||
channels INT # Channels
|
channels INT # Channels
|
||||||
rate INT # Rate
|
rate INT # Rate
|
||||||
|
|
@ -46,6 +48,8 @@ pcm.NAME {
|
||||||
# or
|
# or
|
||||||
slave { # Slave definition or name
|
slave { # Slave definition or name
|
||||||
pcm STR # Slave PCM name
|
pcm STR # Slave PCM name
|
||||||
|
# or
|
||||||
|
pcm { } # Slave PCM definition
|
||||||
}
|
}
|
||||||
ttable { # Transfer table (bidimensional compound of
|
ttable { # Transfer table (bidimensional compound of
|
||||||
# cchannels * schannels numbers)
|
# cchannels * schannels numbers)
|
||||||
|
|
@ -63,6 +67,8 @@ pcm.NAME {
|
||||||
# or
|
# or
|
||||||
slave { # Slave definition or name
|
slave { # Slave definition or name
|
||||||
pcm STR # Slave PCM name
|
pcm STR # Slave PCM name
|
||||||
|
# or
|
||||||
|
pcm { } # Slave PCM definition
|
||||||
format STR # Slave format
|
format STR # Slave format
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,6 +78,8 @@ pcm.NAME {
|
||||||
# or
|
# or
|
||||||
slave { # Slave definition or name
|
slave { # Slave definition or name
|
||||||
pcm STR # Slave PCM name
|
pcm STR # Slave PCM name
|
||||||
|
# or
|
||||||
|
pcm { } # Slave PCM definition
|
||||||
[format STR] # Slave format (default client format)
|
[format STR] # Slave format (default client format)
|
||||||
rate INT # Slave rate
|
rate INT # Slave rate
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +90,8 @@ pcm.NAME {
|
||||||
# or
|
# or
|
||||||
slave { # Slave definition or name
|
slave { # Slave definition or name
|
||||||
pcm STR # Slave PCM name
|
pcm STR # Slave PCM name
|
||||||
|
# or
|
||||||
|
pcm { } # Slave PCM definition
|
||||||
[format STR] # Slave format (default client format)
|
[format STR] # Slave format (default client format)
|
||||||
[channels INT] # Slave channels (default client channels)
|
[channels INT] # Slave channels (default client channels)
|
||||||
}
|
}
|
||||||
|
|
@ -99,6 +109,8 @@ pcm.NAME {
|
||||||
# or
|
# or
|
||||||
N { # Slave definition for slave N
|
N { # Slave definition for slave N
|
||||||
pcm STR # Slave PCM name
|
pcm STR # Slave PCM name
|
||||||
|
# or
|
||||||
|
pcm { } # Slave PCM definition
|
||||||
channels INT # Slave channels
|
channels INT # Slave channels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -115,6 +127,8 @@ pcm.NAME {
|
||||||
# or
|
# or
|
||||||
slave { # Slave definition or name
|
slave { # Slave definition or name
|
||||||
pcm STR # Slave PCM name
|
pcm STR # Slave PCM name
|
||||||
|
# or
|
||||||
|
pcm { } # Slave PCM definition
|
||||||
}
|
}
|
||||||
file STR # File name
|
file STR # File name
|
||||||
# or
|
# or
|
||||||
|
|
@ -127,6 +141,8 @@ pcm.NAME {
|
||||||
# or
|
# or
|
||||||
slave { # Slave definition or name
|
slave { # Slave definition or name
|
||||||
pcm STR # Slave PCM name
|
pcm STR # Slave PCM name
|
||||||
|
# or
|
||||||
|
pcm { } # Slave PCM definition
|
||||||
}
|
}
|
||||||
[frequency INT] # Updates per second
|
[frequency INT] # Updates per second
|
||||||
scopes { # Scopes
|
scopes { # Scopes
|
||||||
|
|
@ -142,6 +158,8 @@ pcm.NAME {
|
||||||
# or
|
# or
|
||||||
slave { # Slave definition or name
|
slave { # Slave definition or name
|
||||||
pcm STR # Slave PCM name
|
pcm STR # Slave PCM name
|
||||||
|
# or
|
||||||
|
pcm { } # Slave PCM definition
|
||||||
[format STR] # Slave format (default client format)
|
[format STR] # Slave format (default client format)
|
||||||
[channels INT] # Slave channels (default client channels)
|
[channels INT] # Slave channels (default client channels)
|
||||||
}
|
}
|
||||||
|
|
@ -165,6 +183,8 @@ pcm.NAME {
|
||||||
# or
|
# or
|
||||||
slave { # Slave definition or name
|
slave { # Slave definition or name
|
||||||
pcm STR # Slave PCM name
|
pcm STR # Slave PCM name
|
||||||
|
# or
|
||||||
|
pcm { } # Slave PCM definition
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
211
src/pcm/pcm.c
211
src/pcm/pcm.c
|
|
@ -909,31 +909,93 @@ ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, int samples)
|
||||||
return samples * pcm->sample_bits / 8;
|
return samples * pcm->sample_bits / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
|
||||||
* \brief Opens a PCM
|
snd_config_t *pcm_conf,
|
||||||
* \param pcmp Returned PCM handle
|
snd_pcm_stream_t stream, int mode)
|
||||||
* \param name ASCII identifier of the PCM handle
|
|
||||||
* \param stream Wanted stream
|
|
||||||
* \param mode Open mode (see #SND_PCM_NONBLOCK, #SND_PCM_ASYNC)
|
|
||||||
* \return 0 on success otherwise a negative error code
|
|
||||||
*/
|
|
||||||
int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
|
|
||||||
snd_pcm_stream_t stream, int mode)
|
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
int err;
|
int err;
|
||||||
snd_config_t *pcm_conf, *conf, *type_conf = NULL;
|
snd_config_t *conf, *type_conf = NULL;
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *lib = NULL, *open_name = NULL;
|
const char *lib = NULL, *open_name = NULL;
|
||||||
int (*open_func)(snd_pcm_t **, const char *, snd_config_t *,
|
int (*open_func)(snd_pcm_t **, const char *, snd_config_t *,
|
||||||
snd_pcm_stream_t, int);
|
snd_pcm_stream_t, int);
|
||||||
void *h;
|
void *h;
|
||||||
const char *name1;
|
if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
|
||||||
assert(pcmp && name);
|
if (name)
|
||||||
err = snd_config_update();
|
SNDERR("Invalid type for PCM %s definition", name);
|
||||||
if (err < 0)
|
else
|
||||||
|
SNDERR("Invalid type for PCM definition");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
err = snd_config_search(pcm_conf, "type", &conf);
|
||||||
|
if (err < 0) {
|
||||||
|
SNDERR("type is not defined");
|
||||||
return err;
|
return err;
|
||||||
|
}
|
||||||
|
err = snd_config_get_string(conf, &str);
|
||||||
|
if (err < 0) {
|
||||||
|
SNDERR("Invalid type for %s", snd_config_get_id(conf));
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
err = snd_config_search_alias(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;
|
||||||
|
}
|
||||||
|
snd_config_for_each(i, next, type_conf) {
|
||||||
|
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(id, "lib") == 0) {
|
||||||
|
err = snd_config_get_string(n, &lib);
|
||||||
|
if (err < 0) {
|
||||||
|
SNDERR("Invalid type for %s", id);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp(id, "open") == 0) {
|
||||||
|
err = snd_config_get_string(n, &open_name);
|
||||||
|
if (err < 0) {
|
||||||
|
SNDERR("Invalid type for %s", id);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
SNDERR("Unknown field %s", id);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!open_name) {
|
||||||
|
open_name = buf;
|
||||||
|
snprintf(buf, sizeof(buf), "_snd_pcm_%s_open", str);
|
||||||
|
}
|
||||||
|
if (!lib)
|
||||||
|
lib = "libasound.so";
|
||||||
|
h = dlopen(lib, RTLD_NOW);
|
||||||
|
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);
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
return open_func(pcmp, name, pcm_conf, stream, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, const char *name,
|
||||||
|
snd_pcm_stream_t stream, int mode)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
snd_config_t *pcm_conf;
|
||||||
|
const char *name1;
|
||||||
|
|
||||||
err = snd_config_search_alias(snd_config, "pcm", name, &pcm_conf);
|
err = snd_config_search_alias(snd_config, "pcm", name, &pcm_conf);
|
||||||
name1 = name;
|
name1 = name;
|
||||||
|
|
@ -1005,69 +1067,37 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("Unknown PCM %s", name1);
|
SNDERR("Unknown PCM %s", name1);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
|
return snd_pcm_open_conf(pcmp, name, pcm_conf, stream, mode);
|
||||||
SNDERR("Invalid type for PCM %s definition", name1);
|
}
|
||||||
return -EINVAL;
|
|
||||||
}
|
#ifndef DOC_HIDDEN
|
||||||
err = snd_config_search(pcm_conf, "type", &conf);
|
int snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *conf,
|
||||||
if (err < 0) {
|
snd_pcm_stream_t stream, int mode)
|
||||||
SNDERR("type is not defined");
|
{
|
||||||
|
const char *str;
|
||||||
|
if (snd_config_get_string(conf, &str) >= 0)
|
||||||
|
return snd_pcm_open_noupdate(pcmp, str, stream, mode);
|
||||||
|
return snd_pcm_open_conf(pcmp, NULL, conf, stream, mode);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Opens a PCM
|
||||||
|
* \param pcmp Returned PCM handle
|
||||||
|
* \param name ASCII identifier of the PCM handle
|
||||||
|
* \param stream Wanted stream
|
||||||
|
* \param mode Open mode (see #SND_PCM_NONBLOCK, #SND_PCM_ASYNC)
|
||||||
|
* \return 0 on success otherwise a negative error code
|
||||||
|
*/
|
||||||
|
int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
|
||||||
|
snd_pcm_stream_t stream, int mode)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
assert(pcmp && name);
|
||||||
|
err = snd_config_update();
|
||||||
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
return snd_pcm_open_noupdate(pcmp, name, stream, mode);
|
||||||
err = snd_config_get_string(conf, &str);
|
|
||||||
if (err < 0) {
|
|
||||||
SNDERR("Invalid type for %s", snd_config_get_id(conf));
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
err = snd_config_search_alias(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;
|
|
||||||
}
|
|
||||||
snd_config_for_each(i, next, type_conf) {
|
|
||||||
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(id, "lib") == 0) {
|
|
||||||
err = snd_config_get_string(n, &lib);
|
|
||||||
if (err < 0) {
|
|
||||||
SNDERR("Invalid type for %s", id);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (strcmp(id, "open") == 0) {
|
|
||||||
err = snd_config_get_string(n, &open_name);
|
|
||||||
if (err < 0) {
|
|
||||||
SNDERR("Invalid type for %s", id);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
SNDERR("Unknown field %s", id);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!open_name) {
|
|
||||||
open_name = buf;
|
|
||||||
snprintf(buf, sizeof(buf), "_snd_pcm_%s_open", str);
|
|
||||||
}
|
|
||||||
if (!lib)
|
|
||||||
lib = "libasound.so";
|
|
||||||
h = dlopen(lib, RTLD_NOW);
|
|
||||||
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);
|
|
||||||
return -ENXIO;
|
|
||||||
}
|
|
||||||
return open_func(pcmp, name, pcm_conf, stream, mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -4281,7 +4311,7 @@ static const char *names[SND_PCM_HW_PARAM_LAST + 1] = {
|
||||||
[SND_PCM_HW_PARAM_BUFFER_TIME] = "buffer_time"
|
[SND_PCM_HW_PARAM_BUFFER_TIME] = "buffer_time"
|
||||||
};
|
};
|
||||||
|
|
||||||
int snd_pcm_slave_conf(snd_config_t *conf, const char **namep,
|
int snd_pcm_slave_conf(snd_config_t *conf, snd_config_t **pcm_conf,
|
||||||
unsigned int count, ...)
|
unsigned int count, ...)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
|
|
@ -4317,17 +4347,7 @@ int snd_pcm_slave_conf(snd_config_t *conf, const char **namep,
|
||||||
if (strcmp(id, "comment") == 0)
|
if (strcmp(id, "comment") == 0)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(id, "pcm") == 0) {
|
if (strcmp(id, "pcm") == 0) {
|
||||||
if (pcm_valid) {
|
*pcm_conf = n;
|
||||||
_duplicated:
|
|
||||||
SNDERR("duplicated %s", id);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
err = snd_config_get_string(n, namep);
|
|
||||||
if (err < 0) {
|
|
||||||
_invalid:
|
|
||||||
SNDERR("invalid type for %s", id);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
pcm_valid = 1;
|
pcm_valid = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -4338,15 +4358,16 @@ int snd_pcm_slave_conf(snd_config_t *conf, const char **namep,
|
||||||
assert(names[idx]);
|
assert(names[idx]);
|
||||||
if (strcmp(id, names[idx]) != 0)
|
if (strcmp(id, names[idx]) != 0)
|
||||||
continue;
|
continue;
|
||||||
if (fields[k].valid)
|
|
||||||
goto _duplicated;
|
|
||||||
switch (idx) {
|
switch (idx) {
|
||||||
case SND_PCM_HW_PARAM_FORMAT:
|
case SND_PCM_HW_PARAM_FORMAT:
|
||||||
{
|
{
|
||||||
snd_pcm_format_t f;
|
snd_pcm_format_t f;
|
||||||
err = snd_config_get_string(n, &str);
|
err = snd_config_get_string(n, &str);
|
||||||
if (err < 0)
|
if (err < 0) {
|
||||||
goto _invalid;
|
_invalid:
|
||||||
|
SNDERR("invalid type for %s", id);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
f = snd_pcm_format_value(str);
|
f = snd_pcm_format_value(str);
|
||||||
if (f == SND_PCM_FORMAT_UNKNOWN) {
|
if (f == SND_PCM_FORMAT_UNKNOWN) {
|
||||||
SNDERR("unknown format");
|
SNDERR("unknown format");
|
||||||
|
|
@ -4370,6 +4391,10 @@ int snd_pcm_slave_conf(snd_config_t *conf, const char **namep,
|
||||||
SNDERR("Unknown field %s", id);
|
SNDERR("Unknown field %s", id);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
if (!pcm_valid) {
|
||||||
|
SNDERR("missing field pcm");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
for (k = 0; k < count; ++k) {
|
for (k = 0; k < count; ++k) {
|
||||||
if (fields[k].mandatory && !fields[k].valid) {
|
if (fields[k].mandatory && !fields[k].valid) {
|
||||||
SNDERR("missing field %s", names[fields[k].index]);
|
SNDERR("missing field %s", names[fields[k].index]);
|
||||||
|
|
|
||||||
|
|
@ -552,10 +552,9 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
snd_pcm_t *spcm;
|
snd_pcm_t *spcm;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
snd_pcm_format_t sformat;
|
snd_pcm_format_t sformat;
|
||||||
snd_config_for_each(i, next, conf) {
|
snd_config_for_each(i, next, conf) {
|
||||||
snd_config_t *n = snd_config_iterator_entry(i);
|
snd_config_t *n = snd_config_iterator_entry(i);
|
||||||
|
|
@ -575,7 +574,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave is not defined");
|
SNDERR("slave is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 1,
|
err = snd_pcm_slave_conf(slave, &sconf, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
|
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -584,12 +583,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("invalid slave format");
|
SNDERR("invalid slave format");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
/* This is needed cause snd_config_update may destroy config */
|
err = snd_pcm_open_slave(&spcm, sconf, stream, mode);
|
||||||
sname = strdup(sname);
|
|
||||||
if (!sname)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = snd_pcm_open(&spcm, sname, stream, mode);
|
|
||||||
free((void *) sname);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_pcm_adpcm_open(pcmp, name, sformat, spcm, 1);
|
err = snd_pcm_adpcm_open(pcmp, name, sformat, spcm, 1);
|
||||||
|
|
|
||||||
|
|
@ -425,10 +425,9 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
snd_pcm_t *spcm;
|
snd_pcm_t *spcm;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
snd_pcm_format_t sformat;
|
snd_pcm_format_t sformat;
|
||||||
snd_config_for_each(i, next, conf) {
|
snd_config_for_each(i, next, conf) {
|
||||||
snd_config_t *n = snd_config_iterator_entry(i);
|
snd_config_t *n = snd_config_iterator_entry(i);
|
||||||
|
|
@ -448,7 +447,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave is not defined");
|
SNDERR("slave is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 1,
|
err = snd_pcm_slave_conf(slave, &sconf, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
|
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -457,12 +456,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("invalid slave format");
|
SNDERR("invalid slave format");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
/* This is needed cause snd_config_update may destroy config */
|
err = snd_pcm_open_slave(&spcm, sconf, stream, mode);
|
||||||
sname = strdup(sname);
|
|
||||||
if (!sname)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = snd_pcm_open(&spcm, sname, stream, mode);
|
|
||||||
free((void *) sname);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_pcm_alaw_open(pcmp, name, sformat, spcm, 1);
|
err = snd_pcm_alaw_open(pcmp, name, sformat, spcm, 1);
|
||||||
|
|
|
||||||
|
|
@ -191,14 +191,13 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int
|
||||||
}
|
}
|
||||||
|
|
||||||
int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
|
int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
|
||||||
snd_config_t *conf,
|
snd_config_t *conf,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
snd_pcm_t *spcm;
|
snd_pcm_t *spcm;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
snd_config_for_each(i, next, conf) {
|
snd_config_for_each(i, next, conf) {
|
||||||
snd_config_t *n = snd_config_iterator_entry(i);
|
snd_config_t *n = snd_config_iterator_entry(i);
|
||||||
const char *id = snd_config_get_id(n);
|
const char *id = snd_config_get_id(n);
|
||||||
|
|
@ -217,15 +216,10 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave is not defined");
|
SNDERR("slave is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 0);
|
err = snd_pcm_slave_conf(slave, &sconf, 0);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
/* This is needed cause snd_config_update may destroy config */
|
err = snd_pcm_open_slave(&spcm, sconf, stream, mode);
|
||||||
sname = strdup(sname);
|
|
||||||
if (!sname)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = snd_pcm_open(&spcm, sname, stream, mode);
|
|
||||||
free((void *) sname);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_pcm_copy_open(pcmp, name, spcm, 1);
|
err = snd_pcm_copy_open(pcmp, name, spcm, 1);
|
||||||
|
|
|
||||||
|
|
@ -457,10 +457,9 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
snd_pcm_t *spcm;
|
snd_pcm_t *spcm;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
const char *fname = NULL;
|
const char *fname = NULL;
|
||||||
const char *format = NULL;
|
const char *format = NULL;
|
||||||
long fd = -1;
|
long fd = -1;
|
||||||
|
|
@ -501,19 +500,14 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave is not defined");
|
SNDERR("slave is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 0);
|
err = snd_pcm_slave_conf(slave, &sconf, 0);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
if (!fname && fd < 0) {
|
if (!fname && fd < 0) {
|
||||||
SNDERR("file is not defined");
|
SNDERR("file is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
/* This is needed cause snd_config_update may destroy config */
|
err = snd_pcm_open_slave(&spcm, sconf, stream, mode);
|
||||||
sname = strdup(sname);
|
|
||||||
if (!sname)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = snd_pcm_open(&spcm, sname, stream, mode);
|
|
||||||
free((void *) sname);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_pcm_file_open(pcmp, name, fname, fd, format, spcm, 1);
|
err = snd_pcm_file_open(pcmp, name, fname, fd, format, spcm, 1);
|
||||||
|
|
|
||||||
|
|
@ -330,10 +330,9 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname;
|
|
||||||
int err;
|
int err;
|
||||||
snd_pcm_t *spcm;
|
snd_pcm_t *spcm;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
snd_pcm_format_t sformat;
|
snd_pcm_format_t sformat;
|
||||||
snd_config_for_each(i, next, conf) {
|
snd_config_for_each(i, next, conf) {
|
||||||
snd_config_t *n = snd_config_iterator_entry(i);
|
snd_config_t *n = snd_config_iterator_entry(i);
|
||||||
|
|
@ -353,7 +352,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave is not defined");
|
SNDERR("slave is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 1,
|
err = snd_pcm_slave_conf(slave, &sconf, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
|
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -361,12 +360,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave format is not linear");
|
SNDERR("slave format is not linear");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
/* This is needed cause snd_config_update may destroy config */
|
err = snd_pcm_open_slave(&spcm, sconf, stream, mode);
|
||||||
sname = strdup(sname);
|
|
||||||
if (!sname)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = snd_pcm_open(&spcm, sname, stream, mode);
|
|
||||||
free((void *) sname);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_pcm_linear_open(pcmp, name, sformat, spcm, 1);
|
err = snd_pcm_linear_open(pcmp, name, sformat, spcm, 1);
|
||||||
|
|
|
||||||
|
|
@ -527,9 +527,12 @@ int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy, int orde
|
||||||
snd_pcm_hw_strategy_simple_choices_list_t *choices);
|
snd_pcm_hw_strategy_simple_choices_list_t *choices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int snd_pcm_slave_conf(snd_config_t *conf, const char **namep,
|
int snd_pcm_slave_conf(snd_config_t *conf, snd_config_t **pcm_conf,
|
||||||
unsigned int count, ...);
|
unsigned int count, ...);
|
||||||
|
|
||||||
|
int snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *conf,
|
||||||
|
snd_pcm_stream_t stream, int mode);
|
||||||
|
|
||||||
#define SND_PCM_HW_PARBIT_ACCESS (1U << SND_PCM_HW_PARAM_ACCESS)
|
#define SND_PCM_HW_PARBIT_ACCESS (1U << SND_PCM_HW_PARAM_ACCESS)
|
||||||
#define SND_PCM_HW_PARBIT_FORMAT (1U << SND_PCM_HW_PARAM_FORMAT)
|
#define SND_PCM_HW_PARBIT_FORMAT (1U << SND_PCM_HW_PARAM_FORMAT)
|
||||||
#define SND_PCM_HW_PARBIT_SUBFORMAT (1U << SND_PCM_HW_PARAM_SUBFORMAT)
|
#define SND_PCM_HW_PARBIT_SUBFORMAT (1U << SND_PCM_HW_PARAM_SUBFORMAT)
|
||||||
|
|
|
||||||
|
|
@ -716,10 +716,9 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
snd_pcm_t *spcm;
|
snd_pcm_t *spcm;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
long frequency = -1;
|
long frequency = -1;
|
||||||
snd_config_t *scopes = NULL;
|
snd_config_t *scopes = NULL;
|
||||||
snd_config_for_each(i, next, conf) {
|
snd_config_for_each(i, next, conf) {
|
||||||
|
|
@ -756,15 +755,10 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave is not defined");
|
SNDERR("slave is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 0);
|
err = snd_pcm_slave_conf(slave, &sconf, 0);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
/* This is needed cause snd_config_update may destroy config */
|
err = snd_pcm_open_slave(&spcm, sconf, stream, mode);
|
||||||
sname = strdup(sname);
|
|
||||||
if (!sname)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = snd_pcm_open(&spcm, sname, stream, mode);
|
|
||||||
free((void *) sname);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_pcm_meter_open(pcmp, name, frequency > 0 ? (unsigned int) frequency : FREQUENCY, spcm, 1);
|
err = snd_pcm_meter_open(pcmp, name, frequency > 0 ? (unsigned int) frequency : FREQUENCY, spcm, 1);
|
||||||
|
|
|
||||||
|
|
@ -440,10 +440,9 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
snd_pcm_t *spcm;
|
snd_pcm_t *spcm;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
snd_pcm_format_t sformat;
|
snd_pcm_format_t sformat;
|
||||||
snd_config_for_each(i, next, conf) {
|
snd_config_for_each(i, next, conf) {
|
||||||
snd_config_t *n = snd_config_iterator_entry(i);
|
snd_config_t *n = snd_config_iterator_entry(i);
|
||||||
|
|
@ -463,7 +462,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave is not defined");
|
SNDERR("slave is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 1,
|
err = snd_pcm_slave_conf(slave, &sconf, 1,
|
||||||
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
|
SND_PCM_HW_PARAM_FORMAT, 1, &sformat);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -472,12 +471,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("invalid slave format");
|
SNDERR("invalid slave format");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
/* This is needed cause snd_config_update may destroy config */
|
err = snd_pcm_open_slave(&spcm, sconf, stream, mode);
|
||||||
sname = strdup(sname);
|
|
||||||
if (!sname)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = snd_pcm_open(&spcm, sname, stream, mode);
|
|
||||||
free((void *) sname);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_pcm_mulaw_open(pcmp, name, sformat, spcm, 1);
|
err = snd_pcm_mulaw_open(pcmp, name, sformat, spcm, 1);
|
||||||
|
|
|
||||||
|
|
@ -655,7 +655,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
||||||
int err;
|
int err;
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
const char **slaves_id = NULL;
|
const char **slaves_id = NULL;
|
||||||
char **slaves_name = NULL;
|
snd_config_t **slaves_conf = NULL;
|
||||||
snd_pcm_t **slaves_pcm = NULL;
|
snd_pcm_t **slaves_pcm = NULL;
|
||||||
unsigned int *slaves_channels = NULL;
|
unsigned int *slaves_channels = NULL;
|
||||||
int *channels_sidx = NULL;
|
int *channels_sidx = NULL;
|
||||||
|
|
@ -718,7 +718,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
slaves_id = calloc(slaves_count, sizeof(*slaves_id));
|
slaves_id = calloc(slaves_count, sizeof(*slaves_id));
|
||||||
slaves_name = calloc(slaves_count, sizeof(*slaves_name));
|
slaves_conf = calloc(slaves_count, sizeof(*slaves_conf));
|
||||||
slaves_pcm = calloc(slaves_count, sizeof(*slaves_pcm));
|
slaves_pcm = calloc(slaves_count, sizeof(*slaves_pcm));
|
||||||
slaves_channels = calloc(slaves_count, sizeof(*slaves_channels));
|
slaves_channels = calloc(slaves_count, sizeof(*slaves_channels));
|
||||||
channels_sidx = calloc(channels_count, sizeof(*channels_sidx));
|
channels_sidx = calloc(channels_count, sizeof(*channels_sidx));
|
||||||
|
|
@ -729,14 +729,12 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
||||||
idx = 0;
|
idx = 0;
|
||||||
snd_config_for_each(i, inext, slaves) {
|
snd_config_for_each(i, inext, slaves) {
|
||||||
snd_config_t *m = snd_config_iterator_entry(i);
|
snd_config_t *m = snd_config_iterator_entry(i);
|
||||||
const char *n;
|
|
||||||
int channels;
|
int channels;
|
||||||
slaves_id[idx] = snd_config_get_id(m);
|
slaves_id[idx] = snd_config_get_id(m);
|
||||||
err = snd_pcm_slave_conf(m, &n, 1,
|
err = snd_pcm_slave_conf(m, &slaves_conf[idx], 1,
|
||||||
SND_PCM_HW_PARAM_CHANNELS, 1, &channels);
|
SND_PCM_HW_PARAM_CHANNELS, 1, &channels);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto _free;
|
goto _free;
|
||||||
slaves_name[idx] = strdup(n);
|
|
||||||
slaves_channels[idx] = channels;
|
slaves_channels[idx] = channels;
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
|
|
@ -807,7 +805,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (idx = 0; idx < slaves_count; ++idx) {
|
for (idx = 0; idx < slaves_count; ++idx) {
|
||||||
err = snd_pcm_open(&slaves_pcm[idx], slaves_name[idx], stream, mode);
|
err = snd_pcm_open_slave(&slaves_pcm[idx], slaves_conf[idx], stream, mode);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto _free;
|
goto _free;
|
||||||
}
|
}
|
||||||
|
|
@ -821,12 +819,10 @@ _free:
|
||||||
for (idx = 0; idx < slaves_count; ++idx) {
|
for (idx = 0; idx < slaves_count; ++idx) {
|
||||||
if (slaves_pcm[idx])
|
if (slaves_pcm[idx])
|
||||||
snd_pcm_close(slaves_pcm[idx]);
|
snd_pcm_close(slaves_pcm[idx]);
|
||||||
if (slaves_name[idx])
|
|
||||||
free(slaves_name[idx]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (slaves_name)
|
if (slaves_conf)
|
||||||
free(slaves_name);
|
free(slaves_conf);
|
||||||
if (slaves_pcm)
|
if (slaves_pcm)
|
||||||
free(slaves_pcm);
|
free(slaves_pcm);
|
||||||
if (slaves_channels)
|
if (slaves_channels)
|
||||||
|
|
|
||||||
|
|
@ -715,10 +715,9 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
snd_pcm_t *spcm;
|
snd_pcm_t *spcm;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
snd_config_t *tt = NULL;
|
snd_config_t *tt = NULL;
|
||||||
snd_pcm_route_ttable_entry_t *ttable = NULL;
|
snd_pcm_route_ttable_entry_t *ttable = NULL;
|
||||||
unsigned int cused, sused;
|
unsigned int cused, sused;
|
||||||
|
|
@ -748,7 +747,7 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave is not defined");
|
SNDERR("slave is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 0);
|
err = snd_pcm_slave_conf(slave, &sconf, 0);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
if (tt) {
|
if (tt) {
|
||||||
|
|
@ -759,12 +758,7 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is needed cause snd_config_update may destroy config */
|
err = snd_pcm_open_slave(&spcm, sconf, stream, mode);
|
||||||
sname = strdup(sname);
|
|
||||||
if (!sname)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = snd_pcm_open(&spcm, sname, stream, mode);
|
|
||||||
free((void *) sname);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_pcm_plug_open(pcmp, name, ttable, MAX_CHANNELS, cused, sused, spcm, 1);
|
err = snd_pcm_plug_open(pcmp, name, ttable, MAX_CHANNELS, cused, sused, spcm, 1);
|
||||||
|
|
|
||||||
|
|
@ -539,10 +539,9 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
snd_pcm_t *spcm;
|
snd_pcm_t *spcm;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
|
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
|
||||||
int srate = -1;
|
int srate = -1;
|
||||||
snd_config_for_each(i, next, conf) {
|
snd_config_for_each(i, next, conf) {
|
||||||
|
|
@ -563,7 +562,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave is not defined");
|
SNDERR("slave is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 2,
|
err = snd_pcm_slave_conf(slave, &sconf, 2,
|
||||||
SND_PCM_HW_PARAM_FORMAT, 0, &sformat,
|
SND_PCM_HW_PARAM_FORMAT, 0, &sformat,
|
||||||
SND_PCM_HW_PARAM_RATE, 1, &srate);
|
SND_PCM_HW_PARAM_RATE, 1, &srate);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
|
@ -573,12 +572,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("slave format is not linear");
|
SNDERR("slave format is not linear");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
/* This is needed cause snd_config_update may destroy config */
|
err = snd_pcm_open_slave(&spcm, sconf, stream, mode);
|
||||||
sname = strdup(sname);
|
|
||||||
if (!sname)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = snd_pcm_open(&spcm, sname, stream, mode);
|
|
||||||
free((void *) sname);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_pcm_rate_open(pcmp, name,
|
err = snd_pcm_rate_open(pcmp, name,
|
||||||
|
|
|
||||||
|
|
@ -843,10 +843,9 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
snd_pcm_t *spcm;
|
snd_pcm_t *spcm;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
|
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
|
||||||
int schannels = -1;
|
int schannels = -1;
|
||||||
snd_config_t *tt = NULL;
|
snd_config_t *tt = NULL;
|
||||||
|
|
@ -882,7 +881,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
|
||||||
SNDERR("ttable is not defined");
|
SNDERR("ttable is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 2,
|
err = snd_pcm_slave_conf(slave, &sconf, 2,
|
||||||
SND_PCM_HW_PARAM_FORMAT, 0, &sformat,
|
SND_PCM_HW_PARAM_FORMAT, 0, &sformat,
|
||||||
SND_PCM_HW_PARAM_CHANNELS, 0, &schannels);
|
SND_PCM_HW_PARAM_CHANNELS, 0, &schannels);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
|
@ -898,12 +897,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
/* This is needed cause snd_config_update may destroy config */
|
err = snd_pcm_open_slave(&spcm, sconf, stream, mode);
|
||||||
sname = strdup(sname);
|
|
||||||
if (!sname)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = snd_pcm_open(&spcm, sname, stream, mode);
|
|
||||||
free((void *) sname);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_pcm_route_open(pcmp, name, sformat, schannels,
|
err = snd_pcm_route_open(pcmp, name, sformat, schannels,
|
||||||
|
|
|
||||||
|
|
@ -1371,10 +1371,11 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
||||||
snd_pcm_stream_t stream, int mode)
|
snd_pcm_stream_t stream, int mode)
|
||||||
{
|
{
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
const char *sname = NULL;
|
const char *slave_name = NULL;
|
||||||
|
const char *sname;
|
||||||
snd_config_t *bindings = NULL;
|
snd_config_t *bindings = NULL;
|
||||||
int err;
|
int err;
|
||||||
snd_config_t *slave = NULL;
|
snd_config_t *slave = NULL, *sconf;
|
||||||
unsigned int *channels_map;
|
unsigned int *channels_map;
|
||||||
unsigned int channels = 0;
|
unsigned int channels = 0;
|
||||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
|
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
|
||||||
|
|
@ -1391,7 +1392,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
||||||
if (strcmp(id, "type") == 0)
|
if (strcmp(id, "type") == 0)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(id, "slave") == 0) {
|
if (strcmp(id, "slave") == 0) {
|
||||||
err = snd_config_get_string(n, &sname);
|
err = snd_config_get_string(n, &slave_name);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
SNDERR("Invalid type for %s", id);
|
SNDERR("Invalid type for %s", id);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -1414,7 +1415,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
||||||
SNDERR("slave is not defined");
|
SNDERR("slave is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = snd_pcm_slave_conf(slave, &sname, 5,
|
err = snd_pcm_slave_conf(slave, &sconf, 5,
|
||||||
SND_PCM_HW_PARAM_CHANNELS, 0, &schannels,
|
SND_PCM_HW_PARAM_CHANNELS, 0, &schannels,
|
||||||
SND_PCM_HW_PARAM_FORMAT, 0, &sformat,
|
SND_PCM_HW_PARAM_FORMAT, 0, &sformat,
|
||||||
SND_PCM_HW_PARAM_RATE, 0, &srate,
|
SND_PCM_HW_PARAM_RATE, 0, &srate,
|
||||||
|
|
@ -1422,6 +1423,14 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
||||||
SND_PCM_HW_PARAM_BUFFER_TIME, 0, &sbuffer_time);
|
SND_PCM_HW_PARAM_BUFFER_TIME, 0, &sbuffer_time);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
/* FIXME: nothing strictly forces to have named definition */
|
||||||
|
err = snd_config_get_string(sconf, &sname);
|
||||||
|
if (err < 0) {
|
||||||
|
SNDERR("slave.pcm is not a string");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
if (!bindings) {
|
if (!bindings) {
|
||||||
SNDERR("bindings is not defined");
|
SNDERR("bindings is not defined");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -1463,10 +1472,10 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
||||||
}
|
}
|
||||||
if (schannels <= 0)
|
if (schannels <= 0)
|
||||||
schannels = schannel_max + 1;
|
schannels = schannel_max + 1;
|
||||||
err = snd_pcm_share_open(pcmp, name, sname, sformat, srate,
|
err = snd_pcm_share_open(pcmp, name, sname, sformat, srate,
|
||||||
(unsigned int) schannels,
|
(unsigned int) schannels,
|
||||||
speriod_time, sbuffer_time,
|
speriod_time, sbuffer_time,
|
||||||
channels, channels_map, stream, mode);
|
channels, channels_map, stream, mode);
|
||||||
_free:
|
_free:
|
||||||
free(channels_map);
|
free(channels_map);
|
||||||
return err;
|
return err;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue