I'm trying to use Apple's MixerHostAudio class to mix and play audio files specified by the user.
The class files can be found here: http://developer.apple.com/library/ios/#samplecode/MixerHost/Listings/Classes_MixerHostAudio_h.html
To make the MixerHostAudio class play the files specified by the user, I instantiated the class with the NSURL of the files. This works great for the first instantiation, however when I wanted to the change the audio files played by releasing the old MixerHostAudio class and allocating a new one the app crashes with "EXC_BAD_ACCESS" seconds after the sound starts to plays.
After doing some debugging, I noticed that the error occurs in inputRenderCallback, where the AudioUnitSampleType (audioDataLeft, and audioDataRight) of the soundStructPointerArray is nil.
This is part of the code where the error occurred:
for (UInt32 frameNumber = 0; frameNumber < inNumberFrames; ++frameNumber) {
outSamplesChannelLeft[frameNumber] = dataInLeft[sampleNumber];
if (isStereo) outSamplesChannelRight[frameNumber] = dataInRight[sampleNumber];
Is there anyway for me to instantiate multiple instances of MixerHostAudio without getting an error??
Any help is greatly appreciated.