Limit rate adjustments to small, inaudible jumps
The same logic is applied to the sample rate adjustments in module-rtp-recv,
module-loopback and module-combine:
- Each time an adjustment is made, the new rate can differ at most 2‰ from the
old rate. Such a step is equal to 3.5 cents (a cent is 1/100th of a
semitone) and as 5 cents is generally considered the smallest observable
difference in pitch, this results in inaudible adjustments.
- The sample rate of the stream can only differ from the rate of the
corresponding sink by 25%. As these adjustments are meant to account for
very small clock drifts, any large deviation from the base rate suggests
something is seriously wrong.
- If the calculated rate is within 20Hz of the base rate, set it to the base
rate. This saves CPU because no resampling is necessary.