From 2ca2553086939dc3d749d43cad680b6ef7e746d2 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 10 Aug 2026 04:49:34 +1000 Subject: [PATCH] [client] audio: limit timing graph update rate Sample the playback ring graph at its original 40 Hz rate so its 1,200 entries continue to represent 30 seconds of history. Keep packet processing and asynchronous USB feedback at full rate. --- client/src/audio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/audio.c b/client/src/audio.c index 2f9e0985..2916c8f5 100644 --- a/client/src/audio.c +++ b/client/src/audio.c @@ -66,6 +66,7 @@ #define PLAYBACK_DEVICE_RATE_STABLE_DELTA_PPM 50.0 #define PLAYBACK_DEVICE_RATE_MAX_ACQUIRE_SEC 20.0 #define PLAYBACK_FEEDBACK_INTERVAL_NS INT64_C(1000000) +#define PLAYBACK_GRAPH_INTERVAL_NS INT64_C(25000000) typedef enum { @@ -173,6 +174,7 @@ typedef struct double lastRatio; double lastClockRatio; int64_t nextFeedbackTime; + int64_t nextGraphTime; int64_t nextLogTime; unsigned int bufferOverruns; @@ -1137,6 +1139,7 @@ static void playbackStart(const LG_AudioFormat * format, audio.playback.sourceData.lastRatio = 1.0; audio.playback.sourceData.lastClockRatio = 1.0; audio.playback.sourceData.nextFeedbackTime = 0; + audio.playback.sourceData.nextGraphTime = 0; audio.playback.sourceData.bufferOverrunPending = false; audio.playback.sourceData.bufferOverruns = 0; audio.playback.sourceData.nextLogTime = @@ -2018,8 +2021,9 @@ static void playbackData(const void * data, size_t frameCount, const double softwareLatencyMs = actualLatencyFrames * 1000.0 / audio.playback.sampleRate; - if (audio.playback.graph) + if (audio.playback.graph && now >= sourceData->nextGraphTime) { + sourceData->nextGraphTime = now + PLAYBACK_GRAPH_INTERVAL_NS; const float latency = softwareLatencyMs; ringbuffer_push(audio.playback.timings, &latency); app_invalidateGraph(audio.playback.graph);