Files
VoelinClient/crates/voelin-audio/src/settings.rs
T
Claude e050148a32 Rename the project to Voelin; packages hold only the app, tsgw is a Linux server package
The product is Voelin (app id io.github.faumaray.Voelin), everywhere:
- crates tsc-* -> voelin-* (and voelin-fuzz), the desktop binary
  tsc-desktop -> voelin, the development CLI tsctl -> voelinctl;
- the Android app: applicationId, Kotlin package io.github.faumaray.voelin,
  VoelinApp, libvoelin_android.so (JNI class names follow);
- TSC_* environment variables -> VOELIN_*, Gradle properties tsc.* ->
  voelin.*, signing secrets VOELIN_SIGNING_*;
- the data/config/cache/state folder tsc -> voelin, the keyring service,
  thread names, the dev compose project;
- desktop file, metainfo, icon, Flatpak manifest, NSIS installer, docs.
The gateway keeps its name: bin tsgw (crate voelin-gateway), TSGW_* env
vars, the tsgw.v1+json protocol, the tsgw image. The window title and the
About page show "Voelin <version>" from voelin_platform::APP_NAME.

Packages (scripts/package.sh): the app only (voelin, voelin.exe, APKs,
Flatpak). voelinctl is a development tool and in no package. tsgw is for
servers and now its own Linux package, tsgw_<v>_amd64.deb and
tsgw-<v>-linux-x86_64.tar.gz, with a sandboxed systemd unit
(packaging/linux/tsgw.service; /etc/tsgw config, /var/lib/tsgw state) and
dependencies of its own (no GUI libraries). docs/gateway-admin.md has an
Install section.

Fixes:
- package-windows: makensis on Windows found no file through "D:/a/..."
  paths; pass Windows paths (cygpath -w).
- StartupWMClass is the app id, which the app sets as its X11 WM_CLASS
  (it was the binary name, so desktops could not match the window).
- Gradle wrapper download timeout 10 s -> 60 s (slow proxies).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-26 21:11:17 +00:00

81 lines
2.4 KiB
Rust

//! All user audio settings in one serde struct, e.g. for
//! `voelin_store::Store::set_setting("audio", &settings)`. Missing fields take
//! their defaults, so stored settings survive new options.
use serde::{Deserialize, Serialize};
use crate::process::ProcessingSettings;
use crate::vad::VadSettings;
/// When the microphone is sent.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum TransmitMode {
/// While the push-to-talk key or button is held.
#[default]
PushToTalk,
/// While the voice activity detector hears speech.
VoiceActivation,
/// Always (unless muted).
Continuous,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct AudioSettings {
pub transmit: TransmitMode,
pub processing: ProcessingSettings,
pub vad: VadSettings,
/// Microphone by device id (`device::DeviceInfo::id`); `None` follows
/// the system default.
pub input_device: Option<String>,
/// Speakers by device id; `None` follows the system default.
pub output_device: Option<String>,
/// Output volume for everyone, linear (1 = unchanged), applied before
/// the echo canceller sees the signal.
pub output_volume: f32,
/// Audio kept queued for the speakers. Lower is snappier, higher
/// survives scheduling hiccups.
pub playback_buffer_ms: u32,
}
impl Default for AudioSettings {
fn default() -> Self {
Self {
transmit: TransmitMode::PushToTalk,
processing: ProcessingSettings::default(),
vad: VadSettings::default(),
input_device: None,
output_device: None,
output_volume: 1.0,
playback_buffer_ms: 60,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn json_roundtrip_and_defaults() {
let mut s = AudioSettings {
transmit: TransmitMode::VoiceActivation,
input_device: Some("alsa:hw:1,0".into()),
..Default::default()
};
s.processing.echo_cancellation = false;
s.vad.threshold_db = -35.0;
let json = serde_json::to_string(&s).unwrap();
assert_eq!(serde_json::from_str::<AudioSettings>(&json).unwrap(), s);
// Older or partial settings fill in defaults.
let partial: AudioSettings =
serde_json::from_str(r#"{"transmit":"continuous","vad":{"hangover_ms":100}}"#).unwrap();
assert_eq!(partial.transmit, TransmitMode::Continuous);
assert_eq!(partial.vad.hangover_ms, 100);
assert_eq!(partial.vad.threshold_db, VadSettings::default().threshold_db);
assert_eq!(partial.processing, ProcessingSettings::default());
}
}