diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-03-21 03:45:58 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-03-21 03:45:58 +0000 |
commit | 445d807b9cdd32619bee42339315b7e83d18eaca (patch) | |
tree | 5c6a60ca918622eac62d51c74710b323fcd4f525 | |
parent | 6436b0ac8a59914b9edf8987274ef66f69637f36 (diff) | |
download | mpd-445d807b9cdd32619bee42339315b7e83d18eaca.tar.gz mpd-445d807b9cdd32619bee42339315b7e83d18eaca.tar.xz mpd-445d807b9cdd32619bee42339315b7e83d18eaca.zip |
streamline ls.c code
remove dontUpSampleSBR, not in faad2 rc3
git-svn-id: https://svn.musicpd.org/mpd/trunk@330 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/ls.c | 236 | ||||
-rw-r--r-- | src/ls.h | 2 | ||||
-rw-r--r-- | src/mp4_decode.c | 3 |
3 files changed, 82 insertions, 159 deletions
@@ -110,202 +110,98 @@ int lsPlaylists(FILE * fp, char * utf8path) { return 0; } -int isMusic(char * utf8file, time_t * mtime) { - int ret = 0; - -#ifdef HAVE_OGG - if((ret = isOgg(utf8file,mtime))) return ret; -#endif -#ifdef HAVE_FLAC - if((ret = isFlac(utf8file,mtime))) return ret; -#endif -#ifdef HAVE_MAD - if((ret = isMp3(utf8file,mtime))) return ret; -#endif -#ifdef HAVE_AUDIOFILE - if((ret = isWave(utf8file,mtime))) return ret; -#endif -#ifdef HAVE_FAAD - if((ret = isMp4(utf8file,mtime))) return ret; -#endif - - return ret; -} - -int isPlaylist(char * utf8file) { +int isFile(char * utf8file, time_t * mtime) { struct stat st; char * file = utf8ToFsCharset(utf8file); char * actualFile = file; - char * temp = NULL; - if(actualFile[0]!='/') actualFile = rpp2app(file); + if(actualFile[0]!='/') actualFile = rmp2amp(file); if(stat(actualFile,&st)==0) { if(S_ISREG(st.st_mode)) { - char * dup; - char * cLast; - char * cNext; - int ret = 0; - dup = strdup(file); - cNext = cLast = strtok(dup,"."); - while((cNext = strtok(NULL,"."))) cLast = cNext; - if(cLast && 0==strcmp(cLast,PLAYLIST_FILE_SUFFIX)) { - ret = 1; - } - free(dup); - if(temp) free(temp); - return ret; + if(mtime) *mtime = st.st_mtime; + return 1; } + else return 0; } - if(temp) free(temp); return 0; } -int isWave(char * utf8file, time_t * mtime) { - struct stat st; +int hasSuffix(char * utf8file, char * suffix) { char * file = utf8ToFsCharset(utf8file); - char * actualFile = file; + char * dup = strdup(file);; + char * cLast; + char * cNext = cLast = strtok(dup,"."); + int ret = 0; - if(actualFile[0]!='/') actualFile = rmp2amp(file); + while((cNext = strtok(NULL,"."))) cLast = cNext; + if(cLast && 0==strcasecmp(cLast,suffix)) ret = 1; + free(dup); - if(stat(actualFile,&st)==0) { - if(S_ISREG(st.st_mode)) { - char * dup; - char * cLast; - char * cNext; - int ret = 0; - dup = strdup(file); - cNext = cLast = strtok(dup,"."); - while((cNext = strtok(NULL,"."))) cLast = cNext; - if(cLast && 0==strcasecmp(cLast,"wav")) { - if(mtime) *mtime = st.st_mtime; - ret = 1; - } - free(dup); - return ret; - } - else return 0; - } + return ret; +} +int isPlaylist(char * utf8file) { + if(isFile(utf8file,NULL)) { + return hasSuffix(utf8file,PLAYLIST_FILE_SUFFIX); + } return 0; } -int isFlac(char * utf8file, time_t * mtime) { - struct stat st; - char * file = utf8ToFsCharset(utf8file); - char * actualFile = file; +int hasWaveSuffix(char * utf8file) { + return hasSuffix(utf8file,"wav"); +} - if(actualFile[0]!='/') actualFile = rmp2amp(file); +int isWave(char * utf8file, time_t * mtime) { + if(isFile(utf8file,mtime)) return hasWaveSuffix(utf8file); + return 0; +} - if(stat(actualFile,&st)==0) { - if(S_ISREG(st.st_mode)) { - char * dup; - char * cLast; - char * cNext; - int ret = 0; - dup = strdup(file); - cNext = cLast = strtok(dup,"."); - while((cNext = strtok(NULL,"."))) cLast = cNext; - if(cLast && 0==strcasecmp(cLast,"flac")) { - if(mtime) *mtime = st.st_mtime; - ret = 1; - } - free(dup); - return ret; - } - else return 0; - } +int hasFlacSuffix(char * utf8file) { + return hasSuffix(utf8file,"flac"); +} +int isFlac(char * utf8file, time_t * mtime) { + if(isFile(utf8file,mtime)) return hasFlacSuffix(utf8file); return 0; } +int hasOggSuffix(char * utf8file) { + return hasSuffix(utf8file,"ogg"); +} + int isOgg(char * utf8file, time_t * mtime) { - struct stat st; - char * file = utf8ToFsCharset(utf8file); - char * actualFile = file; + if(isFile(utf8file,mtime)) return hasOggSuffix(utf8file); + return 0; +} - if(actualFile[0]!='/') actualFile = rmp2amp(file); +int hasAacSuffix(char * utf8file) { + return hasSuffix(utf8file,"aac"); +} - if(stat(actualFile,&st)==0) { - if(S_ISREG(st.st_mode)) { - char * dup; - char * cLast; - char * cNext; - int ret = 0; - dup = strdup(file); - cNext = cLast = strtok(dup,"."); - while((cNext = strtok(NULL,"."))) cLast = cNext; - if(cLast && 0==strcasecmp(cLast,"ogg")) { - if(mtime) *mtime = st.st_mtime; - ret = 1; - } - free(dup); - return ret; - } - else return 0; - } +int isAac(char * utf8file, time_t * mtime) { + if(isFile(utf8file,mtime)) return hasAacSuffix(utf8file); + return 0; +} +int hasMp4Suffix(char * utf8file) { + if(hasSuffix(utf8file,"mp4")) return 1; + if(hasSuffix(utf8file,"m4a")) return 1; return 0; } int isMp4(char * utf8file, time_t * mtime) { - struct stat st; - char * file = utf8ToFsCharset(utf8file); - char * actualFile = file; - - if(actualFile[0]!='/') actualFile = rmp2amp(file); - - if(stat(actualFile,&st)==0) { - if(S_ISREG(st.st_mode)) { - char * dup; - char * cLast; - char * cNext; - int ret = 0; - dup = strdup(file); - cNext = cLast = strtok(dup,"."); - while((cNext = strtok(NULL,"."))) cLast = cNext; - if(cLast && (0==strcasecmp(cLast,"m4a") || - 0==strcasecmp(cLast,"mp4"))) - { - if(mtime) *mtime = st.st_mtime; - ret = 1; - } - free(dup); - return ret; - } - else return 0; - } - + if(isFile(utf8file,mtime)) return hasMp4Suffix(utf8file); return 0; } -int isMp3(char * utf8file, time_t * mtime) { - struct stat st; - char * file = utf8ToFsCharset(utf8file); - char * actualFile = file; - - if(actualFile[0]!='/') actualFile = rmp2amp(file); - - if(stat(actualFile,&st)==0) { - if(S_ISREG(st.st_mode)) { - char * dup; - char * cLast; - char * cNext; - int ret = 0; - dup = strdup(file); - cNext = cLast = strtok(dup,"."); - while((cNext = strtok(NULL,"."))) cLast = cNext; - if(cLast && 0==strcasecmp(cLast,"mp3")) { - if(mtime) *mtime = st.st_mtime; - ret = 1; - } - free(dup); - return ret; - } - else return 0; - } +int hasMp3Suffix(char * utf8file) { + return hasSuffix(utf8file,"mp3"); +} +int isMp3(char * utf8file, time_t * mtime) { + if(isFile(utf8file,mtime)) return hasMp3Suffix(utf8file); return 0; } @@ -325,3 +221,27 @@ int isDir(char * utf8name, time_t * mtime) { return 0; } + +int isMusic(char * utf8file, time_t * mtime) { + if(isFile(utf8file,mtime)) { +#ifdef HAVE_OGG + if(hasOggSuffix(utf8file)) return 1; +#endif +#ifdef HAVE_FLAC + if(hasFlacSuffix(utf8file)) return 1; +#endif +#ifdef HAVE_MAD + if(hasMp3Suffix(utf8file)) return 1; +#endif +#ifdef HAVE_AUDIOFILE + if(hasWaveSuffix(utf8file)) return 1; +#endif +#ifdef HAVE_FAAD + if(hasMp4Suffix(utf8file)) return 1; + if(hasAacSuffix(utf8file)) return 1; + } +#endif + + return 0; +} + @@ -28,6 +28,8 @@ int lsPlaylists(FILE * fp, char * utf8path); int isMp3(char * utf8file, time_t * mtime); +int isAac(char * utf8file, time_t * mtime); + int isMp4(char * utf8file, time_t * mtime); int isOgg(char * utf8file, time_t * mtime); diff --git a/src/mp4_decode.c b/src/mp4_decode.c index 4a0e168b8..cf7fb6137 100644 --- a/src/mp4_decode.c +++ b/src/mp4_decode.c @@ -133,7 +133,8 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) { config = faacDecGetCurrentConfiguration(decoder); config->outputFormat = FAAD_FMT_16BIT; config->downMatrix = 1; - config->dontUpSampleImplicitSBR = 1; + /*comment this out, its not in faad2 2.0 rc2*/ + /*config->dontUpSampleImplicitSBR = 0;*/ faacDecSetConfiguration(decoder,config); af->bits = 16; |