loopback: Calculate and track minimum possible latency
authorGeorg Chini <georg@chini.tk>
Fri, 7 Apr 2017 06:18:08 +0000 (08:18 +0200)
committerGeorg Chini <georg@chini.tk>
Fri, 7 Apr 2017 06:18:08 +0000 (08:18 +0200)
commitc936aa23c316ebf51eb2d7f44c88e6c8434a8da9
tree4da7c450d7958d213c35b55c224ab358e1d99dec
parentb667fb22e43d9403643fa1cfd7ebaecdf60a430d
loopback: Calculate and track minimum possible latency

With the current code, the user can request any end-to-end latency. Because there
is no protection against underruns, setting the latency too small will result in
repetitive underruns.

This patch tries to mitigate the problem by calculating the minimum possible latency
for the current combination of source and sink. The actual calculation has been put
in a separate function so it can easily be changed. To keep the values up to date,
changes in the latency ranges have to be tracked.

The calculated minimum latency is used to limit the configured latency.
The minimum latency is only a "best guess", so the actual minimum may be much
larger (for example for USB devices) or much smaller than the calculated value.

Changes of the port latency offsets are not yet handled, this will be done in a
separate patch.
src/modules/module-loopback.c