implementing an AudioIOFunction
implementing an AudioIOFunction
- Subject: implementing an AudioIOFunction
- From: Josh Rodatus <email@hidden>
- Date: Sat, 23 Dec 2006 19:50:36 -0500
Greetings,
I am writing a KEXT that taps system audio output by first locating the output IOAudioStream object in the registry, and then calling its setIOFunction() method to install a custom AudioIOFunction in the pipeline.
The typedef for an AudioIOFunction as declared in IOAudioStream.h is:
typedef IOReturn (*AudioIOFunction)(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream);
The problem is that installing my IO function prevents any output audio from reaching the device. All I can figure is that an AudioIOFunction is expected to copy a section of mixBuf into sampleBuf, or vice versa. Unfortunately my attempts copying the samples from one buffer to the other only result in distorted output audio.
Here's how I'm copying it:
IOReturn AudioIOProc(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream) {
{
void *samples = (float *)mixBuf + (firstSampleFrame * streamFormat->fNumChannels);
size_t size = numSampleFrames * sizeof(float) * streamFormat->fNumChannels;
bcopy(samples, sampleBuf, size);
return kIOReturnSuccess;
}
I tried Googling for source code and documentation, to no avail. If anyone could give some advice or instruction on how to properly implement an AudioIOFunction, I would be most grateful.
Thanks,
Josh
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden