highfidelity/hifi — pull request #3266 by wangyix (2014-08-08 18:50:07+00:00)
Title: InboundAudioStream new behavior and more knobs

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).