fix(client): list only real audio devices and persist the choice by id

The device pickers showed every ALSA PCM plugin (Discard all samples, Rate
Converter, JACK, Open Sound System, surround/dmix aliases). Enumeration now
goes through a pure filter that keeps the system default, the PipeWire and
PulseAudio servers and one entry per hardware endpoint, with technical tails
removed and a stable sort.

Selections are stored by device id instead of list position, so the filter
and hotplug cannot move a saved choice. Indexes saved by older versions are
migrated by device name; a missing device falls back to the default.

The same preferences change records whether the voice mode was chosen by
the person: a profile that only carries the old push-to-talk default now
starts in voice activation, explicit choices are kept.
This commit is contained in:
Loki 2026-10-24 23:59:27 +02:00
parent 82dd9a324d
commit 3b95df9e9c
Signed by: boba
GPG key ID: 253067914055423B
17 changed files with 780 additions and 210 deletions

View file

@ -33,13 +33,17 @@ impl Default for UiState {
mic_enabled: true,
ptt_held: false,
deafen: false,
vad_mode: 0,
vad_mode: crate::ui::state::DEFAULT_VOICE_MODE,
voice_bitrate: 64.0,
packet_interval: 1,
mic_device: 0,
mic_device_id: String::new(),
output_device: 0,
output_device_id: String::new(),
output_volume: 90.0,
device_lists: Default::default(),
vad_mode_chosen: false,
auto_reconnect: true,

View file

@ -8,6 +8,9 @@ pub use types::{ConnState, TrustPrompt, TrustPromptKind, UiState, VoiceUiState};
use models::bookmark_label_from_address;
/// Voice input mode of a fresh profile: 0 push to talk, 1 voice activation, 2 open microphone.
pub const DEFAULT_VOICE_MODE: usize = 1;
impl UiState {
pub fn remove_bookmark(&mut self, index: usize) {
if index < self.bookmarks.len() {

View file

@ -77,10 +77,20 @@ pub struct UiState {
pub vad_mode: usize,
pub voice_bitrate: f32,
pub packet_interval: usize,
/// Picker position of the microphone (0 is the system default).
pub mic_device: usize,
/// Persisted microphone id; empty is the system default.
pub mic_device_id: String,
/// Picker position of the output device (0 is the system default).
pub output_device: usize,
/// Persisted output device id; empty is the system default.
pub output_device_id: String,
pub output_volume: f32,
/// Devices behind the picker positions, as of the last enumeration.
pub device_lists: vnox_client::audio::DeviceLists,
/// True once the person picked a voice input mode themselves.
pub vad_mode_chosen: bool,
pub auto_reconnect: bool,