Suspend hardware clock during output replacement without resetting media

This commit is contained in:
evgeny committed 2026-10-15 14:36:03 +02:00
1 parent ede911e7e4
commit 0a56c01e29
3 files changed
+31 -2

No files matched your search

+10 -1
View File
@@ -143,10 +143,19 @@ void CallTimeline::progress(uint64_t deviceEpoch, uint64_t position, int64_t atU
while (output.count > 1 && output.front().first + output.front().count <= minimumPosition) output.pop();
}
/* Устройство меняется, но PCM/PTS, монотонная позиция и сетевой резерв сохраняются. */
void CallTimeline::suspend_device(uint64_t deviceEpoch) {
if (deviceEpoch != epoch) return;
anchorReceived = -1;
DEBUG_INFO(DEBUG_CATEGORY_CALL, "audio clock device suspended epoch=%llu position=%llu written=%llu",
(unsigned long long)epoch, (unsigned long long)anchorPosition, (unsigned long long)written);
}
call_clock_snapshot CallTimeline::clock(int64_t nowUs) {
call_clock_snapshot result{};
result.epoch = epoch; result.written_samples = written; result.pts_us = lastPts; result.measured = measured;
if (outputFailed || deviceFailed || !haveAnchor || !output.count || nowUs < anchorReceived || nowUs - anchorReceived > 250000) return result;
if (outputFailed || deviceFailed || !haveAnchor || !output.count || anchorReceived < 0 ||
nowUs < anchorReceived || nowUs - anchorReceived > 250000) return result;
uint64_t pending = anchorTime > nowUs ? (uint64_t)std::ceil((anchorTime - nowUs) / sampleUs) : 0;
uint64_t position = pending > anchorPosition ? 0 : anchorPosition - pending;
position = std::max(position, minimumPosition);
+1
View File
@@ -18,6 +18,7 @@ public:
void read(unsigned samples);
void silence(unsigned samples);
void progress(uint64_t epoch, uint64_t position, int64_t at_us, int64_t received_us, bool measured);
void suspend_device(uint64_t epoch);
call_clock_snapshot clock(int64_t now_us);
private:
struct Span {