From ff054008c315108dff1766ff4a6f5ca82886e19a Mon Sep 17 00:00:00 2001 From: faumaray Date: Wed, 14 Oct 2026 18:09:21 +0300 Subject: [PATCH] Settle the small leftovers of the earlier reviews - jitter.rs: short_packet_fuzz takes payloads of 0..=100 bytes (was under 12) and 3000 iterations (was 500). - ui-review.md: the whisper row pointed at voelin-audio/src/encode.rs:90; the C2S-only packet is built by out_audio in voelin-core/src/voice.rs. - mixer.rs: the module doc's first paragraph is reflowed, and Mixer::set_priority names its parameter talkers, not clients. - stream.rs: api_types_convert_at_the_boundary asserts the remaining variants: every ViewerState, StreamKind (both ways) and LeaveReason (alone and inside EndReason::Removed). Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-audio/src/jitter.rs | 5 +++-- crates/voelin-audio/src/mixer.rs | 8 ++++---- crates/voelin-core/src/stream.rs | 33 +++++++++++++++++++++++++++++++ docs/research/ui-review.md | 2 +- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/crates/voelin-audio/src/jitter.rs b/crates/voelin-audio/src/jitter.rs index c2ca614..38afc1b 100644 --- a/crates/voelin-audio/src/jitter.rs +++ b/crates/voelin-audio/src/jitter.rs @@ -702,8 +702,9 @@ mod test { state }; - for _ in 0..500 { - let len = (next() % 12) as usize; + for _ in 0..3_000 { + // Payloads of 0..=100 bytes: empty, a lone TOC byte, and frames of any shape. + let len = (next() % 101) as usize; let payload: Vec = (0..len).map(|_| next() as u8).collect(); let _ = handler.handle_packet(packet(30, &payload)); diff --git a/crates/voelin-audio/src/mixer.rs b/crates/voelin-audio/src/mixer.rs index 073d131..5828615 100644 --- a/crates/voelin-audio/src/mixer.rs +++ b/crates/voelin-audio/src/mixer.rs @@ -2,8 +2,8 @@ //! volume and mute per talker, and everyone else dimmed while a priority //! speaker talks. //! -//! The jitter buffer is [`AudioHandler`]. Per -//! sender it keeps a queue of Opus packets and adapts its length: +//! The jitter buffer is [`AudioHandler`]. Per sender it keeps a queue of Opus +//! packets and adapts its length: //! //! - a new talker starts after a pre-buffer derived from the queue lengths of //! the other talkers (none for the first one); @@ -171,8 +171,8 @@ impl Mixer { /// one of them talks: dB, clamped to -60..=0 (NaN: not at all). /// Replaces the previous set; [`forget`](Self::forget) leaves it alone, /// the caller sends a new set when the talkers change. - pub fn set_priority(&mut self, clients: impl IntoIterator, dimm_db: f32) { - self.priority = clients.into_iter().collect(); + pub fn set_priority(&mut self, talkers: impl IntoIterator, dimm_db: f32) { + self.priority = talkers.into_iter().collect(); let db = if dimm_db.is_nan() { 0.0 } else { dimm_db.clamp(MAX_DIMM_DB, 0.0) }; self.dimm = 10f32.powf(db / 20.0); } diff --git a/crates/voelin-core/src/stream.rs b/crates/voelin-core/src/stream.rs index a864b52..7ba77a7 100644 --- a/crates/voelin-core/src/stream.rs +++ b/crates/voelin-core/src/stream.rs @@ -1510,6 +1510,39 @@ mod tests { assert!(media_codec(codec).name().eq_ignore_ascii_case(codec.sdp_name())); } + // Every viewer state, stream kind (both ways) and leave reason. + for (state, expected) in [ + (wire::ViewerState::Requested, ViewerState::Requested), + (wire::ViewerState::Connecting, ViewerState::Connecting), + (wire::ViewerState::Connected, ViewerState::Connected), + ] { + assert_eq!(ViewerState::from(state), expected); + } + for (sent, kind) in [ + (wire::StreamKind::Camera, StreamKind::Camera), + (wire::StreamKind::Screen, StreamKind::Screen), + (wire::StreamKind::Window, StreamKind::Window), + (wire::StreamKind::Other(9), StreamKind::Other(9)), + ] { + assert_eq!(StreamKind::from(sent), kind); + assert_eq!(wire::StreamKind::from(kind), sent); + } + for (reason, expected) in [ + (wire::LeaveReason::None, LeaveReason::None), + (wire::LeaveReason::Left, LeaveReason::Left), + (wire::LeaveReason::Denied, LeaveReason::Denied), + (wire::LeaveReason::Failed, LeaveReason::Failed), + (wire::LeaveReason::Kicked, LeaveReason::Kicked), + (wire::LeaveReason::Banned, LeaveReason::Banned), + (wire::LeaveReason::Other(42), LeaveReason::Other(42)), + ] { + assert_eq!(LeaveReason::from(reason), expected); + assert_eq!( + EndReason::from(wire::EndReason::Removed(Some(reason))), + EndReason::Removed(Some(expected)) + ); + } + for (reason, expected) in [ (wire::EndReason::Local, EndReason::Local), (wire::EndReason::Denied, EndReason::Denied), diff --git a/docs/research/ui-review.md b/docs/research/ui-review.md index c2bc257..3054e43 100644 --- a/docs/research/ui-review.md +++ b/docs/research/ui-review.md @@ -203,7 +203,7 @@ is not new in TS6. It is the classic client that TS3 already had. | Assigning server and channel groups, privilege keys (tokens) | none | | | Permission editor | none | TS6 discusses a simpler "easy view"; start there | | Server edit, "Recent server events" (log), complaints, client database, snapshots (TS6 beta4) | none | For admins; lower priority | -| Whisper lists and whisper hotkeys | incoming whispers only (`voelin-audio/src/encode.rs:90`: C2S only) | A TS signature feature: team leads whisper to the other leads | +| Whisper lists and whisper hotkeys | incoming whispers only (`out_audio` in `voelin-core/src/voice.rs`: C2S only) | A TS signature feature: team leads whisper to the other leads | | Asking for talk power | none (`client_talk_request` is not modelled) | Moderated channels | | Channel description (BBCode, pictures) | none (`ChannelInfo` has the topic only) | Shown when a channel is selected | | Server welcome message and host message in the chat | only stripped, in Home's news | Official clients print them in the Server tab, and host message mode 3 as a dialog |