aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-10-27 23:07:24 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-10-27 23:07:24 +0000
commit3e6a8042cadb03776e153aa1d7acab42b70d0c23 (patch)
tree8e06438633bff94c7307f3df69e3b34e3e4a125b
parent6237195faba7064df2496d410d9a615471b65807 (diff)
downloadmpd-3e6a8042cadb03776e153aa1d7acab42b70d0c23.tar.gz
mpd-3e6a8042cadb03776e153aa1d7acab42b70d0c23.tar.xz
mpd-3e6a8042cadb03776e153aa1d7acab42b70d0c23.zip
more config rewrite work, done with audioOutput* stuff
git-svn-id: https://svn.musicpd.org/mpd/branches/shank-rewrite-config@2365 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/audioOutput_shout.c84
-rw-r--r--src/conf.h2
2 files changed, 37 insertions, 49 deletions
diff --git a/src/audioOutput_shout.c b/src/audioOutput_shout.c
index 45ef00846..f41b57359 100644
--- a/src/audioOutput_shout.c
+++ b/src/audioOutput_shout.c
@@ -88,7 +88,16 @@ static void freeShoutData(ShoutData * sd) {
free(sd);
}
-static int shout_initDriver(AudioOutput * audioOutput) {
+#define checkBlockParam(name) { \
+ blockParam = getBlockParam(param, name); \
+ if(!blockParam) { \
+ ERROR("no \"%s\" defined for shout device defined at line " \
+ "%i\n", name, param->line); \
+ exit(EXIT_FAILURE); \
+ } \
+}
+
+static int shout_initDriver(AudioOutput * audioOutput, ConfigParam * param) {
ShoutData * sd;
char * test;
int port;
@@ -97,73 +106,50 @@ static int shout_initDriver(AudioOutput * audioOutput) {
char * passwd;
char * user;
char * name;
-
- if(!getConf()[CONF_SHOUT_HOST]) {
- return -1;
- }
+ BlockParam * blockParam;
sd = newShoutData();
- if(!getConf()[CONF_SHOUT_MOUNT]) {
- ERROR("shout host defined but not shout mount point\n");
- exit(EXIT_FAILURE);
- }
-
- if(!getConf()[CONF_SHOUT_PORT]) {
- ERROR("shout host defined but not shout port\n");
- exit(EXIT_FAILURE);
- }
+ checkBlockParam("host");
+ host = blockParam->value;
- if(!getConf()[CONF_SHOUT_PASSWD]) {
- ERROR("shout host defined but not shout password\n");
- exit(EXIT_FAILURE);
- }
+ checkBlockParam("mount");
+ mount = blockParam->value;
- if(!getConf()[CONF_SHOUT_NAME]) {
- ERROR("shout host defined but not shout name\n");
- exit(EXIT_FAILURE);
- }
+ checkBlockParam("port");
- if(!getConf()[CONF_SHOUT_USER]) {
- ERROR("shout host defined but not shout user\n");
- exit(EXIT_FAILURE);
- }
+ port = strtol(blockParam->value, &test, 10);
- if(!getConf()[CONF_SHOUT_QUALITY]) {
- ERROR("shout host defined but not shout quality\n");
+ if(*test != '\0' || port <= 0) {
+ ERROR("shout port \"%s\" is not a positive integer, line %i\n",
+ blockParam->value, blockParam->line);
exit(EXIT_FAILURE);
}
- if(!getConf()[CONF_SHOUT_FORMAT]) {
- ERROR("shout host defined but not shout format\n");
- exit(EXIT_FAILURE);
- }
+ checkBlockParam("password");
+ passwd = blockParam->value;
- host = getConf()[CONF_SHOUT_HOST];
- passwd = getConf()[CONF_SHOUT_PASSWD];
- user = getConf()[CONF_SHOUT_USER];
- mount = getConf()[CONF_SHOUT_MOUNT];
- name = getConf()[CONF_SHOUT_NAME];
+ checkBlockParam("name");
+ name = blockParam->value;
- port = strtol(getConf()[CONF_SHOUT_PORT], &test, 10);
+ checkBlockParam("user");
+ user = blockParam->value;
- if(*test != '\0' || port <= 0) {
- ERROR("shout port \"%s\" is not a positive integer\n",
- getConf()[CONF_SHOUT_PORT]);
- exit(EXIT_FAILURE);
- }
+ checkBlockParam("quality");
- sd->quality = strtod(getConf()[CONF_SHOUT_QUALITY], &test);
+ sd->quality = strtod(blockParam->value, &test);
if(*test != '\0' || sd->quality < 0.0 || sd->quality > 10.0) {
ERROR("shout quality \"%s\" is not a number in the range "
- "0-10\n", getConf()[CONF_SHOUT_QUALITY]);
+ "0-10, line %i\n", blockParam->value,
+ blockParam->line);
exit(EXIT_FAILURE);
}
- if(0 != parseAudioConfig(&(sd->outAudioFormat),
- getConf()[CONF_SHOUT_FORMAT]) )
- {
+ checkBlockParam("format");
+
+ if(0 != parseAudioConfig(&(sd->outAudioFormat), blockParam->value)) {
+ ERROR("error parsing format at line %i\n", blockParam->line);
exit(EXIT_FAILURE);
}
@@ -276,7 +262,7 @@ static int initEncoder(ShoutData * sd) {
vorbis_info_init(&(sd->vi));
if( 0 != vorbis_encode_init_vbr(&(sd->vi), sd->outAudioFormat.channels,
- sd->outAudioFormat.sampleRate, sd->quality) )
+ sd->outAudioFormat.sampleRate, sd->quality/10.0) )
{
ERROR("problem seting up vorbis encoder for shout\n");
vorbis_info_clear(&(sd->vi));
diff --git a/src/conf.h b/src/conf.h
index e3e1fb7b9..5bdff584d 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -79,6 +79,8 @@ ConfigParam * getNextConfigParam(char * name, ConfigParam * last);
#define getConfigParam(name) getNextConfigParam(name, NULL);
+char * getConfigParamValue(char * name);
+
void registerConfigParam(char * name, int repeats, int block);
BlockParam * getBlockParam(ConfigParam * param, char * name);