highfidelity/hifi — pull request #3135 by wangyix (2014-07-08 18:26:02+00:00)
Title: changed Audio.cpp to not overflow _audioOutput buffer; fixed premature injector stream deletion; disabled silent-frame dropping in non-dyanimic-jitter-buffers mode

Issue 1: local AudioMixer echoing test tone will click intensely every 10 seconds or so

Fix: QAudioOutput's internal buffer was not being checked for room before downstream audio was written to it, sometimes causing a write to not occur due to no room, which leads to lost audio. An _audioOutput->bytesFree() check was added to prevent writing too many samples. Also, the ring buffer for downstream audio was not big enough and was regularly overflowed, so its size was increased from 10 to 100.

Test: local audiomixer test tone clicking has mostly disappeared.

Issue 2: injected audio streams in AudioMixer were being deleted prematurely, which means their SequenceNumberStats would be deleted (and later recreated when the next audio frame for that stream came in).

Fix: _consecutiveNotMixedCount was added to PositionalAudioRingBuffer to keep track of how many times in a row a stream would not be mixed. Now, an injected stream (and its seq num stats) will only be deleted if it has not been mixed for 100 times in a row.

Test: injected streams are still being removed, but a little later now.

Issue 3: silent frame dropping was enabled even when dynamic jitter buffers weren't in the AudioMixer.

Fix: an extra check was added so silent frames are only dropped when _dynamicJitterBuffers is true.

Test: not tested.