Keep viewer snapshots scoped and normalize Opus packet cadence

This commit is contained in:
evgeny committed 2026-10-13 22:45:07 +02:00
1 parent 650b65078a
commit 8d317dbb85
2 files changed
+9 -6

No files matched your search

+6 -3
View File
@@ -88,7 +88,9 @@ struct stream_playback_audio* stream_playback_audio_create(int64_t start) {
auto* a = new (memory) stream_playback_audio;
a->startPts = start; a->lastPts = (double)start;
a->opus = opus_codec_decoder_create(rate, 2);
if (!a->opus) { stream_playback_audio_destroy(a); return nullptr; }
if (!a->opus) {
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "playback audio Opus initialization failed"); stream_playback_audio_destroy(a); return nullptr;
}
a->stretch.setSampleRate(rate); a->stretch.setChannels(2); a->stretch.setTempo(1.0);
a->stretch.setSetting(SETTING_USE_QUICKSEEK, 1);
a->stretch.setSetting(SETTING_SEQUENCE_MS, 20); a->stretch.setSetting(SETTING_SEEKWINDOW_MS, 10);
@@ -117,9 +119,10 @@ int stream_playback_audio_feed(struct stream_playback_audio* a, int64_t pts, con
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "playback audio discontinuity pts=%lld expected=%lld missing=%d",
(long long)pts, (long long)a->expectedPts, missing); return -2;
}
int64_t effectivePts = a->expectedPts < 0 ? pts : a->expectedPts + missing * 20000;
for (int i = 0; i < missing; i++) if (feedPcm(a, a->expectedPts + i * 20000, nullptr, 0) < 0) return -1;
if (feedPcm(a, pts, packet, (int)length) < 0) return -1;
a->expectedPts = pts + 20000;
if (feedPcm(a, effectivePts, packet, (int)length) < 0) return -1;
a->expectedPts = effectivePts + 20000;
return 0;
}