diff --git a/src/call/call_jitter.cpp b/src/call/call_jitter.cpp index 9b7da245..a4908e07 100644 --- a/src/call/call_jitter.cpp +++ b/src/call/call_jitter.cpp @@ -226,6 +226,12 @@ void call_jitter_clock(struct call_jitter* j, int64_t now_us, struct call_clock_ *out = j->timeline.clock(now_us); } +int call_jitter_try_clock(struct call_jitter* j, int64_t now_us, struct call_clock_snapshot* out) { + std::unique_lock lock(j->mtx, std::try_to_lock); + if (!lock.owns_lock()) return 0; + *out = j->timeline.clock(now_us); return 1; +} + void call_jitter_reset(struct call_jitter* j) { if (!j) return; std::lock_guard lock(j->mtx); diff --git a/src/call/call_jitter.h b/src/call/call_jitter.h index 8e494a87..5a7f81b8 100644 --- a/src/call/call_jitter.h +++ b/src/call/call_jitter.h @@ -46,6 +46,8 @@ void call_jitter_progress(struct call_jitter* j, uint64_t epoch, uint64_t positi void call_jitter_suspend_device(struct call_jitter* j, uint64_t epoch); /* Любой поток: снимок часов, включая epoch при valid=0. */ void call_jitter_clock(struct call_jitter* j, int64_t now_us, struct call_clock_snapshot* out); +/* Неблокирующее чтение: 1 — снимок получен, 0 — mutex занят. Аргументы должны быть валидны. */ +int call_jitter_try_clock(struct call_jitter* j, int64_t now_us, struct call_clock_snapshot* out); void call_jitter_get_stats(struct call_jitter* j, int* depth_ms, int* tempo_x100, uint32_t* dropped, uint32_t* underruns, struct call_jitter_range* range);