[client] audio: fix latency calculation if audio device starts early

If the audio device starts earlier than required, we slew the read pointer
backwards to avoid underrunning. We need to apply this same offset to the
recorded device position, otherwise the Spice thread will think playback is
further ahead than it really is and inject unnecessary latency to
compensate.
This commit is contained in:
Chris Spencer 2022-02-21 11:03:29 +00:00 committed by Geoffrey McRae
parent a13c90bd27
commit 0dad9b1e76

View File

@ -227,7 +227,10 @@ static int playbackPullFrames(uint8_t * dst, int frames)
int offset = ringbuffer_getCount(audio.playback.buffer) - int offset = ringbuffer_getCount(audio.playback.buffer) -
audio.playback.deviceTargetStartFrames; audio.playback.deviceTargetStartFrames;
if (offset < 0) if (offset < 0)
{
data->nextPosition += offset;
ringbuffer_consume(audio.playback.buffer, NULL, offset); ringbuffer_consume(audio.playback.buffer, NULL, offset);
}
audio.playback.state = STREAM_STATE_RUN; audio.playback.state = STREAM_STATE_RUN;
} }