AIFF files that can't be read by JUCE


#1

Hello,

A user sent us two AIFF files that failed to be read by JUCE's AIFF reader implementation. Why I'm reporting it here is because the same files work correctly in other apps, most notably iTunes (unsurprisingly, it worked in VLC too).

The probleme with each files was:

The "AUTH" chunk was followed by the int 7, followed by "Beatles" and then a null byte. That makes a total of 8 bytes before the next chunk, hence it failed to find the "SSND" chunk, or any other chunks.

I made the following quick and dirty fix, but I'm not really happy with it:


                    int type = input->readInt();
                    while ((type & 0xff) == 0 && input->getPosition() < end)
                    {
                        type >>= 8;
                        type |= (int)input->readByte() << 24;
                    }

If, for some reason, the file is so corrupt that all the following read bytes are null, it reads the whole file, one byte at a time, before failing.

Has anyone a better fix? Can there be a limit to the number of extra null bytes?

Also, in our version of JUCE at least, if the "SSND" chunk isn't found, and if there is a valid sample rate, the reader says "valid" and dataChunkStart isn't initialised.


#2

Hmmm... this is strange as line 555 in juce_AiffAudioFormat.cpp should take care of this situation.  It takes only the lowest bit of chunkend (which if the lenght of the chunk was odd will be one) and adds this to the chunkend. This means that the next position will always be even. Can you pm me a stripped down audio file which causes this behaviour. You are using the latest tip?


#3

No, we are still using an old version (an upgrade is the works though).

I missed that difference when comparing our version to the latest.

This fix works with the said files, and makes much more sense, thanks.