highfidelity/hifi — pull request #3216 by wangyix (2014-07-26 01:09:11+00:00)
Title: Audio ringbuffer classes refactored into subclasses of InboundAudioStream

Issue: PositionalAudioRingBuffer contained code that had nothing to do with ring buffers, including packet timegap stats, starving behavior, and inserting samples for dropped packets. There needed to be a class that handled these behaviors and could be used on the server and client sides.

Fix: The InboundAudioStream class was created: it contains a ringbuffer and all the code for starving, refilling, calculating desired jitter buffer frames, and adding samples for dropped packets. It does not, however, have code for dropping silent packets. That behavior is implemented in its applicable subclasses (specifically, AvatarAudioRingBuffer).

AudioMixer changes: PositionalAudioRingBuffer is now a subclass of InboundAudioStream. Positional-, Avatar-, and Injected-AudioRingBuffer classes should all be renamed to ....AudioStream. Also, AudioRingBuffer is no longer a NodeData subclass since packet parsing code belong in the AudioStream classes.

Client changes: InboundMixedAudioStream replaced the MixedAudioRingBuffer member for handling downstream audio packets. Now both server and client have the same desired jitter frames calculation, which is Freddy's method of taking the max time gap in the last 5000 frames (replacing the stddev calculation). However, since silent frames aren't dropped on the client side yet (see next paragraph), the calculated desired jitter frames doesn't affect anything except the displayed audio stats.

The one thing still different between server and client is that the client does not drop silent frames since there is no silent packet type for downstream mixed audio. I think the current PacketTypeSilentFrame should have its positional members removed so that it's generalized for use anywhere.

Test: audiomixer and interface were run with an agent running dancer.js to ensure mixing behavior is still the same.