Skip mp3 files with no sync frame

This commit is contained in:
Ron Pedde 2003-11-14 16:19:21 +00:00
parent d780313965
commit 0885bbfb50

View File

@ -149,10 +149,12 @@ int scan_foreground(char *path) {
mp3file.fname=de.d_name; mp3file.fname=de.d_name;
/* Do the tag lookup here */ /* Do the tag lookup here */
scan_gettags(mp3file.path,&mp3file); if(!scan_gettags(mp3file.path,&mp3file) &&
scan_getfileinfo(mp3file.path,&mp3file); !scan_getfileinfo(mp3file.path,&mp3file)) {
db_add(&mp3file);
db_add(&mp3file); } else {
DPRINTF(ERR_INFO,"Skipping %s\n",de.d_name);
}
scan_freetags(&mp3file); scan_freetags(&mp3file);
} }
@ -259,8 +261,8 @@ int scan_getfileinfo(char *file, MP3FILE *pmp3) {
FILE *infile; FILE *infile;
SCAN_ID3HEADER *pid3; SCAN_ID3HEADER *pid3;
unsigned int size=0; unsigned int size=0;
fpos_t fp_size=0; long fp_size;
fpos_t file_size; long file_size;
unsigned char buffer[256]; unsigned char buffer[256];
int time_seconds; int time_seconds;
@ -292,8 +294,6 @@ int scan_getfileinfo(char *file, MP3FILE *pmp3) {
fread(buffer,1,sizeof(buffer),infile); fread(buffer,1,sizeof(buffer),infile);
if((buffer[0] == 0xFF)&&(buffer[1] >= 224)) { if((buffer[0] == 0xFF)&&(buffer[1] >= 224)) {
printf("Found sync frame\n");
ver=(buffer[1] & 0x18) >> 3; ver=(buffer[1] & 0x18) >> 3;
layer=(buffer[1] & 0x6) >> 1; layer=(buffer[1] & 0x6) >> 1;
if((ver==3) && (layer==1)) { /* MPEG1, Layer 3 */ if((ver==3) && (layer==1)) { /* MPEG1, Layer 3 */
@ -313,6 +313,9 @@ int scan_getfileinfo(char *file, MP3FILE *pmp3) {
} }
pmp3->bitrate=bitrate; pmp3->bitrate=bitrate;
pmp3->samplerate=samplerate; pmp3->samplerate=samplerate;
} else {
/* not an mp3... */
return -1;
} }
/* guesstimate the file length */ /* guesstimate the file length */