I am thinking about shipping an iPhone (2.1+ OS) app, with compressed audio delivered with the application. I'd like to convert those compressed audio files to native CAF lossless files on the iPhone when the user launches the application the first time (or when needed). This seems fairly straightforward after I looked at the Apple Mac Os X 10.5 sample code located at: /Developer/Examples/CoreAudio/SimpleSDK/ConvertFile/
Specifically the file UseExtAF.cpp looks almost exactly what I need in order to make the conversion possible. I built the sample app on Mac OS X, and ran it with one of my files (m4a), and it converted the file into a CAF file that was not compressed. (Excellent!)
I've converted the routines I needed into Objective-C, and tried using the same technique, but I'm getting a permissions ('perm') error when I run through the ConvertFile function. The permissions error is happening on the line:
err = ExtAudioFileSetProperty(infile, kExtAudioFileProperty_ClientDataFormat, size, &clientFormat);
It appears that the ExtAudioFileSetProperty function is unhappy with me trying to set the clientDataFormat for the input file. But if I comment out this line of code, I am unable to get all of the sample frames from the input file - which is what I need in order to convert the compressed file into an uncompressed format.
Is there a way I can work around this error? Or do I need to do this the more involved way, as shown in the UseAC-AF.cpp file in the ConvertFile sample for Mac OS X? I'll convert those methods if need be, but the ExtAudioFile API's look like they should do what I want.
Thank you for your help!
Scott Tury
P.S. I can send the ConvertFile() function if anyone is interested, but it's extremely similar to the Mac OS sample. |