]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Added missing diagnostics
authorAbramo Bagnara <abramo@alsa-project.org>
Thu, 30 Nov 2000 09:40:50 +0000 (09:40 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Thu, 30 Nov 2000 09:40:50 +0000 (09:40 +0000)
18 files changed:
aserver/aserver.c
src/control/control_shm.c
src/pcm/pcm.c
src/pcm/pcm_adpcm.c
src/pcm/pcm_alaw.c
src/pcm/pcm_file.c
src/pcm/pcm_hw.c
src/pcm/pcm_linear.c
src/pcm/pcm_mulaw.c
src/pcm/pcm_multi.c
src/pcm/pcm_null.c
src/pcm/pcm_plug.c
src/pcm/pcm_rate.c
src/pcm/pcm_route.c
src/pcm/pcm_share.c
src/pcm/pcm_shm.c
src/rawmidi/rawmidi.c
src/seq/seq.c

index 6434aa053ea62f32a181d21220f2af5316eca990..384054e3ad5f91ea042b41cd90674ab9432ef00c 100644 (file)
@@ -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) {
index e8086f1933126eefacec4fdf2a5d3c79334cfdc4..ccf217ba27bca8c82a2fecbc565e1c5e98c9c16d 100644 (file)
@@ -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;
        }
 
index c4ca15b9d7e11a7e621ead3d5adbd9075a8a41d5..eb449b14d0d02dc1dedd1c09dd82a861eadffeae 100644 (file)
@@ -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;
index 70882a036c0a30112f2bf07c050cd0080d1f08b1..6a45d7614dce1fdbbdafe387667ee4661c46f0f1 100644 (file)
@@ -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)
index 16dd739914d25d401548c5d390f51af108877a55..4ea75ec4f8849c7b07ffb51df563f98b28868173 100644 (file)
@@ -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)
index 1cf456a6c1520b91ae5d0876139025cc49e0b007..bebc751e836243ba426acd328c09e5ad2f5c7b0e 100644 (file)
@@ -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)
index 2e3f14fc6c28668efea45fc78002f959aa5be3b8..c874634e3873863a8c5903fbeb7a4482006ecc08 100644 (file)
@@ -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);
 }
                                
index ba577ff9cc8ad7e86aa9a00aab080afb59f607e4..5a608d4a5bc1cb32f3a8ac2051c973bb84ccf230 100644 (file)
@@ -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)
index 90aa36a0a0c76f83ebb6ec2866321add1ce15e85..489a69728b387910ff201d266f62b422fe1c9c64 100644 (file)
@@ -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)
index 9567800455aa4935dcce084879cfa6dc13f123db..c67b992581994b2c812ce9f86da62f4d487f5f05 100644 (file)
@@ -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;
                }
index f46cd6acdb1b57de8f556ca5d2eae952a1a8ea00..abaa06ad08af60fc6494a8fa5d99c12ef4e34eeb 100644 (file)
@@ -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);
index f94a98216d6c62044b08455e5aa0faf9afce4986..452705ce6315c121bd14632b5c40d6815edfef82 100644 (file)
@@ -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,
index 94a9a9f81068fac13bb807506cd0aab8b6fedf0b..8bdb51fd2a7f1ed24b5b2167ef1cea0fdab7084b 100644 (file)
@@ -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)
index da35baab70afe15f7582f3275fde9a8e2a21bfd5..7f6785bf2dd88c43607fd4a44d757981a6873853 100644 (file)
@@ -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);
index d116b2e862eaebc48d4791bc91942abc570288b1..8c55c9ad15409bcf44cecf1f4aa1397708782dd2 100644 (file)
@@ -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) {
index cc6bfa4c31f7dbbddb6049d6aebcb5f8d116361e..885d72e0791169e18511bfb061eb43a22964b10b 100644 (file)
@@ -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;
        }
 
index 3bebdff9d19bc1647848306274e6a684f08d945a..536098a796d0274c70efedd5ae9d90ee5149bc5b 100644 (file)
@@ -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;
                }
        }
index ab4f269f7af3a20a9b9787685e7e508ce068330a..389faf5dec2f6ded4eac5f69c4dc4846c22606b0 100644 (file)
@@ -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;
                }
        }