aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/audio.c2
-rw-r--r--src/conf.c164
-rw-r--r--src/conf.h6
-rw-r--r--src/directory.c3
-rw-r--r--src/inputStream_http.c108
-rw-r--r--src/listen.c20
-rw-r--r--src/log.c16
-rw-r--r--src/main.c29
-rw-r--r--src/path.c9
-rw-r--r--src/replayGain.c26
-rw-r--r--src/tag.c12
-rw-r--r--src/volume.c85
12 files changed, 284 insertions, 196 deletions
diff --git a/src/audio.c b/src/audio.c
index 7f04ea2df..e3a311abb 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -224,7 +224,7 @@ int isAudioDeviceOpen() {
int i;
for(i = 0; i < audioOutputArraySize; i++) {
- ret &= audioOutputArray[i]->open;
+ ret |= audioOutputArray[i]->open;
}
return ret;
diff --git a/src/conf.c b/src/conf.c
index 32f3f57a7..ccbb99f1c 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -87,8 +87,8 @@ ConfigEntry * newConfigEntry(int repeatable, int block) {
ret->mask = 0;
ret->configParamList = makeList((ListFreeDataFunc *)freeConfigParam);
- if(repeatable) ret->mask &= CONF_REPEATABLE_MASK;
- if(block) ret->mask &= CONF_BLOCK_MASK;
+ if(repeatable) ret->mask |= CONF_REPEATABLE_MASK;
+ if(block) ret->mask |= CONF_BLOCK_MASK;
return ret;
}
@@ -171,7 +171,7 @@ static ConfigParam * readConfigBlock(FILE * fp, int * count, char * string) {
int numberOfArgs;
int argsMinusComment;
- while(myFgets(string,sizeof(MAX_STRING_SIZE),fp)) {
+ while(myFgets(string, MAX_STRING_SIZE ,fp)) {
(*count)++;
numberOfArgs = buffer2array(string, &array);
@@ -232,7 +232,7 @@ void readConf(char * file) {
exit(EXIT_FAILURE);
}
- while(myFgets(string,sizeof(MAX_STRING_SIZE),fp)) {
+ while(myFgets(string, MAX_STRING_SIZE, fp)) {
count++;
numberOfArgs = buffer2array(string, &array);
@@ -312,71 +312,107 @@ ConfigParam * getNextConfigParam(char * name, ConfigParam * last) {
return param;
}
- /*for(i=0;i<CONF_NUMBER_OF_PATHS;i++) {
- if(conf_params[conf_absolutePaths[i]] &&
- conf_params[conf_absolutePaths[i]][0]!='/' &&
- conf_params[conf_absolutePaths[i]][0]!='~')
- {
- ERROR("\"%s\" is not an absolute path\n",
- conf_params[conf_absolutePaths[i]]);
- exit(EXIT_FAILURE);
+char * getConfigParamValue(char * name) {
+ ConfigParam * param = getConfigParam(name);
+
+ if(!param) return NULL;
+
+ return param->value;
+}
+
+char * forceAndGetConfigParamValue(char * name) {
+ ConfigParam * param = getConfigParam(name);
+
+ if(!param) {
+ ERROR("\"%s\" not found in config file\n", name);
+ exit(EXIT_FAILURE);
+ }
+
+ return param->value;
+}
+
+BlockParam * getBlockParam(ConfigParam * param, char * name) {
+ BlockParam * ret = NULL;
+ int i;
+
+ for(i = 0; i < param->numberOfBlockParams; i++) {
+ if(0 == strcmp(name, param->blockParams[i].name)) {
+ if(ret) {
+ ERROR("\"%s\" first defined on line %i, and "
+ "redefined on line %i\n", name,
+ ret->line, param->blockParams[i].line);
+ }
+ ret = param->blockParams+i;
}
- // Parse ~ in path
- else if(conf_params[conf_absolutePaths[i]] &&
- conf_params[conf_absolutePaths[i]][0]=='~')
- {
- struct passwd * pwd = NULL;
- char * path;
- int pos = 1;
- if(conf_params[conf_absolutePaths[i]][1]=='/' ||
- conf_params[conf_absolutePaths[i]][1]=='\0')
- {
- if(conf_params[CONF_USER] &&
- strlen(conf_params[CONF_USER]))
- {
- pwd = getpwnam(
- conf_params[CONF_USER]);
- if(!pwd) {
- ERROR("no such user: %s\n",
- conf_params[CONF_USER]);
- exit(EXIT_FAILURE);
- }
- }
- else {
- uid_t uid = geteuid();
- if((pwd = getpwuid(uid)) == NULL) {
- ERROR("problems getting passwd "
- "entry "
- "for current user\n");
- exit(EXIT_FAILURE);
- }
+ }
+
+ return ret;
+}
+
+char * parseConfigFilePath(char * name, int force) {
+ ConfigParam * param = getConfigParam(name);
+ char * path;
+
+ if(!param && force) {
+ ERROR("config parameter \"%s\" not found\n", name);
+ exit(EXIT_FAILURE);
+ }
+
+ if(!param) return NULL;
+
+ path = param->value;
+
+ if(path[0] != '/' && path[0] != '~') {
+ ERROR("\"%s\" is not an absolute path at line %i\n",
+ param->value, param->line);
+ exit(EXIT_FAILURE);
+ }
+ // Parse ~ in path
+ else if(path[0] == '~') {
+ struct passwd * pwd = NULL;
+ char * newPath;
+ int pos = 1;
+ if(path[1]=='/' || path[1] == '\0') {
+ ConfigParam * userParam = getConfigParam(CONF_USER);
+
+ if(userParam) {
+ pwd = getpwnam(userParam->value);
+ if(!pwd) {
+ ERROR("no such user %s at line %i\n",
+ userParam->value,
+ userParam->line);
+ exit(EXIT_FAILURE);
}
}
else {
- int foundSlash = 0;
- char * ch = &(
- conf_params[conf_absolutePaths[i]][1]);
- for(;*ch!='\0' && *ch!='/';ch++);
- if(*ch=='/') foundSlash = 1;
- * ch = '\0';
- pos+= ch-
- &(conf_params[
- conf_absolutePaths[i]][1]);
- if((pwd = getpwnam(&(conf_params[
- conf_absolutePaths[i]][1]))) == NULL)
- {
- ERROR("user \"%s\" not found\n",
- &(conf_params[
- conf_absolutePaths[i]][1]));
+ uid_t uid = geteuid();
+ if((pwd = getpwuid(uid)) == NULL) {
+ ERROR("problems getting passwd entry "
+ "for current user\n");
exit(EXIT_FAILURE);
}
- if(foundSlash) *ch = '/';
}
- path = malloc(strlen(pwd->pw_dir)+strlen(
- &(conf_params[conf_absolutePaths[i]][pos]))+1);
- strcpy(path,pwd->pw_dir);
- strcat(path,&(conf_params[conf_absolutePaths[i]][pos]));
- free(conf_params[conf_absolutePaths[i]]);
- conf_params[conf_absolutePaths[i]] = path;
}
- }*/
+ else {
+ int foundSlash = 0;
+ char * ch = path+1;
+ for(;*ch!='\0' && *ch!='/';ch++);
+ if(*ch=='/') foundSlash = 1;
+ * ch = '\0';
+ pos+= ch-path+1;
+ if((pwd = getpwnam(path+1)) == NULL) {
+ ERROR("user \"%s\" not found at line %i\n",
+ path+1, param->line);
+ exit(EXIT_FAILURE);
+ }
+ if(foundSlash) *ch = '/';
+ }
+ newPath = malloc(strlen(pwd->pw_dir)+strlen(path+pos)+1);
+ strcpy(newPath, pwd->pw_dir);
+ strcat(newPath, path+pos);
+ free(param->value);
+ param->value = newPath;
+ }
+
+ return param->value;
+}
diff --git a/src/conf.h b/src/conf.h
index 5bdff584d..1c9413654 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -77,12 +77,16 @@ void readConf(char * file);
set _last_ to NULL to get first entry */
ConfigParam * getNextConfigParam(char * name, ConfigParam * last);
-#define getConfigParam(name) getNextConfigParam(name, NULL);
+#define getConfigParam(name) getNextConfigParam(name, NULL)
char * getConfigParamValue(char * name);
+char * forceAndGetConfigParamValue(char * name);
+
void registerConfigParam(char * name, int repeats, int block);
BlockParam * getBlockParam(ConfigParam * param, char * name);
+char * parseConfigFilePath(char * name, int force);
+
#endif
diff --git a/src/directory.c b/src/directory.c
index b5c5ed965..85773489b 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -1053,7 +1053,8 @@ int readDirectoryDB() {
fsCharset = &(buffer[strlen(
DIRECTORY_FS_CHARSET)]);
if((tempCharset =
- getConf()[CONF_FS_CHARSET]) &&
+ getConfigParamValue(
+ CONF_FS_CHARSET)) &&
strcmp(fsCharset,tempCharset))
{
WARNING("Using \"%s\" for the "
diff --git a/src/inputStream_http.c b/src/inputStream_http.c
index 353285ebd..15768929f 100644
--- a/src/inputStream_http.c
+++ b/src/inputStream_http.c
@@ -47,6 +47,11 @@
#define HTTP_REDIRECT_MAX 10
+static char * proxyHost = NULL;
+static int proxyPort = 0;
+static char * proxyUser = NULL;
+static char * proxyPassword = NULL;
+
typedef struct _InputStreemHTTPData {
char * host;
char * path;
@@ -59,57 +64,73 @@ typedef struct _InputStreemHTTPData {
int icyMetaint;
int prebuffer;
int icyOffset;
- char * proxyHost;
- int proxyPort;
char * proxyAuth;
char * httpAuth;
} InputStreamHTTPData;
void inputStream_initHttp() {
- if(getConf()[CONF_HTTP_PROXY_HOST]) {
- char * portStr = getConf()[CONF_HTTP_PROXY_PORT];
- int port = 0;
- char * test;
-
- if(!portStr) {
- ERROR("http_proxy_host specified but not the http_"
- "proxy_port\n");
+ ConfigParam * param = getConfigParam(CONF_HTTP_PROXY_HOST);
+ char * test;
+
+ if(param) {
+ proxyHost = param->value;
+
+ param = getConfigParam(CONF_HTTP_PROXY_PORT);
+
+ if(!param) {
+ ERROR("%s specified but not %s", CONF_HTTP_PROXY_HOST,
+ CONF_HTTP_PROXY_PORT);
exit(EXIT_FAILURE);
}
- port = strtol(portStr, &test, 10);
- if(port <= 0 || *test != '\0') {
- ERROR("http_proxy_port \"%s\" is not a positive integer"
- "\n", portStr);
+ proxyPort = strtol(param->value, &test, 10);
+ if(proxyPort <= 0 || *test != '\0') {
+ ERROR("%s \"%s\" is not a positive integer, line %i\n"
+ CONF_HTTP_PROXY_PORT, param->value,
+ param->line);
}
- if(getConf()[CONF_HTTP_PROXY_USER] &&
- !getConf()[CONF_HTTP_PROXY_PASSWORD])
- {
- ERROR("http_proxy_user specified, but not http_proxy_"
- "password\n");
- exit(EXIT_FAILURE);
+ param = getConfigParam(CONF_HTTP_PROXY_USER);
+
+ if(param) {
+ proxyUser = param->value;
+
+ param = getConfigParam(CONF_HTTP_PROXY_PASSWORD);
+
+ if(!param) {
+ ERROR("%s specifid but not %s\n",
+ CONF_HTTP_PROXY_USER,
+ CONF_HTTP_PROXY_PASSWORD);
+ exit(EXIT_FAILURE);
+ }
+
+ proxyPassword = param->value;
}
- if(getConf()[CONF_HTTP_PROXY_PASSWORD] &&
- !getConf()[CONF_HTTP_PROXY_USER])
- {
- ERROR("http proxy password specified, but not http "
- "proxy user\n");
+ param = getConfigParam(CONF_HTTP_PROXY_PASSWORD);
+
+ if(param) {
+ ERROR("%s specifid but not %s\n",
+ CONF_HTTP_PROXY_PASSWORD, CONF_HTTP_PROXY_USER);
exit(EXIT_FAILURE);
}
}
- else if(getConf()[CONF_HTTP_PROXY_PORT]) {
- ERROR("http_proxy_port specified but not http_proxy_host\n");
+ else if((param = getConfigParam(CONF_HTTP_PROXY_PORT))) {
+ ERROR("%s specified but not %s, line %i\n",
+ CONF_HTTP_PROXY_PORT, CONF_HTTP_PROXY_HOST,
+ param->line);
exit(EXIT_FAILURE);
}
- else if(getConf()[CONF_HTTP_PROXY_USER]) {
- ERROR("http_proxy_user specified but not http_proxy_host\n");
+ else if((param = getConfigParam(CONF_HTTP_PROXY_USER))) {
+ ERROR("%s specified but not %s, line %i\n",
+ CONF_HTTP_PROXY_USER, CONF_HTTP_PROXY_HOST,
+ param->line);
exit(EXIT_FAILURE);
}
- else if(getConf()[CONF_HTTP_PROXY_PASSWORD]) {
- ERROR("http_proxy_password specified but not http_proxy_host"
- "\n");
+ else if((param = getConfigParam(CONF_HTTP_PROXY_PASSWORD))) {
+ ERROR("%s specified but not %s, line %i\n",
+ CONF_HTTP_PROXY_PASSWORD, CONF_HTTP_PROXY_HOST,
+ param->line);
exit(EXIT_FAILURE);
}
}
@@ -188,19 +209,10 @@ static char * authString(char * header, char * user, char * password) {
static InputStreamHTTPData * newInputStreamHTTPData() {
InputStreamHTTPData * ret = malloc(sizeof(InputStreamHTTPData));
- if(getConf()[CONF_HTTP_PROXY_HOST]) {
- ret->proxyHost = getConf()[CONF_HTTP_PROXY_HOST];
- DEBUG(__FILE__ ": Proxy host %s\n", ret->proxyHost);
- ret->proxyPort = atoi(getConf()[CONF_HTTP_PROXY_PORT]);
- DEBUG(__FILE__ ": Proxy port %i\n", ret->proxyPort);
- ret->proxyAuth = proxyAuthString(
- getConf()[CONF_HTTP_PROXY_USER],
- getConf()[CONF_HTTP_PROXY_PASSWORD]);
- }
- else {
- ret->proxyHost = NULL;
- ret->proxyAuth = NULL;
+ if(proxyHost) {
+ ret->proxyAuth = proxyAuthString(proxyUser, proxyPassword);
}
+ else ret->proxyAuth = NULL;
ret->httpAuth = NULL;
ret->host = NULL;
@@ -299,7 +311,7 @@ static int parseUrl(InputStreamHTTPData * data, char * url) {
}
/* fetch the path */
- if(data->proxyHost) data->path = strdup(url);
+ if(proxyHost) data->path = strdup(url);
else data->path = strdup(slash ? slash : "/");
return 0;
@@ -319,9 +331,9 @@ static int initHTTPConnection(InputStream * inStream) {
struct sockaddr_in6 sin6;
#endif
- if(data->proxyHost) {
- connHost = data->proxyHost;
- connPort = data->proxyPort;
+ if(proxyHost) {
+ connHost = proxyHost;
+ connPort = proxyPort;
}
else {
connHost = data->host;
diff --git a/src/listen.c b/src/listen.c
index 49ff4c33e..065e1ccc6 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -44,6 +44,7 @@
int listenSocket;
int establish(unsigned short port) {
+ ConfigParam * param;
int allowReuse = ALLOW_REUSE;
int sock;
struct sockaddr * addrp;
@@ -60,8 +61,10 @@ int establish(unsigned short port) {
memset(&sin, 0, sizeof(struct sockaddr_in));
sin.sin_port = htons(port);
sin.sin_family = AF_INET;
+
+ param = getConfigParam(CONF_BIND_TO_ADDRESS);
- if(strcmp((getConf())[CONF_BIND_TO_ADDRESS],"any")==0) {
+ if(!param || 0==strcmp(param->value, "any")==0) {
#ifdef HAVE_IPV6
if(ipv6Supported()) {
sin6.sin6_addr = in6addr_any;
@@ -78,9 +81,9 @@ int establish(unsigned short port) {
}
else {
struct hostent * he;
- if(!(he = gethostbyname((getConf())[CONF_BIND_TO_ADDRESS]))) {
- ERROR("can't lookup host \"%s\"\n",
- (getConf())[CONF_BIND_TO_ADDRESS]);
+ if(!(he = gethostbyname(param->value))) {
+ ERROR("can't lookup host \"%s\" at line %i\n",
+ param->value, param->line);
exit(EXIT_FAILURE);
}
switch(he->h_addrtype) {
@@ -88,8 +91,8 @@ int establish(unsigned short port) {
case AF_INET6:
if(!ipv6Supported()) {
ERROR("no IPv6 support, but a IPv6 address "
- "found for \"%s\"\n",
- (getConf())[CONF_BIND_TO_ADDRESS]);
+ "found for \"%s\" at line %i\n",
+ param->value, param->line);
exit(EXIT_FAILURE);
}
bcopy((char *)he->h_addr,(char *)
@@ -105,8 +108,9 @@ int establish(unsigned short port) {
addrlen = sizeof(struct sockaddr_in);
break;
default:
- ERROR("address type for \"%s\" is not IPv4 or IPv6\n",
- (getConf())[CONF_BIND_TO_ADDRESS]);
+ ERROR("address type for \"%s\" is not IPv4 or IPv6 "
+ "at line %i\n",
+ param->value, param->line);
exit(EXIT_FAILURE);
}
}
diff --git a/src/log.c b/src/log.c
index 835fa9e00..964b8aa66 100644
--- a/src/log.c
+++ b/src/log.c
@@ -32,16 +32,24 @@ short warningFlushed = 0;
static char * warningBuffer = NULL;
void initLog() {
- if(strcmp(getConf()[CONF_LOG_LEVEL],"default")==0) {
+ ConfigParam * param = getConfigParam(CONF_LOG_LEVEL);
+
+ if(!param) return;
+
+ if(0 == strcmp(param->value, "default")) {
if(logLevel<LOG_LEVEL_LOW) logLevel = LOG_LEVEL_LOW;
}
- else if(strcmp(getConf()[CONF_LOG_LEVEL],"secure")==0) {
+ else if(0 == strcmp(param->value, "secure")) {
if(logLevel<LOG_LEVEL_SECURE) logLevel = LOG_LEVEL_SECURE;
}
- else if(strcmp(getConf()[CONF_LOG_LEVEL],"verbose")==0) {
+ else if(0 == strcmp(param->value, "verbose")) {
if(logLevel<LOG_LEVEL_DEBUG) logLevel = LOG_LEVEL_DEBUG;
}
- else ERROR("unknown log level \"%s\"\n",getConf()[CONF_LOG_LEVEL]);
+ else {
+ ERROR("unknown log level \"%s\" at line %i\n",
+ param->value, param->line);
+ exit(EXIT_FAILURE);
+ }
}
#define BUFFER_LENGTH 4096
diff --git a/src/main.c b/src/main.c
index a73d778cf..f56d74939 100644
--- a/src/main.c
+++ b/src/main.c
@@ -165,9 +165,12 @@ void parseOptions(int argc, char ** argv, Options * options) {
return;
}
else if(argcLeft<=2) {
- char ** conf = NULL;
- if(argcLeft==2) readConf(argv[argc-1]);
- if(argcLeft==1) {
+ int conf = 0;
+ if(argcLeft==2) {
+ readConf(argv[argc-1]);
+ conf = 1;
+ }
+ else if(argcLeft==1) {
FILE * fp;
char * homedir = getenv("HOME");
char userfile[MAXPATHLEN+1] = "";
@@ -180,26 +183,26 @@ void parseOptions(int argc, char ** argv, Options * options) {
if(strlen(userfile) && (fp=fopen(userfile,"r"))) {
fclose(fp);
readConf(userfile);
+ conf = 1;
}
else if((fp=fopen(SYSTEM_CONFIG_FILE_LOCATION,"r"))) {
fclose(fp);
readConf(SYSTEM_CONFIG_FILE_LOCATION);
+ conf = 1;
}
}
if(conf) {
- options->portStr = getConfigParamValue(CONF_PORT);
+ options->portStr = forceAndGetConfigParamValue(
+ CONF_PORT);
options->musicDirArg =
- getConfigParamValue(CONF_MUSIC_DIR);
+ parseConfigFilePath(CONF_MUSIC_DIR, 1);
options->playlistDirArg =
- getConfigParamValue(CONF_PLAYLIST_DIR);
- options->logFile = getConfigParamValue(CONF_LOG_FILE);
+ parseConfigFilePath(CONF_PLAYLIST_DIR, 1);
+ options->logFile = parseConfigFilePath(CONF_LOG_FILE,1);
options->errorFile =
- getConfigParamValue(CONF_ERROR_FILE);
- options->usr = getConfigParamValue(CONF_USER);
- if(getConfigParamValue(CONF_DB_FILE)) {
- options->dbFile =
- getConfigParamValue(CONF_DB_FILE);
- }
+ parseConfigFilePath(CONF_ERROR_FILE, 1);
+ options->usr = parseConfigFilePath(CONF_USER, 0);
+ options->dbFile = parseConfigFilePath(CONF_DB_FILE, 0);
return;
}
}
diff --git a/src/path.c b/src/path.c
index 48d5eff09..1d599bda3 100644
--- a/src/path.c
+++ b/src/path.c
@@ -114,6 +114,7 @@ void initPaths(char * playlistDirArg, char * musicDirArg) {
char * charset = NULL;
char * originalLocale;
struct stat st;
+ ConfigParam * param;
playlistDir = prependCwdToPathDup(playlistDirArg);
if((stat(playlistDir,&st))<0) {
@@ -135,8 +136,10 @@ void initPaths(char * playlistDirArg, char * musicDirArg) {
exit(EXIT_FAILURE);
}
- if(getConf()[CONF_FS_CHARSET]) {
- charset = strdup(getConf()[CONF_FS_CHARSET]);
+ param = getConfigParam(CONF_FS_CHARSET);
+
+ if(param) {
+ charset = strdup(param->value);
}
#ifdef HAVE_LOCALE
#ifdef HAVE_LANGINFO_CODESET
@@ -296,5 +299,3 @@ char * prependCwdToPathDup(char * path) {
return realloc(ret,len+1);
}
-
-/* vim:set shiftwidth=4 tabstop=8 expandtab: */
diff --git a/src/replayGain.c b/src/replayGain.c
index dbd09aa36..4788d7d95 100644
--- a/src/replayGain.c
+++ b/src/replayGain.c
@@ -32,34 +32,38 @@ static int replayGainState = REPLAYGAIN_OFF;
static float replayGainPreamp = 1.0;
void initReplayGainState() {
- if(!getConf()[CONF_REPLAYGAIN]) return;
+ ConfigParam * param = getConfigParam(CONF_REPLAYGAIN);
- if(strcmp(getConf()[CONF_REPLAYGAIN],"track")==0) {
+ if(!param) return;
+
+ if(strcmp(param->value, "track") == 0) {
replayGainState = REPLAYGAIN_TRACK;
}
- else if(strcmp(getConf()[CONF_REPLAYGAIN],"album")==0) {
+ else if(strcmp(param->value, "album") == 0) {
replayGainState = REPLAYGAIN_ALBUM;
}
else {
- ERROR("replaygain value \"%s\" is invalid\n",
- getConf()[CONF_REPLAYGAIN]);
+ ERROR("replaygain value \"%s\" at line %i is invalid\n",
+ param->value, param->line);
exit(EXIT_FAILURE);
}
- if(getConf()[CONF_REPLAYGAIN_PREAMP]) {
+ param = getConfigParam(CONF_REPLAYGAIN_PREAMP);
+
+ if(param) {
char * test;
- float f = strtod(getConf()[CONF_REPLAYGAIN_PREAMP], &test);
+ float f = strtod(param->value, &test);
if(*test != '\0') {
- ERROR("Replaygain preamp \"%s\" is not a number\n",
- getConf()[CONF_REPLAYGAIN_PREAMP]);
+ ERROR("Replaygain preamp \"%s\" is not a number at "
+ "line %i\n", param->value, param->line);
exit(EXIT_FAILURE);
}
if(f < -15 || f > 15) {
ERROR("Replaygain preamp \"%s\" is not between -15 and"
- "15\n",
- getConf()[CONF_REPLAYGAIN_PREAMP]);
+ "15 at line %i\n",
+ param->value, param->line);
exit(EXIT_FAILURE);
}
diff --git a/src/tag.c b/src/tag.c
index 08b620289..b5c71c500 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -93,18 +93,6 @@ char * getID3Info(struct id3_tag * tag, char * id) {
utf8 = id3_ucs4_utf8duplicate(ucs4);
if(!utf8) return NULL;
- if(getConf()[CONF_ID3V1_ENCODING]
- && (id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1)) {
-
- char* isostr;
- setCharSetConversion("ISO-8859-1", "UTF-8");
- isostr = convStrDup(utf8);
- free(utf8);
- setCharSetConversion("UTF-8", getConf()[CONF_ID3V1_ENCODING]);
- utf8 = convStrDup(isostr);
- free(isostr);
- }
-
return utf8;
}
#endif
diff --git a/src/volume.c b/src/volume.c
index fa2f8aaa9..cd48f76f4 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -45,8 +45,21 @@
#define VOLUME_MIXER_ALSA_DEFAULT "default"
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "Master"
-int volume_mixerType = VOLUME_MIXER_TYPE_SOFTWARE;
-char * volume_mixerDevice;
+#ifndef NO_OSS_MIXER
+#define VOLUME_MIXER_TYPE_DEFAULT VOLUME_MIXER_TYPE_OSS
+#define VOLUME_MIXER_DEVICE_DEFAULT VOLUME_MIXER_OSS_DEFAULT
+#else
+#ifdef HAVE_ALSA
+#define VOLUME_MIXER_TYPE_DEFAULT VOLUME_MIXER_TYPE_ALSA
+#define VOLUME_MIXER_DEVICE_DEFAULT VOLUME_MIXER_ALSA_DEFAULT
+#else
+#define VOLUME_MIXER_TYPE_DEFAULT VOLUME_MIXER_TYPE_SOFTWARE
+#define VOLUME_MIXER_DEVICE_DEFAULT VOLUME_MIXER_SOFTWARE_DEFAULT
+#endif
+#endif
+
+int volume_mixerType = VOLUME_MIXER_TYPE_DEFAULT;
+char * volume_mixerDevice = VOLUME_MIXER_DEVICE_DEFAULT;
int volume_softwareSet = 100;
@@ -66,13 +79,16 @@ int volume_alsaSet = -1;
#ifndef NO_OSS_MIXER
int prepOssMixer(char * device) {
int devmask = 0;
+ ConfigParam * param;
if((volume_ossFd = open(device,O_RDONLY))<0) {
WARNING("unable to open oss mixer \"%s\"\n",device);
return -1;
}
- if(getConf()[CONF_MIXER_CONTROL]) {
+ param = getConfigParam(CONF_MIXER_CONTROL);
+
+ if(param) {
char * labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
char * dup;
int i,j;
@@ -88,7 +104,7 @@ int prepOssMixer(char * device) {
/* eliminate spaces at the end */
j = strlen(dup)-1;
while(j>=0 && dup[j]==' ') dup[j--] = '\0';
- if(strcasecmp(dup,getConf()[CONF_MIXER_CONTROL])==0) {
+ if(strcasecmp(dup, param->value)==0) {
free(dup);
break;
}
@@ -96,14 +112,14 @@ int prepOssMixer(char * device) {
}
if(i>=SOUND_MIXER_NRDEVICES) {
- WARNING("mixer control \"%s\" not found\n",
- getConf()[CONF_MIXER_CONTROL]);
+ WARNING("mixer control \"%s\" not found at line %i\n",
+ param->value, param->line);
close(volume_ossFd);
return -1;
}
else if(!( ( 1 << i ) & devmask )) {
- WARNING("mixer control \"%s\" not usable\n",
- getConf()[CONF_MIXER_CONTROL]);
+ WARNING("mixer control \"%s\" not usable at line %i\n",
+ param->value, param->line);
close(volume_ossFd);
return -1;
}
@@ -173,6 +189,7 @@ int prepAlsaMixer(char * card) {
int err;
snd_mixer_elem_t * elem;
char * controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT;
+ ConfigParam * param;
if((err = snd_mixer_open(&volume_alsaMixerHandle,0))<0) {
WARNING("problems opening alsa mixer: %s\n",snd_strerror(err));
@@ -201,8 +218,11 @@ int prepAlsaMixer(char * card) {
}
elem = snd_mixer_first_elem(volume_alsaMixerHandle);
- if(getConf()[CONF_MIXER_CONTROL]) {
- controlName = getConf()[CONF_MIXER_CONTROL];
+
+ param = getConfigParam(CONF_MIXER_CONTROL);
+
+ if(param) {
+ controlName = param->value;
}
while(elem) {
@@ -340,29 +360,37 @@ void finishVolume() {
}
void initVolume() {
- if(0);
+ ConfigParam * param = getConfigParam(CONF_MIXER_TYPE);
+
+ if(param) {
+ if(0);
#ifdef HAVE_ALSA
- else if(strcmp((getConf())[CONF_MIXER_TYPE],VOLUME_MIXER_ALSA)==0) {
- volume_mixerType = VOLUME_MIXER_TYPE_ALSA;
- volume_mixerDevice = VOLUME_MIXER_ALSA_DEFAULT;
- }
+ else if(strcmp(param->value, VOLUME_MIXER_ALSA)==0) {
+ volume_mixerType = VOLUME_MIXER_TYPE_ALSA;
+ volume_mixerDevice = VOLUME_MIXER_ALSA_DEFAULT;
+ }
#endif
#ifndef NO_OSS_MIXER
- else if(strcmp((getConf())[CONF_MIXER_TYPE],VOLUME_MIXER_OSS)==0) {
- volume_mixerType = VOLUME_MIXER_TYPE_OSS;
- volume_mixerDevice = VOLUME_MIXER_OSS_DEFAULT;
- }
+ else if(strcmp(param->value, VOLUME_MIXER_OSS)==0) {
+ volume_mixerType = VOLUME_MIXER_TYPE_OSS;
+ volume_mixerDevice = VOLUME_MIXER_OSS_DEFAULT;
+ }
#endif
- else if(strcmp((getConf())[CONF_MIXER_TYPE],VOLUME_MIXER_SOFTWARE)==0) {
- volume_mixerType = VOLUME_MIXER_TYPE_SOFTWARE;
- volume_mixerDevice = VOLUME_MIXER_SOFTWARE_DEFAULT;
- }
- else {
- ERROR("unknown mixer type: %s\n",(getConf())[CONF_MIXER_TYPE]);
- exit(EXIT_FAILURE);
+ else if(strcmp(param->value ,VOLUME_MIXER_SOFTWARE)==0) {
+ volume_mixerType = VOLUME_MIXER_TYPE_SOFTWARE;
+ volume_mixerDevice = VOLUME_MIXER_SOFTWARE_DEFAULT;
+ }
+ else {
+ ERROR("unknown mixer type %s at line %i\n",
+ param->value, param->line);
+ exit(EXIT_FAILURE);
+ }
}
- if(strlen((getConf())[CONF_MIXER_DEVICE])) {
- volume_mixerDevice = (getConf())[CONF_MIXER_DEVICE];
+
+ param = getConfigParam(CONF_MIXER_DEVICE);
+
+ if(param) {
+ volume_mixerDevice = param->value;
}
}
@@ -431,4 +459,3 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
break;
}
}
-/* vim:set shiftwidth=4 tabstop=8 expandtab: */