Skip to content

Conversation

@mg-dev25
Copy link
Contributor

Improvement: Audio Recorder Quality & Crash Fix

While debugging audio issues on Linux/Wayland (related to #390), I noticed the audio recorder wasn't always picking the best settings. In fact, without this change, the application was crashing in a loop on my machine due to configuration mismatches.

I updated recorder.rs to explicitly check for F32 support and prioritize that over I16 or I32 if available. This prevents the crash and ensures the highest possible input quality for transcription.

Technical Implementation

The get_preferred_config method now iterates through all supported configurations and assigns a score based on the sample format, rather than selecting the first match.

// Prioritize F32 > I16 > I32 > others
let score = |fmt: cpal::SampleFormat| match fmt {
    cpal::SampleFormat::F32 => 4,
    cpal::SampleFormat::I16 => 3,
    cpal::SampleFormat::I32 => 2,
    _ => 1,
};

if score(config_range.sample_format()) > score(current.sample_format()) {
    best_config = Some(config_range);
}

Relates to #390

@cjpais
Copy link
Owner

cjpais commented Nov 30, 2025

@mg-dev25 im good to pull this in, but could you remove the change to bindings.ts, it's going to be autogenerated differently on different platforms so lets just keep it stable where it is for now

@mg-dev25
Copy link
Contributor Author

@cjpais Done.

@cjpais cjpais merged commit 244a99e into cjpais:main Nov 30, 2025
zhuzhuyule pushed a commit to zhuzhuyule/Votype that referenced this pull request Dec 13, 2025
zhuzhuyule pushed a commit to zhuzhuyule/Votype that referenced this pull request Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants