aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ. Alexander Treuman <jat@spatialrift.net>2007-05-26 17:33:59 +0000
committerJ. Alexander Treuman <jat@spatialrift.net>2007-05-26 17:33:59 +0000
commitdba45a59928301da0faa4ec679eb1a3a81d5fba5 (patch)
treea20e255db1323af1eda467490a22d7706e5b9b07 /src
parent665ab837616aa1977805c21b2e0d67c395de3d87 (diff)
downloadmpd-dba45a59928301da0faa4ec679eb1a3a81d5fba5.tar.gz
mpd-dba45a59928301da0faa4ec679eb1a3a81d5fba5.tar.xz
mpd-dba45a59928301da0faa4ec679eb1a3a81d5fba5.zip
Cleaning up pcm_getSampleRateConverter.
git-svn-id: https://svn.musicpd.org/mpd/trunk@6275 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/pcm_utils.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/pcm_utils.c b/src/pcm_utils.c
index 36b1a9b37..ab84850d7 100644
--- a/src/pcm_utils.c
+++ b/src/pcm_utils.c
@@ -151,32 +151,36 @@ void pcm_mix(char *buffer1, char *buffer2, size_t bufferSize1,
#ifdef HAVE_LIBSAMPLERATE
static int pcm_getSampleRateConverter(void)
{
- const char *conf, *test;
- int convalgo = SRC_SINC_FASTEST;
- int newalgo;
+ const char *conf = getConfigParamValue(CONF_SAMPLERATE_CONVERTER);
+ long convalgo;
+ char *test;
size_t len;
-
- conf = getConfigParamValue(CONF_SAMPLERATE_CONVERTER);
- if(conf) {
- newalgo = strtol(conf, (char **)&test, 10);
- if(*test) {
- len = strlen(conf);
- for(newalgo = 0; ; newalgo++) {
- test = src_get_name(newalgo);
- if(!test)
- break; /* FAIL */
- if(!strncasecmp(test, conf, len)) {
- convalgo = newalgo;
- break;
- }
- }
- } else {
- if(src_get_name(newalgo))
- convalgo = newalgo;
- /* else FAIL */
+
+ if (!conf) {
+ convalgo = SRC_SINC_FASTEST;
+ goto out;
+ }
+
+ convalgo = strtol(conf, &test, 10);
+ if (*test == '\0' && src_get_name(convalgo))
+ goto out;
+
+ len = strlen(conf);
+ for (convalgo = 0 ; ; convalgo++) {
+ test = (char *)src_get_name(convalgo);
+ if (!test) {
+ convalgo = SRC_SINC_FASTEST;
+ break;
}
+ if (strncasecmp(test, conf, len) == 0)
+ goto out;
}
- DEBUG("Selecting samplerate converter '%s'\n", src_get_name(convalgo));
+
+ ERROR("unknown samplerate converter \"%s\"\n", conf);
+out:
+ DEBUG("selecting samplerate converter \"%s\"\n",
+ src_get_name(convalgo));
+
return convalgo;
}
#endif