FlacReader bug?


Seems that there is a bug in the FlacReader. I added it to my DJ application, there I have a Thread that always reads in portions of 64K buffers. I get random “jumps” (like very small loops) in the audio that is coming out.

And when reading further than the amount of samples the file has, I get a small FM-like sound.

All other JUCE AudioFormatReaders work well and don’t produce any kind of artifacts.

If you want, I can send you the .EXE of my app together with the test-FLAC I use, if that helps.


Well, if it’s a bug in the flac code itself, I’m not sure how I’d track it down, as I haven’t a clue how it works internally. I changed some stuff a couple of months ago to remove any unnecessary file-seeks when streaming from audio files, as that was causing problems with some of the codecs - are you using a code-base older than that?


I tried the code from the tip; the bug is still there.


Well, I wouldn’t know where to start looking, TBH.

It’s the sort of bug that you could spend days on, and right now finding even minutes to spare is tricky, so I can’t look into it.

One quick idea for you to think about - maybe the flac codec isn’t properly multithreaded? If there are multiple streams reading, maybe they’re sharing a static somewhere and corrupting each other?


No, there was just one stream, if I find out what it is I´ll let you know…


I’ve re-checked your code, and found no error. Then I tried the application Mixxx which allows playing files in reverse, and when playing FLAC files in reverse with this application, there are also clicks and pops (I assume at the beginning of each big block it seeks and then reads for playing in reverse).

So there’s a bug in libFLAC without any doubt. I posted a bug report to the FLAC team, let’s see what they find out…


Thanks - always good to hear when something isn’t my fault!