highfidelity/hifi — pull request #3254 by wangyix (2014-08-05 01:16:08+00:00)
Title: Audio output switched to pull mode

Issue: QAudioOutput was being used in push mode for audio playback on the client. In this mode, audio samples had to be pushed to the audio output regularly.

Fix: QAudioOutput has been switched over to pull mode, in which we simply provide a readData() function in a QIODevice subclass. Also, the code for resampling and spatial audio stuff has been moved so that they're executed as soon as a packet is parsed as opposed to when a frame is pushed to the audio output. This reduces processing time inside the readData() callback. This change allows the QAudioOutput buffer to be reduced to only 3 frames (down from 8), which should reduce overall audio latency by ~50ms.

Test: echoed test tone and ran dancer.js on an agent to ensure mixing still worked. Confirmed the reduced output buffer size produced good audio.