mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 06:35:57 -05:00
Move collecting pmp3->file_size in the scanner driver rather than individual scanners. Fixes half of #166
This commit is contained in:
parent
e00ad47a55
commit
c319c8b090
@ -619,7 +619,8 @@ void scan_music_file(char *path, char *fname,
|
||||
memset((void*)&mp3file,0,sizeof(mp3file));
|
||||
mp3file.path=strdup(path);
|
||||
mp3file.fname=strdup(fname);
|
||||
|
||||
mp3file.file_size = psb->st_size;
|
||||
|
||||
if((fname) && (strlen(fname) > 1) && (fname[strlen(fname)-1] != '.')) {
|
||||
type = strrchr(fname, '.') + 1;
|
||||
if(type && *type) {
|
||||
@ -729,9 +730,6 @@ int scan_freetags(MP3FILE *pmp3) {
|
||||
* @param pmp3 struct to stuff with info gleaned
|
||||
*/
|
||||
int scan_get_info(char *file, MP3FILE *pmp3) {
|
||||
FILE *infile;
|
||||
off_t file_size;
|
||||
|
||||
TAGHANDLER *hdl;
|
||||
|
||||
/* dispatch to appropriate tag handler */
|
||||
@ -739,20 +737,6 @@ int scan_get_info(char *file, MP3FILE *pmp3) {
|
||||
if(hdl && hdl->scanner)
|
||||
return hdl->scanner(file,pmp3);
|
||||
|
||||
/* a file we don't know anything about... ogg or aiff maybe */
|
||||
if(!(infile=fopen(file,"rb"))) {
|
||||
DPRINTF(E_WARN,L_SCAN,"Could not open %s for reading\n",file);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* we can at least get this */
|
||||
fseek(infile,0,SEEK_END);
|
||||
file_size=ftell(infile);
|
||||
fseek(infile,0,SEEK_SET);
|
||||
|
||||
pmp3->file_size=file_size;
|
||||
|
||||
fclose(infile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -193,10 +193,6 @@ int scan_get_aacinfo(char *filename, MP3FILE *pmp3) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fseek(fin,0,SEEK_END);
|
||||
pmp3->file_size = ftell(fin);
|
||||
fseek(fin,0,SEEK_SET);
|
||||
|
||||
atom_offset=scan_aac_drilltoatom(fin, "moov:udta:meta:ilst", &atom_length);
|
||||
if(atom_offset != -1) {
|
||||
/* found the tag section - need to walk through now */
|
||||
|
@ -137,11 +137,6 @@ int scan_get_aifinfo(char *filename, MP3FILE *pmp3) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fseek(infile,0,SEEK_END);
|
||||
pmp3->file_size = ftell(infile);
|
||||
fseek(infile,0,SEEK_SET);
|
||||
|
||||
|
||||
/* first, verify we have a valid iff header */
|
||||
if(fread((void*)&iff_header,sizeof(AIF_IFF_HEADER),1,infile) != 1) {
|
||||
DPRINTF(E_WARN,L_SCAN,"Error reading %s -- bad iff header\n",filename);
|
||||
|
@ -68,22 +68,11 @@ int scan_get_flacinfo(char *filename, MP3FILE *pmp3) {
|
||||
FLAC__StreamMetadata *block;
|
||||
int found=0;
|
||||
unsigned int sec, ms;
|
||||
FILE *f;
|
||||
int i;
|
||||
char *val;
|
||||
size_t len;
|
||||
char tmp;
|
||||
|
||||
/* get file length */
|
||||
if (!(f = fopen(filename, "rb"))) {
|
||||
DPRINTF(E_WARN,L_SCAN,"Could not open %s for reading\n", filename);
|
||||
return FALSE;
|
||||
}
|
||||
fseek(f, 0, SEEK_END);
|
||||
pmp3->file_size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fclose(f);
|
||||
|
||||
chain = FLAC__metadata_chain_new();
|
||||
if (! chain) {
|
||||
DPRINTF(E_WARN,L_SCAN,"Cannot allocate FLAC metadata chain\n");
|
||||
|
@ -821,12 +821,6 @@ int scan_mp3_get_mp3fileinfo(char *file, MP3FILE *pmp3) {
|
||||
|
||||
memset((void*)&fi,0x00,sizeof(fi));
|
||||
|
||||
fseek(infile,0,SEEK_END);
|
||||
file_size=ftell(infile);
|
||||
fseek(infile,0,SEEK_SET);
|
||||
|
||||
pmp3->file_size=file_size;
|
||||
|
||||
if(fread(buffer,1,sizeof(buffer),infile) != sizeof(buffer)) {
|
||||
if(ferror(infile)) {
|
||||
DPRINTF(E_LOG,L_SCAN,"Error reading: %s\n",strerror(errno));
|
||||
|
@ -81,11 +81,6 @@ int scan_get_mp4info(char *filename, MP3FILE *pmp3) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fseek(fin,0,SEEK_END);
|
||||
pmp3->file_size = ftell(fin);
|
||||
fseek(fin,0,SEEK_SET);
|
||||
|
||||
|
||||
atom_offset=scan_aac_drilltoatom(fin, "moov:udta:meta:ilst", &atom_length);
|
||||
if(atom_offset != -1) {
|
||||
/* found the tag section - need to walk through now */
|
||||
|
@ -47,16 +47,6 @@ int scan_get_mpcinfo(char *filename, MP3FILE *pmp3) {
|
||||
int len;
|
||||
unsigned int i;
|
||||
|
||||
/* get file length */
|
||||
if (!(f = fopen(filename, "rb"))) {
|
||||
DPRINTF(E_WARN,L_SCAN,"Could not open %s for reading\n", filename);
|
||||
return FALSE;
|
||||
}
|
||||
fseek(f, 0, SEEK_END);
|
||||
pmp3->file_size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fclose(f);
|
||||
|
||||
/* open file with taglib */
|
||||
if ((file = taglib_file_new_type(filename, TagLib_File_MPC)) == NULL) {
|
||||
DPRINTF(E_WARN,L_SCAN,"Could not open %s with taglib\n", filename);
|
||||
|
@ -43,11 +43,6 @@ int scan_get_ogginfo(char *filename, MP3FILE *pmp3) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(!fseek(f,0,SEEK_END)) {
|
||||
pmp3->file_size=ftell(f);
|
||||
fseek(f,0,SEEK_SET);
|
||||
}
|
||||
|
||||
if (ov_open(f, &vf, NULL, 0) != 0) {
|
||||
fclose(f);
|
||||
DPRINTF(E_LOG, L_SCAN,
|
||||
|
@ -68,10 +68,6 @@ int scan_get_wavinfo(char *filename, MP3FILE *pmp3) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fseek(infile,0,SEEK_END);
|
||||
pmp3->file_size = ftell(infile);
|
||||
fseek(infile,0,SEEK_SET);
|
||||
|
||||
rl = fread(hdr, 1, 44, infile);
|
||||
fclose(infile);
|
||||
if (rl != 44) {
|
||||
|
@ -866,7 +866,7 @@ int scan_get_wmainfo(char *filename, MP3FILE *pmp3) {
|
||||
int item;
|
||||
int err;
|
||||
int res=TRUE;
|
||||
|
||||
|
||||
wma_fd = r_open2(filename,O_RDONLY);
|
||||
if(wma_fd == -1) {
|
||||
DPRINTF(E_INF,L_SCAN,"Error opening WMA file (%s): %s\n",filename,
|
||||
|
Loading…
Reference in New Issue
Block a user