stop crash on unknown song_length

This commit is contained in:
Ron Pedde 2006-06-07 04:38:54 +00:00
parent 53125647d6
commit 606858a02f
1 changed files with 5 additions and 3 deletions

View File

@ -971,14 +971,16 @@ int scan_mp3_get_mp3fileinfo(char *file, MP3FILE *pmp3) {
pmp3->song_length = (int) ((double) file_size * 8. /
(double) fi.bitrate);
} else {
} else if (fi.samplerate ) {
pmp3->song_length = (int) ((double)(fi.number_of_frames*fi.samples_per_frame*1000.)/
(double) fi.samplerate);
}
/* back-calculate bitrate from duration */
pmp3->bitrate = ((file_size / 1000) * 8) /
(pmp3->song_length / 1000);
if(pmp3->song_length) { /* could still be unknown */
pmp3->bitrate = ((file_size / 1000) * 8) /
(pmp3->song_length / 1000);
}
}
DPRINTF(E_DBG,L_SCAN," Song Length: %d\n",pmp3->song_length);