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/playlist.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/playlist.c')
-rw-r--r-- | src/playlist.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/playlist.c b/src/playlist.c index fd1873f93..74bb56116 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -60,6 +60,9 @@ #define PLAYLIST_HASH_MULT 4 +#define DEFAULT_PLAYLIST_MAX_LENGTH (1024*16) +#define DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS 0 + typedef struct _Playlist { Song ** songs; /* holds version a song was modified on */ @@ -77,13 +80,13 @@ typedef struct _Playlist { static Playlist playlist; static int playlist_state = PLAYLIST_STATE_STOP; -static int playlist_max_length; +static int playlist_max_length = DEFAULT_PLAYLIST_MAX_LENGTH; static int playlist_stopOnError; static int playlist_errorCount = 0; static int playlist_queueError; static int playlist_noGoToNext = 0; -static int playlist_saveAbsolutePaths; +static int playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS; static char * playlist_stateFile = NULL; @@ -128,6 +131,7 @@ static void incrPlaylistCurrent() { void initPlaylist() { char * test; int i; + ConfigParam * param; playlist.length = 0; playlist.repeat = 0; @@ -136,26 +140,32 @@ void initPlaylist() { playlist.queued = -1; playlist.current = -1; - playlist_max_length = strtol((getConf())[CONF_MAX_PLAYLIST_LENGTH],&test,10); - if(*test!='\0') { - ERROR("max playlist length \"%s\" is not an integer\n", - (getConf())[CONF_MAX_PLAYLIST_LENGTH]); - exit(EXIT_FAILURE); - } + param = getConfigParam(CONF_MAX_PLAYLIST_LENGTH); - if(strcmp("yes",(getConf())[CONF_SAVE_ABSOLUTE_PATHS_IN_PLAYLISTS]) - ==0) { - playlist_saveAbsolutePaths = 1; - } - else if(strcmp("no",(getConf())[CONF_SAVE_ABSOLUTE_PATHS_IN_PLAYLISTS]) - ==0) { - playlist_saveAbsolutePaths = 0; + if(param) { + playlist_max_length = strtol(param->value, &test, 10); + if(*test!='\0') { + ERROR("max playlist length \"%s\" is not an integer, " + "line %i\n", param->value, param->line); + exit(EXIT_FAILURE); + } } - else { - ERROR("save_absolute_paths_in_playlist \"%s\" is not yes or " - "no\n", - (getConf())[CONF_SAVE_ABSOLUTE_PATHS_IN_PLAYLISTS]); - exit(EXIT_FAILURE); + + param = getConfigParam(CONF_SAVE_ABSOLUTE_PATHS); + + if(param) { + if(0 == strcmp("yes", param->value) ) { + playlist_saveAbsolutePaths = 1; + } + else if(0 == strcmp("no", param->value) ) { + playlist_saveAbsolutePaths = 0; + } + else { + ERROR("%s \"%s\" is not yes or no, line %i" + CONF_SAVE_ABSOLUTE_PATHS, + param->value, param->line); + exit(EXIT_FAILURE); + } } playlist.songs = malloc(sizeof(Song *)*playlist_max_length); @@ -169,9 +179,7 @@ void initPlaylist() { srand(time(NULL)); - if(getConf()[CONF_STATE_FILE]) { - playlist_stateFile = getConf()[CONF_STATE_FILE]; - } + playlist_stateFile = getConfigParamValue(CONF_STATE_FILE); for(i=0; i<playlist_max_length*PLAYLIST_HASH_MULT; i++) { playlist.idToPosition[i] = -1; |