diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-10-23 01:04:58 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-10-23 01:04:58 +0000 |
commit | 12597322a2c4a1271249eb66192bfb6f0e1294e5 (patch) | |
tree | 201e8b5d6ded1df66e19951df617214369bc4acc /src/audio.c | |
parent | 413bf61ea1c3beaee98197e8d759ac2375ce51ef (diff) | |
download | mpd-12597322a2c4a1271249eb66192bfb6f0e1294e5.tar.gz mpd-12597322a2c4a1271249eb66192bfb6f0e1294e5.tar.xz mpd-12597322a2c4a1271249eb66192bfb6f0e1294e5.zip |
configure shout encoding quality and audio format
git-svn-id: https://svn.musicpd.org/mpd/trunk@2307 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/audio.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/audio.c b/src/audio.c index f8bcd7edc..75d833be3 100644 --- a/src/audio.c +++ b/src/audio.c @@ -66,22 +66,27 @@ void getOutputAudioFormat(AudioFormat * inAudioFormat, void initAudioConfig() { char * conf = getConf()[CONF_AUDIO_OUTPUT_FORMAT]; - char * test; if(NULL == conf) return; audio_configFormat = malloc(sizeof(AudioFormat)); - memset(audio_configFormat,0,sizeof(AudioFormat)); + if(0 != parseAudioConfig(audio_configFormat, conf)) exit(EXIT_FAILURE); +} + +int parseAudioConfig(AudioFormat * audioFormat, char * conf) { + char * test; - audio_configFormat->sampleRate = strtol(conf,&test,10); + memset(audioFormat,0,sizeof(AudioFormat)); + + audioFormat->sampleRate = strtol(conf,&test,10); if(*test!=':') { ERROR("error parsing audio output format: %s\n",conf); - exit(EXIT_FAILURE); + return -1; } - /*switch(audio_configFormat->sampleRate) { + /*switch(audioFormat->sampleRate) { case 48000: case 44100: case 32000: @@ -89,47 +94,50 @@ void initAudioConfig() { break; default: ERROR("sample rate %i can not be used for audio output\n", - (int)audio_configFormat->sampleRate); - exit(EXIT_FAILURE); + (int)audioFormat->sampleRate); + return -1 }*/ - if(audio_configFormat->sampleRate <= 0) { + if(audioFormat->sampleRate <= 0) { ERROR("sample rate %i is not >= 0\n", - (int)audio_configFormat->sampleRate); - exit(EXIT_FAILURE); + (int)audioFormat->sampleRate); + return -1; } - audio_configFormat->bits = strtol(test+1,&test,10); + audioFormat->bits = strtol(test+1,&test,10); if(*test!=':') { ERROR("error parsing audio output format: %s\n",conf); - exit(EXIT_FAILURE); + return -1; } - switch(audio_configFormat->bits) { + switch(audioFormat->bits) { case 16: break; default: ERROR("bits %i can not be used for audio output\n", - (int)audio_configFormat->bits); - exit(EXIT_FAILURE); + (int)audioFormat->bits); + return -1; } - audio_configFormat->channels = strtol(test+1,&test,10); + audioFormat->channels = strtol(test+1,&test,10); if(*test!='\0') { ERROR("error parsing audio output format: %s\n",conf); - exit(EXIT_FAILURE); + return -1; } - switch(audio_configFormat->channels) { + switch(audioFormat->channels) { + case 1: case 2: break; default: ERROR("channels %i can not be used for audio output\n", - (int)audio_configFormat->channels); - exit(EXIT_FAILURE); + (int)audioFormat->channels); + return -1; } + + return 0; } void finishAudioConfig() { |