From 55ef0f4d3273793b86fede6d99d4fffcb06a7085 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Mon, 27 Apr 2026 02:56:07 -0300 Subject: [PATCH] tune(sync): add hdmi audio holdback default --- Cargo.lock | 6 +++--- client/Cargo.toml | 2 +- common/Cargo.toml | 2 +- docs/operational-env.md | 2 +- scripts/install/server.sh | 2 +- server/Cargo.toml | 2 +- server/src/audio/voice_input.rs | 11 ++++++----- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f4af52..45a490d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1642,7 +1642,7 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "lesavka_client" -version = "0.14.12" +version = "0.14.13" dependencies = [ "anyhow", "async-stream", @@ -1676,7 +1676,7 @@ dependencies = [ [[package]] name = "lesavka_common" -version = "0.14.12" +version = "0.14.13" dependencies = [ "anyhow", "base64", @@ -1688,7 +1688,7 @@ dependencies = [ [[package]] name = "lesavka_server" -version = "0.14.12" +version = "0.14.13" dependencies = [ "anyhow", "base64", diff --git a/client/Cargo.toml b/client/Cargo.toml index ae70c4a..eaa8e68 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -4,7 +4,7 @@ path = "src/main.rs" [package] name = "lesavka_client" -version = "0.14.12" +version = "0.14.13" edition = "2024" [dependencies] diff --git a/common/Cargo.toml b/common/Cargo.toml index 01fad29..69dbc37 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lesavka_common" -version = "0.14.12" +version = "0.14.13" edition = "2024" build = "build.rs" diff --git a/docs/operational-env.md b/docs/operational-env.md index f100589..fce9896 100644 --- a/docs/operational-env.md +++ b/docs/operational-env.md @@ -185,7 +185,7 @@ Hardware-facing assumptions belong near the code that uses them; this file is th | `LESAVKA_UAC_BUFFER_TIME_US` | server audio sink latency override | | `LESAVKA_UAC_COMPENSATION_US` | server audio sink latency override | | `LESAVKA_UAC_DEV` | server hardware/device override | -| `LESAVKA_UAC_HDMI_COMPENSATION_US` | server HDMI audio sink latency override | +| `LESAVKA_UAC_HDMI_COMPENSATION_US` | server HDMI audio sink latency override; defaults to `205000` to hold gadget audio back toward the host-observed HDMI video path | | `LESAVKA_UAC_LATENCY_TIME_US` | server audio sink latency override | | `LESAVKA_UAC_SESSION_CLOCK_ALIGN` | server audio sink clock-alignment override; defaults to `0` | | `LESAVKA_TEST_CAM_U32` | test/build contract variable; not runtime operator config | diff --git a/scripts/install/server.sh b/scripts/install/server.sh index caf7c15..6bfac21 100755 --- a/scripts/install/server.sh +++ b/scripts/install/server.sh @@ -492,7 +492,7 @@ fi printf 'LESAVKA_HDMI_PRESENTATION_DELAY_US=%s\n' "${LESAVKA_HDMI_PRESENTATION_DELAY_US:-180000}" printf 'LESAVKA_UAC_DEV=%s\n' "${LESAVKA_UAC_DEV:-hw:UAC2Gadget,0}" printf 'LESAVKA_ALSA_DEV=%s\n' "${LESAVKA_ALSA_DEV:-hw:UAC2Gadget,0}" - printf 'LESAVKA_UAC_HDMI_COMPENSATION_US=%s\n' "${LESAVKA_UAC_HDMI_COMPENSATION_US:-0}" + printf 'LESAVKA_UAC_HDMI_COMPENSATION_US=%s\n' "${LESAVKA_UAC_HDMI_COMPENSATION_US:-205000}" printf 'LESAVKA_UAC_SESSION_CLOCK_ALIGN=%s\n' "${LESAVKA_UAC_SESSION_CLOCK_ALIGN:-0}" printf 'LESAVKA_UPSTREAM_PLAYOUT_DELAY_MS=%s\n' "${LESAVKA_UPSTREAM_PLAYOUT_DELAY_MS:-1000}" printf 'LESAVKA_UPSTREAM_AUDIO_PLAYOUT_OFFSET_US=%s\n' "${LESAVKA_UPSTREAM_AUDIO_PLAYOUT_OFFSET_US:-0}" diff --git a/server/Cargo.toml b/server/Cargo.toml index ef7e516..1df0b19 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -10,7 +10,7 @@ bench = false [package] name = "lesavka_server" -version = "0.14.12" +version = "0.14.13" edition = "2024" autobins = false diff --git a/server/src/audio/voice_input.rs b/server/src/audio/voice_input.rs index 8c02aeb..62e3392 100644 --- a/server/src/audio/voice_input.rs +++ b/server/src/audio/voice_input.rs @@ -86,9 +86,10 @@ fn voice_sink_compensation_us() -> i64 { fn default_voice_sink_compensation_us() -> i64 { let cfg = crate::camera::current_camera_config(); if cfg.output == crate::camera::CameraOutput::Hdmi { - // HDMI now prefers MJPEG on hosts without hardware H.264 decode, which - // removed the old video-side lag that justified the large audio pad. - non_negative_voice_sink_timing_env("LESAVKA_UAC_HDMI_COMPENSATION_US", 0) + // Bench captures on the real HDMI/UAC host path still show gadget audio + // arriving about 205 ms ahead of the HDMI camera feed once the shared + // upstream playout is stable, so keep a modest default audio holdback. + non_negative_voice_sink_timing_env("LESAVKA_UAC_HDMI_COMPENSATION_US", 205_000) } else { 0 } @@ -413,8 +414,8 @@ mod voice_sink_timing_tests { temp_env::with_var_unset("LESAVKA_UAC_HDMI_COMPENSATION_US", || { temp_env::with_var("LESAVKA_CAM_OUTPUT", Some("hdmi"), || { update_camera_config(); - assert_eq!(default_voice_sink_compensation_us(), 0); - assert_eq!(voice_sink_compensation_us(), 0); + assert_eq!(default_voice_sink_compensation_us(), 205_000); + assert_eq!(voice_sink_compensation_us(), 205_000); }); }); });