If you want your device to be able to receive some kind of data that is non-standard, then you have to set your driver up properly to do that. This means that you need to make sure that the format of your streams is all set correctly and is using a unique format ID. If this data can't be mixed, you'll also need to be sure set the non-mixable flag in the format.
Once your device is advertising that it accepts a custom format, it is up to you to write the code to shovel the data to the device as I don't believe that we have any sample code that shows how to send non-linear PCM data to a device.
Basically, the key thing to keep in mind is that IOAudio/HAL only support constant bit rate formats. This means that all the packets of data have to be the same size. Further, the HAL will only do IO in single packet buffers. This means that each call to the IOProc is expected to produce exactly one packet of the non-linear PCM formated data.
This is just the overview of what's involved. I'm sure as you dig into the problem you'll have more questions, so feel free to ask.
On Jan 5, 2009, at 3:12 AM, David Tan wrote: Now I’m working on an applet which can transmit customized samples data to my KEXT audio driver. I found useful source code from AudioFileTools provided at /Developer/Examples/CoreAudio/Services/AudioFileTools. It seems that “afplay” is similar to what I expect. After examining the source code, I thought I can replace the actual audio data from audio file with my customized data at CAAudioFilePlayer::InputProc(). There’s a parameter “AudioBufferList* ioData” of this callback function. As I understood, actual audio data will be filled into ioData and then CAAudioFilePlayer will transfer them to KEXT audio driver via CoreAudio. However, after I implemented the replacement, I cannot hear anything from the headphone. So I put a breakpoint at IOAudioEngine::clipOutputSample() in my kernel-driver, and found that the samples in mixbuf are always zero. That means I cannot get customized audio data from my applet. Is there anything I misunderstood or missed? Any advice and suggestion will be much appreciated. Thanks a lot!
--
Jeff Moore Core Audio Apple
|