Discord names a speaker's SSRC in the Speaking op only the first time they speak, and the op arrives after their first UDP packets. songbird 0.6.1 dropped the DAVE packets it could not decrypt yet, so the first ~100 ms of the first thing each person said after a join were lost (live 2026-11-18: "자비스 서울 날씨 어때" arrived as "아비 서울날씨 어때", and the first call after the 01:20 start as "아비스"). songbird is vendored in app/vendor/songbird with one patch: packets of an unnamed SSRC are held (1 s, 50 packets each, 32 SSRCs) and processed in arrival order once it is named, and the Speaking event is sent before the SSRC is named so handlers know the speaker first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
1.3 KiB
Rust
52 lines
1.3 KiB
Rust
//! Configuration for connection retries.
|
|
|
|
mod strategy;
|
|
|
|
pub use self::strategy::*;
|
|
|
|
use std::num::NonZeroU8;
|
|
|
|
use crate::FloatDuration;
|
|
|
|
/// Configuration to be used for retrying driver connection attempts.
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
pub struct Retry {
|
|
/// Strategy used to determine how long to wait between retry attempts.
|
|
///
|
|
/// *Defaults to an [`ExponentialBackoff`] from 0.25s
|
|
/// to 10s, with a jitter of `0.1`.*
|
|
///
|
|
/// [`ExponentialBackoff`]: Strategy::Backoff
|
|
pub strategy: Strategy,
|
|
/// The maximum number of retries to attempt.
|
|
///
|
|
/// `None` will attempt an infinite number of retries,
|
|
/// while `Some(0)` will attempt to connect *once* (no retries).
|
|
///
|
|
/// *Defaults to `Some(5)`.*
|
|
pub retry_limit: Option<NonZeroU8>,
|
|
}
|
|
|
|
impl Default for Retry {
|
|
fn default() -> Self {
|
|
Self {
|
|
strategy: Strategy::Backoff(ExponentialBackoff::default()),
|
|
retry_limit: Some(const { NonZeroU8::new(5).unwrap() }),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Retry {
|
|
pub(crate) fn retry_in(
|
|
&self,
|
|
last_wait: Option<FloatDuration>,
|
|
attempts: u8,
|
|
) -> Option<FloatDuration> {
|
|
if self.retry_limit.is_none_or(|a| attempts < a.get()) {
|
|
Some(self.strategy.retry_in(last_wait))
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
}
|