AudioConverterRef *conv;
AudioFileID *musicFileID;
UInt32 magicCookieSize = 0;
//...
// Open a new AudioFile and create a new AudioConverter here.
// ...
//Get Magic Cookie info(if exists) and pass it to converter
err = AudioFileGetPropertyInfo(*musicFileID,
kAudioFilePropertyMagicCookieData,
&magicCookieSize,
NULL);
if (err == noErr)
{
void *magicCookie = calloc (1, magicCookieSize);
if (magicCookie)
{
err = AudioFileGetProperty (*musicFileID,
kAudioFilePropertyMagicCookieData,
&magicCookieSize,
magicCookie);
// Give the AudioConverter the magic cookie decompression
//params if any exist
if (err == noErr)
{
err = AudioConverterSetProperty( *conv,
kAudioConverterDecompressionMagicCookie,
magicCookieSize,
magicCookie);
}
if (magicCookie) free(magicCookie);
}
}else //OK if audio doesn't need magic cookie data
err = noErr; //reset error status
|