Thanks Aran. You're doing it more or less the same way I am, and I've also now based mine on the example from Core Audio Public Utilities (CAAudioUnitOutputCapture) as it looks like you did.
I'm utterly at a loss here. I had some problems with my ASBDs which I've now fixed. If I use synchronous calls (for debugging) it still fails with a -50 on the recorder priming call, and still gives -50s on each write. If I use async calls then the priming call goes through fine, but the actual recording calls crash with the EXC_BAD_ACCESS as before.
// Set desired audio output format
memset(&_outputASBD, 0, sizeof(_outputASBD));
_outputASBD.mSampleRate = 44100.0;
_outputASBD.mFormatID = kAudioFormatLinearPCM;
_outputASBD.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsPacked;
_outputASBD.mBytesPerPacket = sizeof(AudioUnitSampleType);
_outputASBD.mBytesPerFrame = sizeof(AudioUnitSampleType);
_outputASBD.mFramesPerPacket = 1;
_outputASBD.mChannelsPerFrame = 2;
_outputASBD.mBitsPerChannel = 16;
// Set recording format
memset(&_fileASBD, 0, sizeof(_fileASBD));
_fileASBD.mSampleRate = 44100.00;
_fileASBD.mFormatID = kAudioFormatLinearPCM;
_fileASBD.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsPacked;;
_fileASBD.mBytesPerPacket = sizeof(AudioUnitSampleType);
_fileASBD.mBytesPerFrame = sizeof(AudioUnitSampleType);
_fileASBD.mFramesPerPacket = 1;
_fileASBD.mChannelsPerFrame = 2;
_fileASBD.mBitsPerChannel = 16;
_isRecording = NO;
_recordedSamples = 0;
Here I set up the file:
CFURLRef urlRef = (__bridge CFURLRef) url;
checkError(ExtAudioFileCreateWithURL(urlRef,
kAudioFileCAFType,
&_fileASBD,
NULL,
kAudioFileFlags_EraseFile,
&_recFileRef),
"ExtAudioFileCreateWithURL failed: creating file", false);
checkError(ExtAudioFileWriteAsync(_recFileRef,
0,
NULL),
"ExtAudioFileWriteAsync failed: initializing write buffers", false);
Here I write to the file in my callback:
checkError(u failed", false);
And I get backtraces like this when I try to record:
* thread #8: tid = 0x2503, 0x34213a68 libsystem_c.dylib`memmove$VARIANT$CortexA9 + 168, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x34213a68 libsystem_c.dylib`memmove$VARIANT$CortexA9 + 168
frame #1: 0x36743c70 AudioToolbox`AudioRingBuffer::Store(AudioBufferList const*, unsigned long, long long) + 576
frame #2: 0x367cf10e AudioToolbox`ExtAudioFile::WriteFramesAsync(unsigned long, AudioBufferList const*) + 490
frame #3: 0x367d4300 AudioToolbox`ExtAudioFileWriteAsync + 172
The line where the debugger stops is here in bold underline in the disassembly:
0x367d42e2: cbz r2, 0x367d42f0 ; ExtAudioFileWriteAsync + 156
0x367d42e4: movs r5, #1
0x367d42e6: str r5, [sp, #20]
0x367d42e8: movs r1, #0
0x367d42ea: mov r0, r2
0x367d42ec: bl 0x366fac00 ; CrashIfClientProvidedBogusAudioBufferList
0x367d42f0: movs r5, #2
0x367d42f2: ldr r1, [sp, #8]
0x367d42f4: str r5, [sp, #20]
0x367d42f6: mov r0, r4
0x367d42f8: movs r5, #0
0x367d42fa: ldr r2, [sp, #12]
0x367d42fc: bl 0x367cef24 ; ExtAudioFile::WriteFramesAsync(unsigned long, AudioBufferList const*)
0x367d4300: b 0x367d4320 ; ExtAudioFileWriteAsync + 204
0x367d4302: mov r0, r5
0x367d4304: blx 0x368add00 ; symbol stub for: __cxa_begin_catch
0x367d4308: ldr.w r5, [r0, #256]
0x367d430c: b 0x367d4316 ; ExtAudioFileWriteAsync + 194
0x367d430e: mov r0, r5
0x367d4310: blx 0x368add00 ; symbol stub for: __cxa_begin_catch
0x367d4314: ldr r5, [r0]
0x367d4316: mov.w r0, #4294967295
0x367d431a: str r0, [sp, #20]
0x367d431c: blx 0x368add20 ; symbol stub for: __cxa_end_catch
0x367d4320: add r0, sp, #16
0x367d4322: blx 0x368adb30 ; symbol stub for: _Unwind_SjLj_Unregister
The only other difference is that I'm now on the device itself.
Quite stuck now; I can usually muddle stuff out with a bit of Googling around but this has me stumped.
Thanks
On 4 Dec 2012, at 18:28, Aran Mulholland wrote: