mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-13 07:53:23 -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,6 +619,7 @@ void scan_music_file(char *path, char *fname,
|
|||||||
memset((void*)&mp3file,0,sizeof(mp3file));
|
memset((void*)&mp3file,0,sizeof(mp3file));
|
||||||
mp3file.path=strdup(path);
|
mp3file.path=strdup(path);
|
||||||
mp3file.fname=strdup(fname);
|
mp3file.fname=strdup(fname);
|
||||||
|
mp3file.file_size = psb->st_size;
|
||||||
|
|
||||||
if((fname) && (strlen(fname) > 1) && (fname[strlen(fname)-1] != '.')) {
|
if((fname) && (strlen(fname) > 1) && (fname[strlen(fname)-1] != '.')) {
|
||||||
type = strrchr(fname, '.') + 1;
|
type = strrchr(fname, '.') + 1;
|
||||||
@ -729,9 +730,6 @@ int scan_freetags(MP3FILE *pmp3) {
|
|||||||
* @param pmp3 struct to stuff with info gleaned
|
* @param pmp3 struct to stuff with info gleaned
|
||||||
*/
|
*/
|
||||||
int scan_get_info(char *file, MP3FILE *pmp3) {
|
int scan_get_info(char *file, MP3FILE *pmp3) {
|
||||||
FILE *infile;
|
|
||||||
off_t file_size;
|
|
||||||
|
|
||||||
TAGHANDLER *hdl;
|
TAGHANDLER *hdl;
|
||||||
|
|
||||||
/* dispatch to appropriate tag handler */
|
/* dispatch to appropriate tag handler */
|
||||||
@ -739,20 +737,6 @@ int scan_get_info(char *file, MP3FILE *pmp3) {
|
|||||||
if(hdl && hdl->scanner)
|
if(hdl && hdl->scanner)
|
||||||
return hdl->scanner(file,pmp3);
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,10 +193,6 @@ int scan_get_aacinfo(char *filename, MP3FILE *pmp3) {
|
|||||||
return FALSE;
|
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);
|
atom_offset=scan_aac_drilltoatom(fin, "moov:udta:meta:ilst", &atom_length);
|
||||||
if(atom_offset != -1) {
|
if(atom_offset != -1) {
|
||||||
/* found the tag section - need to walk through now */
|
/* found the tag section - need to walk through now */
|
||||||
|
@ -137,11 +137,6 @@ int scan_get_aifinfo(char *filename, MP3FILE *pmp3) {
|
|||||||
return FALSE;
|
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 */
|
/* first, verify we have a valid iff header */
|
||||||
if(fread((void*)&iff_header,sizeof(AIF_IFF_HEADER),1,infile) != 1) {
|
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);
|
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;
|
FLAC__StreamMetadata *block;
|
||||||
int found=0;
|
int found=0;
|
||||||
unsigned int sec, ms;
|
unsigned int sec, ms;
|
||||||
FILE *f;
|
|
||||||
int i;
|
int i;
|
||||||
char *val;
|
char *val;
|
||||||
size_t len;
|
size_t len;
|
||||||
char tmp;
|
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();
|
chain = FLAC__metadata_chain_new();
|
||||||
if (! chain) {
|
if (! chain) {
|
||||||
DPRINTF(E_WARN,L_SCAN,"Cannot allocate FLAC metadata chain\n");
|
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));
|
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(fread(buffer,1,sizeof(buffer),infile) != sizeof(buffer)) {
|
||||||
if(ferror(infile)) {
|
if(ferror(infile)) {
|
||||||
DPRINTF(E_LOG,L_SCAN,"Error reading: %s\n",strerror(errno));
|
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;
|
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);
|
atom_offset=scan_aac_drilltoatom(fin, "moov:udta:meta:ilst", &atom_length);
|
||||||
if(atom_offset != -1) {
|
if(atom_offset != -1) {
|
||||||
/* found the tag section - need to walk through now */
|
/* found the tag section - need to walk through now */
|
||||||
|
@ -47,16 +47,6 @@ int scan_get_mpcinfo(char *filename, MP3FILE *pmp3) {
|
|||||||
int len;
|
int len;
|
||||||
unsigned int i;
|
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 */
|
/* open file with taglib */
|
||||||
if ((file = taglib_file_new_type(filename, TagLib_File_MPC)) == NULL) {
|
if ((file = taglib_file_new_type(filename, TagLib_File_MPC)) == NULL) {
|
||||||
DPRINTF(E_WARN,L_SCAN,"Could not open %s with taglib\n", filename);
|
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;
|
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) {
|
if (ov_open(f, &vf, NULL, 0) != 0) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
DPRINTF(E_LOG, L_SCAN,
|
DPRINTF(E_LOG, L_SCAN,
|
||||||
|
@ -68,10 +68,6 @@ int scan_get_wavinfo(char *filename, MP3FILE *pmp3) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(infile,0,SEEK_END);
|
|
||||||
pmp3->file_size = ftell(infile);
|
|
||||||
fseek(infile,0,SEEK_SET);
|
|
||||||
|
|
||||||
rl = fread(hdr, 1, 44, infile);
|
rl = fread(hdr, 1, 44, infile);
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
if (rl != 44) {
|
if (rl != 44) {
|
||||||
|
Loading…
Reference in New Issue
Block a user