These comments have been added to clean up the code and make it more
clear of what the code is doing. The code felt a bit messy, and this
should help prevent the original author of the noise suppression filter
from being lost in case he decides to modify/improve the filter.
When buffering audio data, we don't want to buffer audio data that may
be old. If the audio timing jumps significant and old audio data is
buffered, clear that old data.
The noise suppression filter mistakenly operated on the assumption that
input audio data would always be in 10ms segments, and would crash if
audio data was larger than that size.
Because speexdsp operates on fixed audio frame sizes only, we must
buffer audio data to fit that frame processing size. This creates a
troublesome situation where you must buffer around that specified frame
size.
The new steps for processing are:
1. Push audio data to input circular buffer.
2. Push number of audio frames and timestamp for that audio packet to an
'info' circular buffer.
3. Check size of input circular buffer, and while it's equal to or above
the speexdsp frame size (10ms for minimum latency), pop from the
input buffer to a temporary buffer (10ms frames) and process it, then
push that temporary buffer to the output circular buffer.
4. Peek at the front of the 'info' circular buffer.
5. If the output circular buffer frame size is equal or larger than next
expected number of frames, pop both the info and output buffer, and
return the audio data with the expected audio frames/timestamp.