mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-06 13:29:59 -05:00
Improved .asoundrc changes
This commit is contained in:
parent
0300bbbbb3
commit
a275d66356
25 changed files with 888 additions and 612 deletions
|
|
@ -542,8 +542,9 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
|
|||
const char *sname = NULL;
|
||||
int err;
|
||||
snd_pcm_t *spcm;
|
||||
snd_config_t *slave = NULL;
|
||||
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
|
||||
long srate = -1;
|
||||
int srate = -1;
|
||||
snd_config_for_each(i, next, conf) {
|
||||
snd_config_t *n = snd_config_iterator_entry(i);
|
||||
const char *id = snd_config_get_id(n);
|
||||
|
|
@ -551,49 +552,25 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
|
|||
continue;
|
||||
if (strcmp(id, "type") == 0)
|
||||
continue;
|
||||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (strcmp(id, "sformat") == 0) {
|
||||
const char *f;
|
||||
err = snd_config_get_string(n, &f);
|
||||
if (err < 0) {
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
SNDERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (snd_pcm_format_linear(sformat) != 1) {
|
||||
SNDERR("sformat is not linear");
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (strcmp(id, "srate") == 0) {
|
||||
err = snd_config_get_integer(n, &srate);
|
||||
if (err < 0) {
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (strcmp(id, "slave") == 0) {
|
||||
slave = n;
|
||||
continue;
|
||||
}
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
SNDERR("sname is not defined");
|
||||
if (!slave) {
|
||||
SNDERR("slave is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (srate < 0) {
|
||||
SNDERR("srate is not defined");
|
||||
err = snd_pcm_slave_conf(slave, &sname, 2,
|
||||
SND_PCM_HW_PARAM_FORMAT, 0, &sformat,
|
||||
SND_PCM_HW_PARAM_RATE, 1, &srate);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (sformat != SND_PCM_FORMAT_UNKNOWN &&
|
||||
snd_pcm_format_linear(sformat) != 1) {
|
||||
SNDERR("slave format is not linear");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* This is needed cause snd_config_update may destroy config */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue