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
This commit is contained in:
Warren Dukes 2004-03-21 03:45:58 +00:00
parent 6436b0ac8a
commit 445d807b9c
3 changed files with 89 additions and 166 deletions

250
src/ls.c
View File

@ -110,202 +110,98 @@ int lsPlaylists(FILE * fp, char * utf8path) {
return 0; return 0;
} }
int isMusic(char * utf8file, time_t * mtime) { int isFile(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)) {
if(mtime) *mtime = st.st_mtime;
return 1;
}
else return 0;
}
return 0;
}
int hasSuffix(char * utf8file, char * suffix) {
char * file = utf8ToFsCharset(utf8file);
char * dup = strdup(file);;
char * cLast;
char * cNext = cLast = strtok(dup,".");
int ret = 0; int ret = 0;
#ifdef HAVE_OGG while((cNext = strtok(NULL,"."))) cLast = cNext;
if((ret = isOgg(utf8file,mtime))) return ret; if(cLast && 0==strcasecmp(cLast,suffix)) ret = 1;
#endif free(dup);
#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; return ret;
} }
int isPlaylist(char * utf8file) { int isPlaylist(char * utf8file) {
struct stat st; if(isFile(utf8file,NULL)) {
char * file = utf8ToFsCharset(utf8file); return hasSuffix(utf8file,PLAYLIST_FILE_SUFFIX);
char * actualFile = file;
char * temp = NULL;
if(actualFile[0]!='/') actualFile = rpp2app(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(temp) free(temp);
return 0; return 0;
} }
int hasWaveSuffix(char * utf8file) {
return hasSuffix(utf8file,"wav");
}
int isWave(char * utf8file, time_t * mtime) { int isWave(char * utf8file, time_t * mtime) {
struct stat st; if(isFile(utf8file,mtime)) return hasWaveSuffix(utf8file);
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,"wav")) {
if(mtime) *mtime = st.st_mtime;
ret = 1;
}
free(dup);
return ret;
}
else return 0;
}
return 0; return 0;
} }
int hasFlacSuffix(char * utf8file) {
return hasSuffix(utf8file,"flac");
}
int isFlac(char * utf8file, time_t * mtime) { int isFlac(char * utf8file, time_t * mtime) {
struct stat st; if(isFile(utf8file,mtime)) return hasFlacSuffix(utf8file);
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,"flac")) {
if(mtime) *mtime = st.st_mtime;
ret = 1;
}
free(dup);
return ret;
}
else return 0;
}
return 0; return 0;
} }
int hasOggSuffix(char * utf8file) {
return hasSuffix(utf8file,"ogg");
}
int isOgg(char * utf8file, time_t * mtime) { int isOgg(char * utf8file, time_t * mtime) {
struct stat st; if(isFile(utf8file,mtime)) return hasOggSuffix(utf8file);
char * file = utf8ToFsCharset(utf8file); return 0;
char * actualFile = file; }
if(actualFile[0]!='/') actualFile = rmp2amp(file); int hasAacSuffix(char * utf8file) {
return hasSuffix(utf8file,"aac");
}
if(stat(actualFile,&st)==0) { int isAac(char * utf8file, time_t * mtime) {
if(S_ISREG(st.st_mode)) { if(isFile(utf8file,mtime)) return hasAacSuffix(utf8file);
char * dup; return 0;
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 hasMp4Suffix(char * utf8file) {
if(hasSuffix(utf8file,"mp4")) return 1;
if(hasSuffix(utf8file,"m4a")) return 1;
return 0; return 0;
} }
int isMp4(char * utf8file, time_t * mtime) { int isMp4(char * utf8file, time_t * mtime) {
struct stat st; if(isFile(utf8file,mtime)) return hasMp4Suffix(utf8file);
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;
}
return 0; return 0;
} }
int hasMp3Suffix(char * utf8file) {
return hasSuffix(utf8file,"mp3");
}
int isMp3(char * utf8file, time_t * mtime) { int isMp3(char * utf8file, time_t * mtime) {
struct stat st; if(isFile(utf8file,mtime)) return hasMp3Suffix(utf8file);
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;
}
return 0; return 0;
} }
@ -325,3 +221,27 @@ int isDir(char * utf8name, time_t * mtime) {
return 0; 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;
}

View File

@ -28,6 +28,8 @@ int lsPlaylists(FILE * fp, char * utf8path);
int isMp3(char * utf8file, time_t * mtime); int isMp3(char * utf8file, time_t * mtime);
int isAac(char * utf8file, time_t * mtime);
int isMp4(char * utf8file, time_t * mtime); int isMp4(char * utf8file, time_t * mtime);
int isOgg(char * utf8file, time_t * mtime); int isOgg(char * utf8file, time_t * mtime);

View File

@ -133,7 +133,8 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
config = faacDecGetCurrentConfiguration(decoder); config = faacDecGetCurrentConfiguration(decoder);
config->outputFormat = FAAD_FMT_16BIT; config->outputFormat = FAAD_FMT_16BIT;
config->downMatrix = 1; config->downMatrix = 1;
config->dontUpSampleImplicitSBR = 1; /*comment this out, its not in faad2 2.0 rc2*/
/*config->dontUpSampleImplicitSBR = 0;*/
faacDecSetConfiguration(decoder,config); faacDecSetConfiguration(decoder,config);
af->bits = 16; af->bits = 16;