mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 22:55:56 -05:00
stop crash on unknown song_length
This commit is contained in:
parent
53125647d6
commit
606858a02f
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user