+ /* read tones */
+ length = read_audio(buffer, elapsed);
+
+ /*
+ * get data from up
+ * the fromup_buffer data is written to the beginning of the buffer
+ * the part that is filles with tones (length) is skipped, so tones have priority
+ * the length value is increased by the number of data copied from fromup_buffer
+ */
+ if (inbuffer)
+ {
+ /* inbuffer might be less than we skip due to audio */
+ if (inbuffer <= length)
+ {
+ /* clear buffer */
+ p_fromup_buffer_readp = p_fromup_buffer_writep;
+ inbuffer = 0;
+ } else
+ {
+ /* skip what we already have with tones */
+ p_fromup_buffer_readp = (p_fromup_buffer_readp + length) & FROMUP_BUFFER_MASK;
+ inbuffer -= length;
+ }
+ /* if we have more in buffer, than we send this time */
+ if (inbuffer > (elapsed-length))
+ inbuffer = elapsed - length;
+ /* set length to what we actually have */
+ length = length + inbuffer;
+ /* now fill up with fromup_buffer */
+ while (inbuffer)
+ {
+ *p++ = p_fromup_buffer[p_fromup_buffer_readp];
+ p_fromup_buffer_readp = (p_fromup_buffer_readp + 1) & FROMUP_BUFFER_MASK;
+ inbuffer--;
+ }
+ }
+
+ /* overwrite buffer with crypto stuff */