FS#10067 - FLAC, Divide by zero error
Opened by Frank Grisafi (JobVanDam) - Sunday, 29 March 2009, 03:23 GMT
Last edited by Magnus Holmgren (learman) - Sunday, 29 March 2009, 15:09 GMT
Using Rockbox 3.2, when playing FLAC files shorter than a second causes the following error:
Divide by zero at 01E56B90
Dreamlayers (Boris Gjenero) already located the source of the error so he deserves credit. Forum post of complete findings:
Here's the bug, in flac_init():
/* Calculate track length (in ms) and estimate the bitrate
(in kbit/s) */
fc->length = (fc->totalsamples / fc->samplerate) * 1000;
That's integer division, so if the track is shorter than a second, the result is zero. For example, here's GDB after playing Worms - Jock - Ya Can What Side Yer On.flac, Worms - Jock - Ya Numpty.flac on the r20528 5G iPod sim:
Program received signal SIGFPE, Arithmetic exception.
[Switching to thread 4880.0x818]
0x030a16d5 in flac_init (fc=0x6adfcb0, first_frame_offset=0)
175 fc->bitrate = ((fc->filesize-fc->metadatalength) * 8 ) / fc->length;
(gdb) p fc->totalsamples
$1 = 16383
(gdb) p fc->samplerate
$2 = 22050
Attached are 3, royalty free, FLAC files that are shorter than a second so whoever takes up this task can test it out.
If any other information is needed please don't hesitate to ask.
Sunday, 29 March 2009, 15:09 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed in r20567.