Sending audio
=============

When TAudioIn starts it continually calls AudioInBufferFilled in Unit1.pas with the bytes read from the microphone.  
This immediately calls senderThread.processBytesFromMicrophone which copies the bytes into rawSendBuffer, then exits.
The main thread senderThread loops constantly, and whenever rawSendBuffer has some bytes it encrypts these and writes them on the socket.



Receiving audio
===============
When the receiving audio socket receives some bytes it immediately calls receiverThread.handleReceivedBuffer
which copies the bytes into rawReceiveBuffer, then exits.
The main thread receiverThread loops constantly, and whenever rawReceiveBuffer has some bytes it decrypts these and copies them
into audioOutputBuffer.
TAudioOut continually calls AudioOutFillBuffer in Unit1.pas when it needs some bytes to play out through the speaker.  
This immediately calls receiverThread.getBytesForSpeaker which fills the TAudioOut's buffer with decrypted bytes from audioOutputBuffer.



Notes
=====

Whenever a block of bytes are copied to a buffer, a check is made to make sure that there is sufficient space to copy the new bytes.
If there isn't enough space the process waits until there is sufficient space.
Also, whenever a process wants to read some bytes from a buffer it will make sure some new bytes are available and will wait until this is the case.
This is done by having a "readpos", "writepos" and "bytes available" variable for each buffer.  The writepos indicates the position the next byte
should be written to, and bytes available is increased when a new byte is written.  
The readpos indicates where the next byte should be read from, but only if bytes available is greater than zero.

Be very careful changing the buffer sizes.  The program works best if TAudioIn and TAudioOut have the same buffer size, and when this is the same size as the cryptobuffers used in the 2 threads.
In theory these values can be different but it will be far harder to debug the program if this is the case.

Questions: email wuul39@googlemail.com
