PureDarwin Audio, or audio without CoreAudio
PureDarwin Audio, or audio without CoreAudio
- Subject: PureDarwin Audio, or audio without CoreAudio
- From: Cooper <email@hidden>
- Date: Sat, 1 Aug 2009 13:49:11 +0100
Im working on the pure darwin system and am trying to get audio
working. As the open-source Apple components include all kernel
components but not userspace (CoreAudio), I'm attempting to write an
application which reads audio from an input device and saves it into a
file.
Unfortunately I'm having problems - at least in part related to the
lack of documentation; writing a kernel driver is documented as is
CoreAudio but not the userspace/kernelspace interface.
So far I've figured out the following; please correct me If I'm wrong:
* I can access the IOAudioEngineStatus for a IOAudioEngine (via the
IOAudioEngineUserClient) by calling IOConnectMapMemory with
kIOAudioStatusBuffer.
Q. Is there a mechanism to tell me when its safe to use this data, or
is it, as I suspect, volatile and you use it "as it".
* IOConnectMapMemory with kIOAudioBytesInInputBuffer or
kIOAudioBytesInOutputBuffer do nothing. Tracing through the kernel
code it appears to returns a valid buffer but nothign ever writes into
it (this matches with what I've seen).
* To get the data for a stream I call IOConnectCallMethod with
kIOAudioEngineCallRegisterClientBuffer, supplying a userspace buffer,
an arbitrary bufferSetID and a streamID. This is of type
IOAudioBufferDataDescriptor (+ lots of buffer space).
* Calling IOConnectCallMethod with kIOAudioEngineCallStart/
kIOAudioEngineCallStop starts/stops the engine (respectively)
So based on this and the fact that input is simpler than output
(according to the audio kernel documentation) I'm trying to record.
So I'm creating a buffer, registering it, starting the engine, setting
the fActualNumSampleFrames member of my buffer to 256 and then calling
IOConnectTrap6 with kIOAudioEngineTrapPerformClientIO. This appears
to give me data but just not intelligible stuff.
I was expecting IOConnectTrap6 with kIOAudioEngineTrapPerformClientIO
to block for ~0.005 seconds (time taken to read 256 sample frames) but
it doesn't.
Q. My key question is how do I get intelligible audio from the
driver? I've tried putting a sleep in, but to no avail.
Also I was expecting that if I called IOConnectTrap6 with
kIOAudioEngineTrapPerformClientIO repeatedly but incremented
firstSampleFrame by 256 each time I'd see the driver write data into
the first 2048 bytes of fData, the first time, then the next 2048
bytes etc etc i.e. start writing into the fData buffer at
firstSampleFrame's * sizeof( float ) * numchannels in ... again it
doesn't and appears to simply overwite the first 2048 bytes of fData.
I've tried many things but still can't get it to work so any help or
pointers you can provide will be greatfully recieved.
Please help
Rich
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden