From 44f1e81b2a7513b87673716abcc0b24bd7ae697e Mon Sep 17 00:00:00 2001 From: Raphael Avocegamou Date: Thu, 3 Sep 2026 10:38:09 +0200 Subject: [PATCH] fix: keep route depth within queue capacity --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- RELEASE_NOTES.md | 10 ++++++++ docs/getting-started/rust-quickstart.md | 2 +- src/runtime/audio/router.rs | 31 ++++++++++++++++++++----- 6 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 332b9ca..6e98379 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1015,7 +1015,7 @@ dependencies = [ [[package]] name = "pocketstation" -version = "1.1.6" +version = "1.1.7" dependencies = [ "alsa", "assert_no_alloc", diff --git a/Cargo.toml b/Cargo.toml index ad2b96d..692d24f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pocketstation" -version = "1.1.6" +version = "1.1.7" edition = "2021" rust-version = "1.95.0" license = "MIT OR Apache-2.0" diff --git a/README.md b/README.md index 65d2674..657fd0a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ application PCM ─────┘ ├─ Endpoint or Con You need Rust 1.95 or newer. Native capture is enabled by default. ```bash -cargo add pocketstation@1.1.6 +cargo add pocketstation@1.1.7 ``` Capture any running application with the same API on macOS, Windows, and Linux: @@ -57,7 +57,7 @@ For tooling that only inspects PocketStation types or builds documentation, disable native capture: ```toml -pocketstation = { version = "1.1.6", default-features = false } +pocketstation = { version = "1.1.7", default-features = false } ``` ## Choose a task diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ba286b2..879051e 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,6 +4,16 @@ This page covers user-visible changes in the PocketStation 1.x release line. ## Unreleased +## 1.1.7 — 2026-09-03 + +Route metrics no longer report a queue depth above the route's configured +capacity when producer and consumer counters are sampled concurrently. Audio +delivery and queue storage are unchanged. + +```console +cargo update -p pocketstation --precise 1.1.7 +``` + ## 1.1.6 — 2026-09-03 Configure route delivery with one consistent set of names. diff --git a/docs/getting-started/rust-quickstart.md b/docs/getting-started/rust-quickstart.md index 75f764a..082060f 100644 --- a/docs/getting-started/rust-quickstart.md +++ b/docs/getting-started/rust-quickstart.md @@ -23,7 +23,7 @@ Native build requirements: ## Add PocketStation ```bash -cargo add pocketstation@1.1.6 +cargo add pocketstation@1.1.7 ``` ## Capture in three lines diff --git a/src/runtime/audio/router.rs b/src/runtime/audio/router.rs index 002c49f..339c000 100644 --- a/src/runtime/audio/router.rs +++ b/src/runtime/audio/router.rs @@ -294,12 +294,15 @@ impl EdgeTelemetry { } fn queue_depth_frames(&self) -> u64 { - self.enqueued_total.load(Ordering::Relaxed).saturating_sub( - self.delivered_total - .load(Ordering::Relaxed) - .saturating_add(self.shutdown_discarded_total.load(Ordering::Relaxed)) - .saturating_add(self.discarded_output_frames_total.load(Ordering::Relaxed)), - ) + self.enqueued_total + .load(Ordering::Relaxed) + .saturating_sub( + self.delivered_total + .load(Ordering::Relaxed) + .saturating_add(self.shutdown_discarded_total.load(Ordering::Relaxed)) + .saturating_add(self.discarded_output_frames_total.load(Ordering::Relaxed)), + ) + .min(self.queue_capacity_frames) } fn observe_output_discard(&self) { @@ -1529,6 +1532,22 @@ mod tests { assert_eq!(snapshot.overruns_total, 1); } + #[test] + fn given_delivery_counter_lag_when_queue_depth_is_sampled_then_capacity_is_the_maximum() { + // Given + let telemetry = EdgeTelemetry::new(8); + telemetry.enqueued_total.store(9, Ordering::Relaxed); + + // When + telemetry.observe_enqueue(); + let snapshot = telemetry.snapshot(); + + // Then + assert_eq!(snapshot.queue_capacity_frames, 8); + assert_eq!(snapshot.queue_depth_frames, 8); + assert_eq!(snapshot.queue_peak_frames, 8); + } + #[test] fn given_observation_handle_when_consumer_detects_gap_then_live_discontinuity_is_visible() { // Given