EXC_BAD_ACCESS from AudioBuffer

Posted by jfalexvijay on Stack Overflow See other posts from Stack Overflow or by jfalexvijay
Published on 2011-01-03T07:05:36Z Indexed on 2011/01/03 12:53 UTC
Read the original article Hit count: 169

Filed under:
|

I am trying to do the record using AudioUnit for iPhone app.

Changes: (start) I have added the following code

    bufferList = (AudioBufferList *)malloc(sizeof(AudioBuffer));
    bufferList->mNumberBuffers = 1;
    bufferList->mBuffers[0].mNumberChannels = 2;
    bufferList->mBuffers[0].mDataByteSize = 1024;
    bufferList->mBuffers[0].mData = calloc(256, sizeof(uint32_t));
Changes: (end)


static OSStatus recordingCallback(void *inRefCon, 
                                  AudioUnitRenderActionFlags *ioActionFlags, 
                                  const AudioTimeStamp *inTimeStamp, 
                                  UInt32 inBusNumber, 
                                  UInt32 inNumberFrames, 
                                  AudioBufferList *ioData) {
    OSStatus status;
    status = AudioUnitRender(appdelegate->audioUnit, 
                             ioActionFlags, 
                             inTimeStamp, 
                             inBusNumber, 
                             inNumberFrames, 
                             appdelegate->bufferList);
    if(status != 0)
    NSLog(@"AudioUnitRender status is %d", status);
    SInt16* samples = (SInt16*)(ioData->mBuffers[0].mData);
    .....
}

fixed: (I am getting OSStatus -50 error code)- Because I didn't initialize the bufferList.

I am EXC_BAD_ACCESS from AudioBuffer (ioData->mBuffers[0].mData).

I am not sure with this error. Please help me to resolve it.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about exc-bad-access