FS#11719 - 48Khz FLAC and ALAC playing slow

Attached to Project: Rockbox
Opened by Thomas Brunoli (tominated) - Thursday, 04 November 2010, 04:12 GMT
Last edited by Andree Buschmann (Buschel) - Thursday, 03 February 2011, 09:28 GMT
Task Type Bugs
Category Music playback
Status Closed
Assigned To No-one
Operating System iPod 5G
Severity Low
Priority Normal
Reported Version Release 3.6
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


When playing any lossless track that has a 48Khz sampling rate, rockbox incorrectly shows the song time longer than it actually is, and plays it slowly. E.G. Hurt by Nine Inch Nails is shown to be and plays for 6 minutes and 50 seconds, but it is actually 6 minutes 17 seconds
This task depends upon

Closed by  Andree Buschmann (Buschel)
Thursday, 03 February 2011, 09:28 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed with r29201.
Comment by Nils Wallménius (nls) - Thursday, 04 November 2010, 13:47 GMT
could you attach such a file or post a link to one?
EDIT: i hexedited a flac file so it was played back as 48kHz and that worked fine, playtime was appropriately shortened.
Comment by Thomas Brunoli (tominated) - Friday, 05 November 2010, 10:50 GMT
Here's a copy of 'March of the Pigs' off the same album: I just noticed then, that the FLAC files don't have an issue (probably should've checked more thoroughly), but it's the ALAC copies that I have. Here's the ALAC copy that is slower than it should be:
Comment by Nils Wallménius (nls) - Saturday, 06 November 2010, 09:48 GMT
something is weird with that alac file, its metadata says it's 44.1kHz and that is what rockbox uses. None of my playback software can play back the file correctly but they do determine the correct duration and sample rate in some cases so there must be a different method for determining this although i would say this file is broken.

edit: a more recent version of ffmpeg decodes the file just fine but uses the 44.1kHz sample rate just as rockbox does. So i don't think this is a bug in rockbox, does the file play at its intended sample rate in any player?
Comment by Thomas Brunoli (tominated) - Sunday, 07 November 2010, 23:29 GMT
I never thought to try it in another player. In iTunes it works perfectly, but in VLC it jitters all over the place. I use a mac primarily, so I haven't tried anything else.
Comment by Andree Buschmann (Buschel) - Wednesday, 02 February 2011, 20:10 GMT
I cannot compare with other *.alac files as I do not own such files. But if you take a look into the file with a hex-editor you will see that there are two "alac" IDs in it. The first is followed by 0x00AC44 = 44100 (offset of 22 bytes to "alac"), the second is followed by 0x00BB80 = 48000 (offset of 24 bytes to "alac").

Edit: With the attached patch this file plays correct with the correct sampling rate. Does this also work for other alac files?
Comment by Andree Buschmann (Buschel) - Thursday, 03 February 2011, 00:09 GMT
Good news: We never parsed the right "alac" atom to gather the samplingrate.
Bad news: For now I see no other solution than to parse until we find this "alac" atom.

I am not satisfied with this solution and will further investigate.