[client] audio: tune target latency

The target latency is now based upon the device maximum period size
(which may be configured by setting the `PIPEWIRE_LATENCY` environment
variable if using PipeWire), with some allowance for timing jitter from
Spice and the audio device.

PipeWire can change the period size dynamically at any time which must be
taken into account when selecting the target latency to avoid underruns
when the period size is increased. This is explained in detail within the
commit body.
This commit is contained in:
Chris Spencer
2022-01-29 19:23:28 +00:00
committed by Geoffrey McRae
parent ca29fe80a6
commit e1e60fdaa6
4 changed files with 131 additions and 46 deletions

View File

@@ -47,7 +47,8 @@ struct LG_AudioDevOps
/* setup the stream for playback but don't start it yet
* Note: the pull function returns f32 samples
*/
void (*setup)(int channels, int sampleRate, LG_AudioPullFn pullFn);
void (*setup)(int channels, int sampleRate, int * maxPeriodFrames,
LG_AudioPullFn pullFn);
/* called when there is data available to start playback
* return true if playback should start */