[client] audio: increase startup latency

Underruns can still happen quite easily at the beginning of playback,
particularly at very low latency settings. Further increase the startup
latency to avoid this.
This commit is contained in:
Chris Spencer
2022-02-05 09:53:06 +00:00
committed by Geoffrey McRae
parent 5e1b8f2abe
commit 0d97a51802
4 changed files with 25 additions and 36 deletions

View File

@@ -612,9 +612,17 @@ void audio_playbackData(uint8_t * data, size_t size)
if (audio.playback.state == STREAM_STATE_SETUP)
{
frames = ringbuffer_getCount(audio.playback.buffer);
if (audio.audioDev->playback.start(frames))
// In the worst case, the audio device can immediately request two full
// buffers at the beginning of playback. Latency corrections at startup can
// also be quite significant due to poor packet pacing from Spice, so
// additionally require at least two full Spice periods' worth of data
// before starting playback to minimise the chances of underrunning
int startFrames =
spiceData->periodFrames * 2 + audio.playback.deviceMaxPeriodFrames * 2;
if (spiceData->nextPosition >= startFrames) {
audio.audioDev->playback.start();
audio.playback.state = STREAM_STATE_RUN;
}
}
double latencyFrames = actualOffset;