diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-10-29 16:12:36 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-10-29 16:12:36 +0000 |
commit | 6aa27a3dd4c271a66e1f9d8a6ec1d95f092c224d (patch) | |
tree | 0c35bea4dce1546329cf9d3062f53e8dfec04f2f /src | |
parent | 65a956db17d1bb31412234a4a96c0b1c50b3c09c (diff) | |
download | mpd-6aa27a3dd4c271a66e1f9d8a6ec1d95f092c224d.tar.gz mpd-6aa27a3dd4c271a66e1f9d8a6ec1d95f092c224d.tar.xz mpd-6aa27a3dd4c271a66e1f9d8a6ec1d95f092c224d.zip |
sync w/ trunk
git-svn-id: https://svn.musicpd.org/mpd/branches/shank-rewrite-config@2398 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r-- | src/audio.c | 9 | ||||
-rw-r--r-- | src/audioOutput.c | 4 | ||||
-rw-r--r-- | src/audioOutput_ao.c | 3 | ||||
-rw-r--r-- | src/audioOutput_shout.c | 99 | ||||
-rw-r--r-- | src/decode.c | 4 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/playlist.c | 2 |
7 files changed, 103 insertions, 20 deletions
diff --git a/src/audio.c b/src/audio.c index e3a311abb..9df190dd5 100644 --- a/src/audio.c +++ b/src/audio.c @@ -175,7 +175,7 @@ void finishAudioDriver() { } int isCurrentAudioFormat(AudioFormat * audioFormat) { - if(!audioFormat) return 0; + if(!audioFormat) return 1; if(memcmp(audioFormat,&audio_format,sizeof(AudioFormat)) != 0) return 0; @@ -195,12 +195,9 @@ int openAudioDevice(AudioFormat * audioFormat) { for(i = 0; i < audioOutputArraySize; i++) { if(!audioOutputArray[i]->open || !isCurrentFormat) { - if(0 == openAudioOutput(audioOutputArray[i], - &audio_format)) - { - ret = 0; - } + openAudioOutput(audioOutputArray[i], &audio_format); } + if(audioOutputArray[i]->open) ret = 0; } return ret; diff --git a/src/audioOutput.c b/src/audioOutput.c index 0175ed04f..a1de85942 100644 --- a/src/audioOutput.c +++ b/src/audioOutput.c @@ -11,11 +11,13 @@ static List * audioOutputPluginList; void loadAudioOutputPlugin(AudioOutputPlugin * audioOutputPlugin) { + if(!audioOutputPlugin->name) return; insertInList(audioOutputPluginList, audioOutputPlugin->name, audioOutputPlugin); } void unloadAudioOutputPlugin(AudioOutputPlugin * audioOutputPlugin) { + if(!audioOutputPlugin->name) return; deleteFromList(audioOutputPluginList, audioOutputPlugin->name); } @@ -91,6 +93,8 @@ void closeAudioOutput(AudioOutput * audioOutput) { void finishAudioOutput(AudioOutput * audioOutput) { closeAudioOutput(audioOutput); audioOutput->finishDriverFunc(audioOutput); + free(audioOutput->type); + free(audioOutput->name); free(audioOutput); } diff --git a/src/audioOutput_ao.c b/src/audioOutput_ao.c index 60c4ea402..e904de322 100644 --- a/src/audioOutput_ao.c +++ b/src/audioOutput_ao.c @@ -172,10 +172,11 @@ static void audioOutputAo_closeDevice(AudioOutput * audioOutput) { if(ad->device) { blockSignals(); ao_close(ad->device); - audioOutput->open = 0; ad->device = NULL; unblockSignals(); } + + audioOutput->open = 0; } static int audioOutputAo_openDevice(AudioOutput * audioOutput, diff --git a/src/audioOutput_shout.c b/src/audioOutput_shout.c index f41b57359..8b8ee693c 100644 --- a/src/audioOutput_shout.c +++ b/src/audioOutput_shout.c @@ -56,6 +56,7 @@ typedef struct _ShoutData { vorbis_comment vc; float quality; + int bitrate; AudioFormat outAudioFormat; AudioFormat inAudioFormat; @@ -77,6 +78,8 @@ static ShoutData * newShoutData() { ret->convBufferLen = 0; ret->opened = 0; ret->tag = NULL; + ret->bitrate = -1; + ret->quality = -1.0; return ret; } @@ -135,15 +138,45 @@ static int shout_initDriver(AudioOutput * audioOutput, ConfigParam * param) { checkBlockParam("user"); user = blockParam->value; - checkBlockParam("quality"); + blockParam = getBlockParam(param, "quality"); - sd->quality = strtod(blockParam->value, &test); + if(blockParam) { + int line = blockParam->line; - if(*test != '\0' || sd->quality < 0.0 || sd->quality > 10.0) { - ERROR("shout quality \"%s\" is not a number in the range " - "0-10, line %i\n", blockParam->value, + 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 " + "rage 0-10, line %i\n", blockParam->value, blockParam->line); - exit(EXIT_FAILURE); + exit(EXIT_FAILURE); + } + + blockParam = getBlockParam(param, "bitrate"); + + if(blockParam) { + ERROR("quality (line %i) and bitrate (line %i) are " + "both defined for shout output\n", line, + blockParam->line); + exit(EXIT_FAILURE); + } + } + else { + blockParam = getBlockParam(param, "bitrate"); + + if(!blockParam) { + ERROR("neither bitrate nor quality defined for shout " + "output at line %i\n", param->line); + exit(EXIT_FAILURE); + } + + sd->bitrate = strtol(blockParam->value, &test, 10); + + if(*test != '\0' || sd->bitrate <= 0) { + ERROR("bitrate at line %i should be a positve integer " + "\n", blockParam->line); + exit(EXIT_FAILURE); + } } checkBlockParam("format"); @@ -162,13 +195,37 @@ static int shout_initDriver(AudioOutput * audioOutput, ConfigParam * param) { shout_set_format(sd->shoutConn, SHOUT_FORMAT_VORBIS) != SHOUTERR_SUCCESS || shout_set_protocol(sd->shoutConn, SHOUT_PROTOCOL_HTTP) - != SHOUTERR_SUCCESS) + != SHOUTERR_SUCCESS || + shout_set_agent(sd->shoutConn, "MPD") != SHOUTERR_SUCCESS) { ERROR("error configuring shout: %s\n", shout_get_error(sd->shoutConn)); exit(EXIT_FAILURE); } + { + char temp[11]; + memset(temp, 0, sizeof(temp)); + + snprintf(temp, sizeof(temp), "%d", sd->outAudioFormat.channels); + shout_set_audio_info(sd->shoutConn, SHOUT_AI_CHANNELS, temp); + + snprintf(temp, sizeof(temp), "%d", + sd->outAudioFormat.sampleRate); + shout_set_audio_info(sd->shoutConn, SHOUT_AI_SAMPLERATE, temp); + + if(sd->quality >= 0) { + snprintf(temp, sizeof(temp), "%2.2f", sd->quality); + shout_set_audio_info(sd->shoutConn, SHOUT_AI_QUALITY, + temp); + } + else { + snprintf(temp, sizeof(temp), "%d", sd->bitrate); + shout_set_audio_info(sd->shoutConn, SHOUT_AI_BITRATE, + temp); + } + } + audioOutput->data = sd; if(shoutInitCount == 0) shout_init(); @@ -261,9 +318,29 @@ static void copyTagToVorbisComment(ShoutData * sd) { 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/10.0) ) - { + if(sd->quality >= 0) { + if( 0 != vorbis_encode_init_vbr(&(sd->vi), + sd->outAudioFormat.channels, + sd->outAudioFormat.sampleRate, sd->quality*0.1) ) + { + ERROR("problem seting up vorbis encoder for shout\n"); + vorbis_info_clear(&(sd->vi)); + return -1; + } + } + else { + if( 0 != vorbis_encode_setup_managed(&(sd->vi), + sd->outAudioFormat.channels, + sd->outAudioFormat.sampleRate, -1.0, + sd->bitrate*1000, -1.0) ) + { + ERROR("problem seting up vorbis encoder for shout\n"); + vorbis_info_clear(&(sd->vi)); + return -1; + } + } + + if(0 != vorbis_encode_setup_init(&(sd->vi))) { ERROR("problem seting up vorbis encoder for shout\n"); vorbis_info_clear(&(sd->vi)); return -1; @@ -467,7 +544,7 @@ AudioOutputPlugin shoutPlugin = AudioOutputPlugin shoutPlugin = { - "shout", + NULL, NULL, NULL, NULL, diff --git a/src/decode.c b/src/decode.c index 148ed02c5..2a3170c7b 100644 --- a/src/decode.c +++ b/src/decode.c @@ -158,6 +158,10 @@ int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, } if((tag = metadataChunkToMpdTagDup(&(pc->fileMetadataChunk)))) { + /* lets put the filename in the title if no tag info */ + if(!tag->title && !tag->artist && !tag->album) { + tag->title = strdup(pc->currentUrl); + } sendMetadataToAudioDevice(tag); freeMpdTag(tag); } diff --git a/src/main.c b/src/main.c index f56d74939..d4732f046 100644 --- a/src/main.c +++ b/src/main.c @@ -201,7 +201,7 @@ void parseOptions(int argc, char ** argv, Options * options) { options->logFile = parseConfigFilePath(CONF_LOG_FILE,1); options->errorFile = parseConfigFilePath(CONF_ERROR_FILE, 1); - options->usr = parseConfigFilePath(CONF_USER, 0); + options->usr = getConfigParamValue(CONF_USER); options->dbFile = parseConfigFilePath(CONF_DB_FILE, 0); return; } diff --git a/src/playlist.c b/src/playlist.c index 74bb56116..a77581c5c 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -179,7 +179,7 @@ void initPlaylist() { srand(time(NULL)); - playlist_stateFile = getConfigParamValue(CONF_STATE_FILE); + playlist_stateFile = parseConfigFilePath(CONF_STATE_FILE, 0); for(i=0; i<playlist_max_length*PLAYLIST_HASH_MULT; i++) { playlist.idToPosition[i] = -1; |