From 9f7962a6cd7dc830bab33ebc5cb0fb86e8d56508 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Tue, 7 Apr 2026 05:26:59 +0400 Subject: [PATCH] fix: vec allocation for desktop AudioRing (match Android fix) Same fix as Android: Box::new([0i16; 16384]) allocates 32KB on the stack before moving to heap. Use vec![].into_boxed_slice() for direct heap allocation. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/wzp-client/src/audio_ring.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wzp-client/src/audio_ring.rs b/crates/wzp-client/src/audio_ring.rs index e6eeae0..8c30232 100644 --- a/crates/wzp-client/src/audio_ring.rs +++ b/crates/wzp-client/src/audio_ring.rs @@ -18,7 +18,7 @@ const RING_MASK: usize = RING_CAPACITY - 1; /// Lock-free single-producer single-consumer ring buffer for i16 PCM samples. pub struct AudioRing { - buf: Box<[i16; RING_CAPACITY]>, + buf: Box<[i16]>, /// Monotonically increasing write cursor. ONLY written by producer. write_pos: AtomicUsize, /// Monotonically increasing read cursor. ONLY written by consumer. @@ -40,7 +40,7 @@ impl AudioRing { pub fn new() -> Self { debug_assert!(RING_CAPACITY.is_power_of_two()); Self { - buf: Box::new([0i16; RING_CAPACITY]), + buf: vec![0i16; RING_CAPACITY].into_boxed_slice(), write_pos: AtomicUsize::new(0), read_pos: AtomicUsize::new(0), overflow_count: AtomicU64::new(0),