Re: In need of documentation 2
Re: In need of documentation 2
- Subject: Re: In need of documentation 2
- From: <email@hidden>
- Date: Thu, 17 Jan 2002 11:36:10 +0100
>
Thanks !
>
>
ok, I took a look at the source code for PlayThru :
>
>
What I understand (please tell me if i am wrong or missed anything) all
>
you need is :
>
catch get the data written the input and pass it to the ouput.
Yep... that's how it's done :-)
>
To do this you need to define the input and output :
>
AudioHardwareGetProperty(...); which gives you a pointer to both of
>
them.
With AudioHardwareGetProperty you can get all kinds of properties for the
audio hardware, like for instance the AudioDeviceIDs for the default input
& output devices.
Once you got the AudioDeviceIDs for your devices, you install an IOProc
for each of them using AudioDeviceAddIOProc, and start them by calling
AudioDeviceStart.
>
then there are two methods that (I guess) the OS calls :
The IOProcs will be called by CoreAudio in a high priority thread.
>
- InputIOProc
>
Where you get the data written to the input buffer and put it in
>
your own Queue.
>
- OutputIOProc
>
Where you "BlitThisData". Here you "send" the data which is in
>
your own Queue.
>
This seems to be the "big deal" of this program : (here I need
>
explications)
>
i.e. you process the data found in your queue to be playable and
>
send it to the output.
>
But I don't understand AT ALL what is being done in this function.
As the name implies, "BlitThisData" just copies the samples from one
AudioBufferList to another. The reason why BlitThisData looks so
complex, is that it can copy the data between 2 differently structured
AudioBufferLists:
Say for instance your input & output device both have a total 2 audio
channels. For some devices, the AudioBufferList would have 1
AudioBuffer with 2 channels, and for other devices it would have 2
AudioBuffers with 1 channel for each AudioBuffer. (someone correct me if
I'm wrong)
If you're sure the AudioBufferLists are structured the same way (equal
number of buffers, and for each corresponding buffer, equal
mDataByteSize and mNumberChannels), you can just go ahead and use
memcpy(outBufferList.mBuffers[i].mData, inBufferList.mBuffers[i].mData,
outBufferList.mBuffers[i].mDataByteSize); for each buffer in the list.
>
Ok, this starts to make sense (I hope). Are there any other needed
>
operations I should know of ?
certainly take a look at CoreAudio/AudioHardware.h
There's a lot of information in there about how the HAL exactly works and
how you (should) use it
>
And please could you clarify what BlitThisData() does, expecially since
>
(French being my usual language) I have no idea what Blit means ! 8)
Ah... j'espere que c'est deja un peu plus clair :-)
I usually speak Dutch, so I dunno exactly what it means either (didn't find it
in the dictionary). Game developers also call their functions to copy pixels
into a video buffer a blitter so it must have something to do with copying
data to a destination buffer... anyone a better explanation?
--Lieven
-------------------------------------------------
Zeus Security / DSA Webmail: webmail.rug.ac.be