Sample code from apple iPhoneMultichannelMixerTest can't run mp3 file
Posted
by Usman
on Stack Overflow
See other posts from Stack Overflow
or by Usman
Published on 2010-03-25T07:25:55Z
Indexed on
2010/03/25
7:33 UTC
Read the original article
Hit count: 951
Hi i want to control channel volume from my app and iPhoneMultichannelMixerTest (http://developer.apple.com/iphone/library/samplecode/iPhoneMultichannelMixerTest/)sample code form apple looks perfect for me. but i m heaving problem in playing mp3 files. code crashes in MultichannelMixerController.m at
static OSStatus renderInput(void
*inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList
*ioData) {
SoundBufferPtr sndbuf = (SoundBufferPtr)inRefCon;
UInt32 bufSamples = sndbuf[inBusNumber].numFrames; AudioUnitSampleType *in = sndbuf[inBusNumber].data; AudioUnitSampleType *outA = (AudioUnitSampleType
*)ioData->mBuffers[0].mData; AudioUnitSampleType *outB = (AudioUnitSampleType
*)ioData->mBuffers[1].mData;
UInt32 sample = sndbuf[inBusNumber].sampleNum; for (UInt32 i = 0; i < inNumberFrames;
++i) {
if (1 == inBusNumber) {
outA[i] = 0;
outB[i] = in[sample++]; //crash on this line.
} else {
outA[i] = in[sample++];
outB[i] = 0;
}
if (sample >= bufSamples) sample = 0;
}
sndbuf[inBusNumber].sampleNum = sample; // printf("bus %d sample %d\n", inBusNumber, sample);
return noErr; }
can any one tell me why this is happening. or is there any limitation to play mp3 on iPhone???
Thankz in Adv.
Usman
© Stack Overflow or respective owner