CAF small update to speed up creation of reader


#1

Currently it takes a significant amount of time to create a reader for a CAF file. I am dealing with very large files and the issue is inside of CoreAudioFormatMetatdata::read. The following code:

  else if (chunkHeader.chunkType == chunkName ("data"))
                {
                    // -1 signifies an unknown data size so the data has to be at the
                    // end of the file so we must have finished the header

                    if (chunkHeader.chunkSize == -1)
                        break;

                    input.skipNextBytes (chunkHeader.chunkSize);
                }

The issue is skipping to the end of the file since, at least in my case, “data” is the last chunk type. Can something like this be added:

 else if (chunkHeader.chunkType == chunkName ("data"))
                {
                    // -1 signifies an unknown data size so the data has to be at the
                    // end of the file so we must have finished the header

                    if (chunkHeader.chunkSize == -1)
                        break;
                    
                    int64 length = input.getTotalLength();
                    if(length != -1){
                        if(chunkHeader.chunkSize + input.getPosition() == length){
                            break;
                        }
                    }

                    input.skipNextBytes (chunkHeader.chunkSize);
                }
'''

#2

I think the underlying issue here is that the base implementation of InputStream::skipNextBytes() is not particularly efficient. Can you see if 6ca7af7 fixes this for you?


#3

That fix works great. Thanks.