diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-10-28 05:14:55 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-10-28 05:14:55 +0000 |
commit | 58dbe4bb5d974c34335d6906a9ce930f07cd1db4 (patch) | |
tree | 9a6aee08b21100cb74e809f0620d81466f6067df /src/audioOutput_shout.c | |
parent | 8f40569aeeafe4a36e3d719c1df97de42606ea76 (diff) | |
download | mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.tar.gz mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.tar.xz mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.zip |
merge shank-rewrite-config changes
git-svn-id: https://svn.musicpd.org/mpd/trunk@2375 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/audioOutput_shout.c')
-rw-r--r-- | src/audioOutput_shout.c | 84 |
1 files changed, 35 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)); |