highfidelity/hifi — pull request #3281 by wangyix (2014-08-13 23:55:28+00:00)
Title: more knobs added for InboundAudioStream; readPendingDatagrams stats added for AudioMixer; repetition-with-fade option added for InboundAudioStream

readPendingDatagrams stats added for AudioMixer:

AudioMixer now times each call of readPendingDatagrams(), the number of datagrams read per call, and time each call of packetVersionAndHashMatch inside that call. Stats include avgs for moving windows of size 30s and 1s. These stats are printed out by the AudioMixer (if stats printing is enabled in the domain settings), as well as sent to the domain page.

More knobs for InboundAudioStream:

Two moving windows are now used in InboundAudioStream (sizes of both are adjustable):

Window A: when a threshold number of starves occur in this window (the threshold being adjustable), _desiredJitterBufferFrames will be updated to the calculated value from the timegaps in this window (if the calculated value happens to be lower, _desiredJitterBufferFrames will not be updated). To avoid future starves at the cost of added latency, make this window longer.

Window B: the _desiredJitterBufferFrames will not be allowed to go over the calculated value from the timegaps of this window. If the length of this window is N seconds, then basically every time we receive a packet, we look back N seconds and see if any timegaps were large enough to justify the current _desiredJitterBufferFrames value. If not, _desiredJitterBufferFrames is lowered to match the max timegap from the last N seconds. (NOTE: this is the behavior if Fred's method is being used. In phil's stdev method, the window is always 500 timegaps and stdev of the timegaps is used instead of the max timegap).

Repetition with Fade:

For dropped audio packets or when audio streams are starved, silence is inserted. If Repetition with Fade is enabled (in the domain settings page and the interface pref dialog), the last valid audio frame will be repeated instead of inserting silence. If that frame needs to be repeated many times, it will slowly fade to silence. This should provide better perceived audio quality when starves/drops are occurring.