Protect SoundTouch lookahead when catching up live stream audio

This commit is contained in:
evgeny committed 2026-10-21 01:38:50 +02:00
1 parent 5d9da0c6b1
commit fcb0768052
3 files changed
+4 -1

No files matched your search

@@ -335,6 +335,7 @@ void StreamPlayerWindow::decode() {
bool starved = p.underruns != observedGaps; observedGaps = p.underruns;
if (!p.activeAudio && p.position + (now - p.clockAt) * p.adaptation.tempo_milli / 1000 > p.ready) starved = true;
int64_t guardUs = p.activeAudio ? std::max<int64_t>(40000, p.deviceLead + 20000) : p.framePeriod;
if (p.sound) guardUs += stream_playback_audio_latency_us(p.sound);
int64_t pending = p.sound ? stream_playback_audio_pending_gain(p.sound, played) : 0;
if (stream_playback_clock_update(&p.adaptation, now, std::max(p.position, position), p.ready,
guardUs, pending, !p.ended && starved, &p.timing) < 0) p.resync = true;