* thread #11: tid = 0x2d03, 0x028e2f77 libsystem_sim_c.dylib`memcpy$VARIANT$sse42 + 154, stop reason = EXC_BAD_ACCESS (code=2, address=0x0)
frame #0: 0x028e2f77 libsystem_sim_c.dylib`memcpy$VARIANT$sse42 + 154
frame #1: 0x002e2cad AudioToolbox`AudioRingBuffer::Store(AudioBufferList const*, unsigned long, long long) + 765
frame #2: 0x003ab516 AudioToolbox`ExtAudioFile::WriteFramesAsync(unsigned long, AudioBufferList const*) + 566
frame #3: 0x003ac5f4 AudioToolbox`ExtAudioFileWriteAsync + 116
frame #4: 0x00054f87 Cellular`-[TKCoreAudioBridge getGeneratedSamples:frames:] + 279 at TKCoreAudioBridge.m:221
Then I tried to work with just one channel, like this:
if (_isRecording) {
AudioBuffer *leftAudioBuffer = &ioData->mBuffers[0];
AudioBuffer *rightAudioBuffer = &ioData->mBuffers[1];
SInt32 *leftData = (SInt32 *) leftAudioBuffer->mData;
SInt32 *rightData = (SInt32 *) rightAudioBuffer->mData;
AudioBufferList abl;
abl.mNumberBuffers = 1;
abl.mBuffers[0] = *leftAudioBuffer;
checkError(ExtAudioFileWriteAsync(_recFileRef,
numFrames,
&abl),
"ExtAudioFileWriteAsync failed", false);
}
And, this time, it works (though the left channel of the file is filled with static because the ASBD expects two buffers.)
If I then try this:
if (_isRecording) {
AudioBuffer *leftAudioBuffer = &ioData->mBuffers[0];
AudioBuffer *rightAudioBuffer = &ioData->mBuffers[1];
SInt32 *leftData = (SInt32 *) leftAudioBuffer->mData;
SInt32 *rightData = (SInt32 *) rightAudioBuffer->mData;
AudioBufferList abl;
abl.mNumberBuffers = 2;
abl.mBuffers[0] = *leftAudioBuffer;
abl.mBuffers[1] = *rightAudioBuffer;
checkError(ExtAudioFileWriteAsync(_recFileRef,
numFrames,
ioData),
"ExtAudioFileWriteAsync failed", false);
}
I get the same EXC_BAD_ACCESS error.
How should I be writing stereo data to the file using that ASBD? Should I also be changing my RemoteIO's ASBD too? Is this something to do with interleaving?
Thanks