guacamole-spice-protocol/src
Michael Jumper 189d8fab30 GUACAMOLE-1201: Throttle outbound audio data to avoid overflowing RDP server audio input buffer.
The RDP specification for the AUDIO_INPUT channel requires that all
audio be sent in packets of a specific size. Guacamole does correctly
limit itself to sending packets of this size to the RDP server, but will
send quite a few of these packets all at once if it has received more
audio data than the RDP packet size. This is OK in principle (the
Guacamole client should be able to send audio in packets of whatever
size it chooses), but may overwhelm the software running within the RDP
server if the amount of data received exceeds the available buffer
space, resulting in dropped samples.

As there is no way to know the size of the remote audio buffer, we need
to instead ensure that audio is streamed as close to real time as
possible, with each audio packet of N bytes not being sent until roughly
the amount of time represented by those N bytes has elapsed since the
last packet. This throttling ensures that software expecting to process
audio in real time should never run out of buffer space.

That said, if we never exceed the per-packet data rate and occasionally
send a packet earlier than real time would dictate, unavoidable latency
in sending/receiving audio data would accumulate over time. For example,
if each audio packet represents 10ms of audio data, but we receive that
audio packet 10.1ms after the previous packet, we need to adjust the
timing of the next audio packet(s) to account for that additional 0.1ms.
Simply waiting 10ms after sending each packet would cause that 0.1ms to
accumulate each time it occurs, eventually resulting in noticable
latency and finally running out of buffer space.

Thus, these changes:

1. Leverage a flush thread and per-packet scheduling to ensure that each
   flushed audio packet does not exceed the equivalent real time rate.
2. Calculate the amount of additional latency from the amount of data
   received beyond the required packet size, and amortize scheduling
   corrections to account for that latency over the next several audio
   packets.

This ensures that audio is streamed exactly as it is received if the
audio matches the packet size of the RDP server, and audio that is
received in a different size or varying sizes is buffered and throttled
to keep things within the expectations of software running within the
RDP server.
2021-05-01 16:23:32 -07:00
..
common GUACAMOLE-1302: Add surface/display level support for forcing lossless compression. 2021-03-03 19:29:14 -08:00
common-ssh GUACAMOLE-1133: initialize GCrypt in VNC protocol prior to client start-up. 2021-01-21 21:14:18 -05:00
guacd Merge 1.3.0 changes back to master. 2020-12-22 19:05:16 -05:00
guacd-docker GUACAMOLE-928: Keep all build artifacts of Docker image within /usr/local/guacamole, including FreeRDP plugins. 2020-01-17 16:15:31 -08:00
guacenc GUACAMOLE-465: Correct printf-style format string (should be "%s" for strings, not "%d"). 2020-06-24 17:14:25 -07:00
guaclog GUACAMOLE-353: Clarify applicability of ASF header when transcluded into generated build files. 2018-10-02 20:37:49 -07:00
libguac GUACAMOLE-1204: Merge addition of server-side support for multi-touch events. 2021-02-11 20:53:22 -08:00
protocols GUACAMOLE-1201: Throttle outbound audio data to avoid overflowing RDP server audio input buffer. 2021-05-01 16:23:32 -07:00
pulse GUACAMOLE-353: Clarify applicability of ASF header when transcluded into generated build files. 2018-10-02 20:37:49 -07:00
terminal GUACAMOLE-1302: Always use lossless compression for text-based protocols leveraging the terminal. 2021-03-03 19:29:14 -08:00