summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aserver/aserver.c10
-rw-r--r--src/control/control_shm.c14
-rw-r--r--src/pcm/pcm.c15
-rw-r--r--src/pcm/pcm_adpcm.c25
-rw-r--r--src/pcm/pcm_alaw.c25
-rw-r--r--src/pcm/pcm_file.c21
-rw-r--r--src/pcm/pcm_hw.c21
-rw-r--r--src/pcm/pcm_linear.c25
-rw-r--r--src/pcm/pcm_mulaw.c25
-rw-r--r--src/pcm/pcm_multi.c70
-rw-r--r--src/pcm/pcm_null.c1
-rw-r--r--src/pcm/pcm_plug.c54
-rw-r--r--src/pcm/pcm_rate.c31
-rw-r--r--src/pcm/pcm_route.c45
-rw-r--r--src/pcm/pcm_share.c13
-rw-r--r--src/pcm/pcm_shm.c14
-rw-r--r--src/rawmidi/rawmidi.c14
-rw-r--r--src/seq/seq.c14
18 files changed, 321 insertions, 116 deletions
diff --git a/aserver/aserver.c b/aserver/aserver.c
index 6434aa05..384054e3 100644
--- a/aserver/aserver.c
+++ b/aserver/aserver.c
@@ -966,7 +966,7 @@ int main(int argc, char **argv)
srvname = argv[optind];
err = snd_config_searchv(snd_config, &conf, "server", srvname, 0);
if (err < 0) {
- ERROR("unknown server %s", srvname);
+ ERROR("Missing definition for server %s", srvname);
return 1;
}
snd_config_foreach(i, conf) {
@@ -976,7 +976,7 @@ int main(int argc, char **argv)
if (strcmp(n->id, "host") == 0) {
err = snd_config_string_get(n, &host);
if (err < 0) {
- ERROR("Invalid type for host");
+ ERROR("Invalid type for %s", n->id);
return 1;
}
continue;
@@ -984,7 +984,7 @@ int main(int argc, char **argv)
if (strcmp(n->id, "socket") == 0) {
err = snd_config_string_get(n, &socket);
if (err < 0) {
- ERROR("Invalid type for socket");
+ ERROR("Invalid type for %s", n->id);
return 1;
}
continue;
@@ -992,12 +992,12 @@ int main(int argc, char **argv)
if (strcmp(n->id, "port") == 0) {
err = snd_config_integer_get(n, &port);
if (err < 0) {
- ERROR("Invalid type for port");
+ ERROR("Invalid type for %s", n->id);
return 1;
}
continue;
}
- ERROR("Unknown field: %s", n->id);
+ ERROR("Unknown field %s", n->id);
return 1;
}
if (!host) {
diff --git a/src/control/control_shm.c b/src/control/control_shm.c
index e8086f19..ccf217ba 100644
--- a/src/control/control_shm.c
+++ b/src/control/control_shm.c
@@ -442,7 +442,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
if (strcmp(n->id, "server") == 0) {
err = snd_config_string_get(n, &server);
if (err < 0) {
- ERR("Invalid type for server");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -450,12 +450,12 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (err < 0) {
- ERR("Invalid type for sname");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
}
- ERR("Unknown field: %s", n->id);
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
if (!sname) {
@@ -478,7 +478,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
if (strcmp(n->id, "host") == 0) {
err = snd_config_string_get(n, &host);
if (err < 0) {
- ERR("Invalid type for host");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -486,7 +486,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
if (strcmp(n->id, "socket") == 0) {
err = snd_config_string_get(n, &socket);
if (err < 0) {
- ERR("Invalid type for socket");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -494,12 +494,12 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
if (strcmp(n->id, "port") == 0) {
err = snd_config_integer_get(n, &port);
if (err < 0) {
- ERR("Invalid type for port");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
}
- ERR("Unknown field: %s", n->id);
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index c4ca15b9..eb449b14 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -826,14 +826,14 @@ int snd_pcm_open(snd_pcm_t **pcmp, char *name,
return -ENOENT;
}
if (snd_config_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
- ERR("Invalid type for PCM definition");
+ ERR("Invalid type for PCM %s definition", name);
return -EINVAL;
}
err = snd_config_search(pcm_conf, "stream", &conf);
if (err >= 0) {
err = snd_config_string_get(conf, &str);
if (err < 0) {
- ERR("Invalid type for stream");
+ ERR("Invalid type for %s", conf->id);
return err;
}
if (strcmp(str, "playback") == 0) {
@@ -843,7 +843,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, char *name,
if (stream != SND_PCM_STREAM_CAPTURE)
return -EINVAL;
} else {
- ERR("Invalid value for stream");
+ ERR("Invalid value for %s", conf->id);
return -EINVAL;
}
}
@@ -854,7 +854,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, char *name,
}
err = snd_config_string_get(conf, &str);
if (err < 0) {
- ERR("Invalid type for type");
+ ERR("Invalid type for %s", conf->id);
return err;
}
err = snd_config_searchv(snd_config, &type_conf, "pcmtype", str, 0);
@@ -869,7 +869,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, char *name,
if (strcmp(n->id, "lib") == 0) {
err = snd_config_string_get(n, &lib);
if (err < 0) {
- ERR("Invalid type for lib");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -877,11 +877,11 @@ int snd_pcm_open(snd_pcm_t **pcmp, char *name,
if (strcmp(n->id, "open") == 0) {
err = snd_config_string_get(n, &open);
if (err < 0) {
- ERR("Invalid type for open");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
- ERR("Unknown field: %s", n->id);
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
}
@@ -1962,6 +1962,7 @@ int _snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
params->fail_mask = snd_pcm_hw_info_fail_mask(&info);
return err;
}
+ params->fail_mask = 0;
if ((err = pcm->ops->hw_params(pcm->op_arg, params)) < 0)
return err;
diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c
index 70882a03..6a45d761 100644
--- a/src/pcm/pcm_adpcm.c
+++ b/src/pcm/pcm_adpcm.c
@@ -569,27 +569,42 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name,
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "sformat") == 0) {
char *f;
err = snd_config_string_get(n, &f);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
sformat = snd_pcm_format_value(f);
- if (sformat < 0)
+ if (sformat < 0) {
+ ERR("Unknown sformat");
return -EINVAL;
+ }
if (snd_pcm_format_linear(sformat) != 1 &&
- sformat != SND_PCM_FORMAT_IMA_ADPCM)
+ sformat != SND_PCM_FORMAT_IMA_ADPCM) {
+ ERR("Invalid sformat");
return -EINVAL;
+ }
continue;
}
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
- if (!sname || !sformat)
+ if (!sname) {
+ ERR("sname is not defined");
return -EINVAL;
+ }
+ if (sformat < 0) {
+ ERR("sformat is not defined");
+ return -EINVAL;
+ }
/* This is needed cause snd_config_update may destroy config */
sname = strdup(sname);
if (!sname)
diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c
index 16dd7399..4ea75ec4 100644
--- a/src/pcm/pcm_alaw.c
+++ b/src/pcm/pcm_alaw.c
@@ -436,27 +436,42 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name,
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "sformat") == 0) {
char *f;
err = snd_config_string_get(n, &f);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
sformat = snd_pcm_format_value(f);
- if (sformat < 0)
+ if (sformat < 0) {
+ ERR("Unknown sformat");
return -EINVAL;
+ }
if (snd_pcm_format_linear(sformat) != 1 &&
- sformat != SND_PCM_FORMAT_A_LAW)
+ sformat != SND_PCM_FORMAT_A_LAW) {
+ ERR("Invalid sformat");
return -EINVAL;
+ }
continue;
}
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
- if (!sname || !sformat)
+ if (!sname) {
+ ERR("sname is not defined");
return -EINVAL;
+ }
+ if (sformat < 0) {
+ ERR("sformat is not defined");
+ return -EINVAL;
+ }
/* This is needed cause snd_config_update may destroy config */
sname = strdup(sname);
if (!sname)
diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c
index 1cf456a6..bebc751e 100644
--- a/src/pcm/pcm_file.c
+++ b/src/pcm/pcm_file.c
@@ -420,29 +420,42 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, char *name,
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "format") == 0) {
err = snd_config_string_get(n, &format);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "file") == 0) {
err = snd_config_string_get(n, &fname);
if (err < 0) {
err = snd_config_integer_get(n, &fd);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
}
continue;
}
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
- if (!sname || (!fname && fd < 0))
+ if (!sname) {
+ ERR("sname is not defined");
return -EINVAL;
+ }
+ if (!fname && fd < 0) {
+ ERR("file is not defined");
+ return -EINVAL;
+ }
if (fname) {
fname = strdup(fname);
if (!fname)
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 2e3f14fc..c874634e 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -707,30 +707,41 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
err = snd_config_integer_get(n, &card);
if (err < 0) {
err = snd_config_string_get(n, &str);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
card = snd_card_get_index(str);
- if (card < 0)
+ if (card < 0) {
+ ERR("Invalid value for %s", n->id);
return card;
+ }
}
continue;
}
if (strcmp(n->id, "device") == 0) {
err = snd_config_integer_get(n, &device);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return err;
+ }
continue;
}
if (strcmp(n->id, "subdevice") == 0) {
err = snd_config_integer_get(n, &subdevice);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return err;
+ }
continue;
}
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
- if (card < 0)
+ if (card < 0) {
+ ERR("card is not defined");
return -EINVAL;
+ }
return snd_pcm_hw_open(pcmp, name, card, device, subdevice, stream, mode);
}
diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c
index ba577ff9..5a608d4a 100644
--- a/src/pcm/pcm_linear.c
+++ b/src/pcm/pcm_linear.c
@@ -280,26 +280,41 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name,
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "sformat") == 0) {
char *f;
err = snd_config_string_get(n, &f);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
sformat = snd_pcm_format_value(f);
- if (sformat < 0)
+ if (sformat < 0) {
+ ERR("Unknown sformat");
return -EINVAL;
- if (snd_pcm_format_linear(sformat) != 1)
+ }
+ if (snd_pcm_format_linear(sformat) != 1) {
+ ERR("sformat is not linear");
return -EINVAL;
+ }
continue;
}
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
- if (!sname || !sformat)
+ if (!sname) {
+ ERR("sname is not defined");
return -EINVAL;
+ }
+ if (sformat < 0) {
+ ERR("sformat is not defined");
+ return -EINVAL;
+ }
/* This is needed cause snd_config_update may destroy config */
sname = strdup(sname);
if (!sname)
diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c
index 90aa36a0..489a6972 100644
--- a/src/pcm/pcm_mulaw.c
+++ b/src/pcm/pcm_mulaw.c
@@ -453,27 +453,42 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name,
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "sformat") == 0) {
char *f;
err = snd_config_string_get(n, &f);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
sformat = snd_pcm_format_value(f);
- if (sformat < 0)
+ if (sformat < 0) {
+ ERR("Unknown sformat");
return -EINVAL;
+ }
if (snd_pcm_format_linear(sformat) != 1 &&
- sformat != SND_PCM_FORMAT_MU_LAW)
+ sformat != SND_PCM_FORMAT_MU_LAW) {
+ ERR("Invalid sformat");
return -EINVAL;
+ }
continue;
}
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
- if (!sname || !sformat)
+ if (!sname) {
+ ERR("sname is not defined");
return -EINVAL;
+ }
+ if (sformat < 0) {
+ ERR("sformat is not defined");
+ return -EINVAL;
+ }
/* This is needed cause snd_config_update may destroy config */
sname = strdup(sname);
if (!sname)
diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c
index 95678004..c67b9925 100644
--- a/src/pcm/pcm_multi.c
+++ b/src/pcm/pcm_multi.c
@@ -507,21 +507,32 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
if (strcmp(n->id, "stream") == 0)
continue;
if (strcmp(n->id, "slave") == 0) {
- if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND)
+ if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
slave = n;
continue;
}
if (strcmp(n->id, "binding") == 0) {
- if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND)
+ if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
binding = n;
continue;
}
+ ERR("Unknown field %s", n->id);
+ return -EINVAL;
+ }
+ if (!slave) {
+ ERR("slave is not defined");
return -EINVAL;
}
- if (!slave || !binding)
+ if (!binding) {
+ ERR("binding is not defined");
return -EINVAL;
+ }
snd_config_foreach(i, slave) {
++slaves_count;
}
@@ -531,13 +542,17 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
snd_config_t *m = snd_config_entry(i);
errno = 0;
cchannel = strtol(m->id, &p, 10);
- if (errno || *p || cchannel < 0)
+ if (errno || *p || cchannel < 0) {
+ ERR("Invalid channel number: %s", m->id);
return -EINVAL;
+ }
if ((unsigned)cchannel >= channels_count)
channels_count = cchannel + 1;
}
- if (channels_count == 0)
+ if (channels_count == 0) {
+ ERR("No cannels defined");
return -EINVAL;
+ }
slaves_id = calloc(slaves_count, sizeof(*slaves_id));
slaves_name = calloc(slaves_count, sizeof(*slaves_name));
slaves_pcm = calloc(slaves_count, sizeof(*slaves_pcm));
@@ -547,31 +562,43 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
idx = 0;
for (idx = 0; idx < channels_count; ++idx)
channels_sidx[idx] = -1;
+ idx = 0;
snd_config_foreach(i, slave) {
snd_config_t *m = snd_config_entry(i);
char *name = NULL;
long channels = -1;
- slaves_id[idx] = snd_config_id(m);
+ slaves_id[idx] = m->id;
snd_config_foreach(j, m) {
snd_config_t *n = snd_config_entry(j);
if (strcmp(n->id, "comment") == 0)
continue;
if (strcmp(n->id, "name") == 0) {
err = snd_config_string_get(n, &name);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
goto _free;
+ }
continue;
}
if (strcmp(n->id, "channels") == 0) {
err = snd_config_integer_get(n, &channels);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
goto _free;
+ }
continue;
}
+ ERR("Unknown field %s", n->id);
err = -EINVAL;
goto _free;
}
- if (!name || channels < 0) {
+ if (!name) {
+ ERR("name is not defined");
+ err = -EINVAL;
+ goto _free;
+ }
+ if (channels < 0) {
+ ERR("channels is not defined");
err = -EINVAL;
goto _free;
}
@@ -588,6 +615,11 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
long val;
char *str;
cchannel = strtol(m->id, 0, 10);
+ if (cchannel < 0) {
+ ERR("Invalid channel number: %s", m->id);
+ err = -EINVAL;
+ goto _free;
+ }
snd_config_foreach(j, m) {
snd_config_t *n = snd_config_entry(j);
if (strcmp(n->id, "comment") == 0)
@@ -598,8 +630,10 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
err = snd_config_string_get(n, &str);
if (err < 0) {
err = snd_config_integer_get(n, &val);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid value for %s", n->id);
goto _free;
+ }
sprintf(buf, "%ld", val);
str = buf;
}
@@ -611,22 +645,24 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
}
if (strcmp(n->id, "schannel") == 0) {
err = snd_config_integer_get(n, &schannel);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
goto _free;
+ }
continue;
}
+ ERR("Unknown field %s", n->id);
err = -EINVAL;
goto _free;
}
- if (cchannel < 0 || slave < 0 || schannel < 0) {
- err = -EINVAL;
- goto _free;
- }
- if ((size_t)slave >= slaves_count) {
+ if (slave < 0 || (size_t)slave >= slaves_count) {
+ ERR("Invalid or missing sidx");
err = -EINVAL;
goto _free;
}
- if ((unsigned int) schannel >= slaves_channels[slave]) {
+ if (schannel < 0 ||
+ (unsigned int) schannel >= slaves_channels[slave]) {
+ ERR("Invalid or missing schannel");
err = -EINVAL;
goto _free;
}
diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c
index f46cd6ac..abaa06ad 100644
--- a/src/pcm/pcm_null.c
+++ b/src/pcm/pcm_null.c
@@ -403,6 +403,7 @@ int _snd_pcm_null_open(snd_pcm_t **pcmp, char *name,
continue;
if (strcmp(n->id, "stream") == 0)
continue;
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
return snd_pcm_null_open(pcmp, name, stream, mode);
diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c
index f94a9821..452705ce 100644
--- a/src/pcm/pcm_plug.c
+++ b/src/pcm/pcm_plug.c
@@ -198,7 +198,38 @@ static int snd_pcm_plug_hw_info(snd_pcm_t *pcm, snd_pcm_hw_info_t *info)
sinfo.buffer_size_min = muldiv_down(info->buffer_size_min, sinfo.rate_min, info->rate_max);
sinfo.buffer_size_max = muldiv_up(info->buffer_size_max, sinfo.rate_max, info->rate_min);
- err = snd_pcm_hw_info(slave, &sinfo);
+ /* FIXME: tricky here. This is not the right way to cope with this */
+ if (info->rate_min == info->rate_max) {
+ snd_pcm_hw_info_t i1 = sinfo;
+ snd_pcm_hw_info_t i2 = sinfo;
+ int err1, err2;
+ unsigned int rate = info->rate_min;
+ i1.rate_max = rate;
+ err1 = snd_pcm_hw_info(slave, &i1);
+ if (err1 < 0 || rate - i1.rate_max > 1) {
+ i2.rate_min = rate + 1;
+ err2 = snd_pcm_hw_info(slave, &i2);
+ } else
+ err2 = -EINVAL;
+ if (err1 < 0) {
+ sinfo = i2;
+ if (err2 >= 0)
+ sinfo.rate_max = sinfo.rate_min;
+ err = err2;
+ } else {
+ if (err2 < 0 ||
+ rate - i1.rate_max <= i2.rate_min - rate) {
+ sinfo = i1;
+ sinfo.rate_min = sinfo.rate_max;
+ err = err1;
+ } else {
+ sinfo = i2;
+ sinfo.rate_max = sinfo.rate_min;
+ err = err2;
+ }
+ }
+ } else
+ err = snd_pcm_hw_info(slave, &sinfo);
info->subformat_mask = sinfo.subformat_mask;
info->fragments_min = sinfo.fragments_min;
info->fragments_max = sinfo.fragments_max;
@@ -209,6 +240,8 @@ static int snd_pcm_plug_hw_info(snd_pcm_t *pcm, snd_pcm_hw_info_t *info)
size = muldiv_up(sinfo.fragment_size_max, info->rate_max, sinfo.rate_min);
if (info->fragment_size_max > size)
info->fragment_size_max = size;
+ if (info->fragment_size_min > info->fragment_size_max)
+ return -EINVAL;
size = muldiv_down(sinfo.buffer_size_min, info->rate_min, sinfo.rate_max);
if (info->buffer_size_min < size)
@@ -216,6 +249,8 @@ static int snd_pcm_plug_hw_info(snd_pcm_t *pcm, snd_pcm_hw_info_t *info)
size = muldiv_up(sinfo.buffer_size_max, info->rate_max, sinfo.rate_min);
if (info->buffer_size_max > size)
info->buffer_size_max = size;
+ if (info->buffer_size_min > info->buffer_size_max)
+ return -EINVAL;
n = info->buffer_size_min / info->fragment_size_max;
if (info->fragments_min < n)
@@ -223,6 +258,8 @@ static int snd_pcm_plug_hw_info(snd_pcm_t *pcm, snd_pcm_hw_info_t *info)
n = info->buffer_size_max / info->fragment_size_min;
if (info->fragments_max > n)
info->fragments_max = n;
+ if (info->fragments_min > info->fragments_max)
+ return -EINVAL;
if (err < 0)
return err;
@@ -435,8 +472,6 @@ static int snd_pcm_plug_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
unsigned int nformats;
int err;
- params->fail_mask = 0;
-
sparams = *params;
snd_pcm_hw_params_to_info(&sparams, &sinfo);
sinfo.access_mask = SND_PCM_ACCBIT_MMAP;
@@ -654,20 +689,27 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, char *name,
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "ttable") == 0) {
- if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND)
+ if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
tt = n;
continue;
}
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
- if (!sname)
+ if (!sname) {
+ ERR("sname is not defined");
return -EINVAL;
+ }
if (tt) {
ttable = malloc(MAX_CHANNELS * MAX_CHANNELS * sizeof(*ttable));
err = snd_pcm_route_load_ttable(tt, ttable, MAX_CHANNELS, MAX_CHANNELS,
diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c
index 94a9a9f8..8bdb51fd 100644
--- a/src/pcm/pcm_rate.c
+++ b/src/pcm/pcm_rate.c
@@ -595,34 +595,51 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name,
continue;
if (strcmp(n->id, "stream") == 0)
continue;
- if (strcmp(n->id, "sname") == 0) {
+ if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "sformat") == 0) {
char *f;
err = snd_config_string_get(n, &f);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
sformat = snd_pcm_format_value(f);
- if (sformat < 0)
+ if (sformat < 0) {
+ ERR("Unknown sformat");
return -EINVAL;
- if (snd_pcm_format_linear(sformat) != 1)
+ }
+ if (snd_pcm_format_linear(sformat) != 1) {
+ ERR("sformat is not linear");
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "srate") == 0) {
err = snd_config_integer_get(n, &srate);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
- if (!sname || !srate)
+ if (!sname) {
+ ERR("sname is not defined");
return -EINVAL;
+ }
+ if (srate < 0) {
+ ERR("srate is not defined");
+ return -EINVAL;
+ }
/* This is needed cause snd_config_update may destroy config */
sname = strdup(sname);
if (!sname)
diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
index da35baab..7f6785bf 100644
--- a/src/pcm/pcm_route.c
+++ b/src/pcm/pcm_route.c
@@ -778,8 +778,10 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, ttable_entry_t *ttable,
errno = 0;
cchannel = strtol(in->id, &p, 10);
if (errno || *p ||
- cchannel < 0 || (unsigned int) cchannel > tt_csize)
+ cchannel < 0 || (unsigned int) cchannel > tt_csize) {
+ ERR("Invalid client channel: %s", in->id);
return -EINVAL;
+ }
if (snd_config_type(in) != SND_CONFIG_TYPE_COMPOUND)
return -EINVAL;
snd_config_foreach(j, in) {
@@ -791,14 +793,18 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, ttable_entry_t *ttable,
schannel = strtol(jn->id, &p, 10);
if (errno || *p ||
schannel < 0 || (unsigned int) schannel > tt_ssize ||
- (schannels > 0 && schannel >= schannels))
+ (schannels > 0 && schannel >= schannels)) {
+ ERR("Invalid slave channel: %s", jn->id);
return -EINVAL;
+ }
err = snd_config_real_get(jn, &value);
if (err < 0) {
long v;
err = snd_config_integer_get(jn, &v);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", jn->id);
return -EINVAL;
+ }
value = v;
}
ttable[cchannel * tt_ssize + schannel] = value;
@@ -838,38 +844,57 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
continue;
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "sformat") == 0) {
char *f;
err = snd_config_string_get(n, &f);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
sformat = snd_pcm_format_value(f);
- if (sformat < 0)
+ if (sformat < 0) {
+ ERR("Unknown sformat");
return -EINVAL;
- if (snd_pcm_format_linear(sformat) != 1)
+ }
+ if (snd_pcm_format_linear(sformat) != 1) {
+ ERR("sformat is not linear");
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "schannels") == 0) {
err = snd_config_integer_get(n, &schannels);
- if (err < 0)
+ if (err < 0) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
continue;
}
if (strcmp(n->id, "ttable") == 0) {
- if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND)
+ if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
+ }
tt = n;
continue;
}
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
- if (!sname || !tt)
+ if (!sname) {
+ ERR("sname is not defined");
return -EINVAL;
+ }
+ if (!tt) {
+ ERR("ttable is not defined");
+ return -EINVAL;
+ }
err = snd_pcm_route_load_ttable(tt, ttable, MAX_CHANNELS, MAX_CHANNELS,
&cused, &sused, schannels);
diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c
index d116b2e8..8c55c9ad 100644
--- a/src/pcm/pcm_share.c
+++ b/src/pcm/pcm_share.c
@@ -498,7 +498,6 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
Pthread_mutex_lock(&slave->mutex);
if (slave->setup_count > 1 ||
(slave->setup_count == 1 && !pcm->setup)) {
- params->fail_mask = 0;
if (params->format != spcm->format)
params->fail_mask |= SND_PCM_HW_PARBIT_FORMAT;
if (params->subformat != spcm->subformat)
@@ -1305,7 +1304,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (err < 0) {
- ERR("Invalid type for sname");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -1314,7 +1313,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
char *f;
err = snd_config_string_get(n, &f);
if (err < 0) {
- ERR("Invalid type for sformat");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
sformat = snd_pcm_format_value(f);
@@ -1327,7 +1326,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
if (strcmp(n->id, "schannels") == 0) {
err = snd_config_integer_get(n, &schannels_count);
if (err < 0) {
- ERR("Invalid type for schannels");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -1335,20 +1334,20 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
if (strcmp(n->id, "srate") == 0) {
err = snd_config_integer_get(n, &srate);
if (err < 0) {
- ERR("Invalid type for srate");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
}
if (strcmp(n->id, "binding") == 0) {
if (snd_config_type(n) != SND_CONFIG_TYPE_COMPOUND) {
- ERR("Invalid type for binding");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
binding = n;
continue;
}
- ERR("Unknown field: %s", n->id);
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
if (!sname) {
diff --git a/src/pcm/pcm_shm.c b/src/pcm/pcm_shm.c
index cc6bfa4c..885d72e0 100644
--- a/src/pcm/pcm_shm.c
+++ b/src/pcm/pcm_shm.c
@@ -721,7 +721,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
if (strcmp(n->id, "server") == 0) {
err = snd_config_string_get(n, &server);
if (err < 0) {
- ERR("Invalid type for server");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -729,12 +729,12 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
if (strcmp(n->id, "sname") == 0) {
err = snd_config_string_get(n, &sname);
if (err < 0) {
- ERR("Invalid type for sname");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
}
- ERR("Unknown field: %s", n->id);
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
if (!sname) {
@@ -757,7 +757,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
if (strcmp(n->id, "host") == 0) {
err = snd_config_string_get(n, &host);
if (err < 0) {
- ERR("Invalid type for host");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -765,7 +765,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
if (strcmp(n->id, "socket") == 0) {
err = snd_config_string_get(n, &socket);
if (err < 0) {
- ERR("Invalid type for socket");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -773,12 +773,12 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
if (strcmp(n->id, "port") == 0) {
err = snd_config_integer_get(n, &port);
if (err < 0) {
- ERR("Invalid type for port");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
}
- ERR("Unknown field: %s", n->id);
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c
index 3bebdff9..536098a7 100644
--- a/src/rawmidi/rawmidi.c
+++ b/src/rawmidi/rawmidi.c
@@ -150,14 +150,14 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
return -ENOENT;
}
if (snd_config_type(rawmidi_conf) != SND_CONFIG_TYPE_COMPOUND) {
- ERR("Invalid type for RAWMIDI definition");
+ ERR("Invalid type for RAWMIDI %s definition", name);
return -EINVAL;
}
err = snd_config_search(rawmidi_conf, "streams", &conf);
if (err >= 0) {
err = snd_config_string_get(conf, &str);
if (err < 0) {
- ERR("Invalid type for streams");
+ ERR("Invalid type for %s", conf->id);
return err;
}
if (strcmp(str, "output") == 0) {
@@ -170,7 +170,7 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
if (streams != SND_RAWMIDI_OPEN_DUPLEX)
return -EINVAL;
} else {
- ERR("Invalid value for streams");
+ ERR("Invalid value for %s", conf->id);
return -EINVAL;
}
}
@@ -181,7 +181,7 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
}
err = snd_config_string_get(conf, &str);
if (err < 0) {
- ERR("Invalid type for type");
+ ERR("Invalid type for %s", conf->id);
return err;
}
err = snd_config_searchv(snd_config, &type_conf, "rawmiditype", str, 0);
@@ -196,7 +196,7 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
if (strcmp(n->id, "lib") == 0) {
err = snd_config_string_get(n, &lib);
if (err < 0) {
- ERR("Invalid type for lib");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -204,11 +204,11 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
if (strcmp(n->id, "open") == 0) {
err = snd_config_string_get(n, &open);
if (err < 0) {
- ERR("Invalid type for open");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
- ERR("Unknown field: %s", n->id);
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
}
diff --git a/src/seq/seq.c b/src/seq/seq.c
index ab4f269f..389faf5d 100644
--- a/src/seq/seq.c
+++ b/src/seq/seq.c
@@ -48,14 +48,14 @@ int snd_seq_open(snd_seq_t **seqp, char *name,
return -ENOENT;
}
if (snd_config_type(seq_conf) != SND_CONFIG_TYPE_COMPOUND) {
- ERR("Invalid type for SEQ definition");
+ ERR("Invalid type for SEQ %s definition", name);
return -EINVAL;
}
err = snd_config_search(seq_conf, "streams", &conf);
if (err >= 0) {
err = snd_config_string_get(conf, &str);
if (err < 0) {
- ERR("Invalid type for streams");
+ ERR("Invalid type for %s", conf->id);
return err;
}
if (strcmp(str, "output") == 0) {
@@ -68,7 +68,7 @@ int snd_seq_open(snd_seq_t **seqp, char *name,
if (streams != SND_SEQ_OPEN_DUPLEX)
return -EINVAL;
} else {
- ERR("Invalid value for streams");
+ ERR("Invalid value for %s", conf->id);
return -EINVAL;
}
}
@@ -79,7 +79,7 @@ int snd_seq_open(snd_seq_t **seqp, char *name,
}
err = snd_config_string_get(conf, &str);
if (err < 0) {
- ERR("Invalid type for type");
+ ERR("Invalid type for %s", conf->id);
return err;
}
err = snd_config_searchv(snd_config, &type_conf, "seqtype", str, 0);
@@ -94,7 +94,7 @@ int snd_seq_open(snd_seq_t **seqp, char *name,
if (strcmp(n->id, "lib") == 0) {
err = snd_config_string_get(n, &lib);
if (err < 0) {
- ERR("Invalid type for lib");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
@@ -102,11 +102,11 @@ int snd_seq_open(snd_seq_t **seqp, char *name,
if (strcmp(n->id, "open") == 0) {
err = snd_config_string_get(n, &open);
if (err < 0) {
- ERR("Invalid type for open");
+ ERR("Invalid type for %s", n->id);
return -EINVAL;
}
continue;
- ERR("Unknown field: %s", n->id);
+ ERR("Unknown field %s", n->id);
return -EINVAL;
}
}