Skip to content

fix: fallback to next audio format if stream build fails#1083

Closed
givizager-boop wants to merge 1 commit intocjpais:mainfrom
givizager-boop:fix/audio-format-fallback
Closed

fix: fallback to next audio format if stream build fails#1083
givizager-boop wants to merge 1 commit intocjpais:mainfrom
givizager-boop:fix/audio-format-fallback

Conversation

@givizager-boop
Copy link
Copy Markdown

Problem

On some devices (e.g. Synaptics audio controllers), build_input_stream fails with error 0x80070057 when using F32 format, even though the device reports it as supported. The old code picked the best format once and gave up on failure.

Fix

Replace single-try logic with a retry loop that tries all supported formats in preference order (F32 → I16 → I32 → others). On failure, logs a warning and tries the next format.

  • get_preferred_configget_configs_by_preference returning sorted Vec
  • Loop over configs, clone sample_tx for each attempt
  • First successful build_stream wins

Tested on

  • Synaptics HD Audio Device (Windows) — previously crashed on F32, now falls back to I16 ✓

On some devices (e.g. Synaptics HD Audio), build_input_stream fails
with 0x80070057 on F32 even though the device claims to support it.

Replace single-try logic with a retry loop over all supported formats
sorted by preference (F32 → I16 → I32 → others). On failure logs a
warning and tries the next format.

- get_preferred_config → get_configs_by_preference returning Vec
- Loop with sample_tx.clone() per attempt
- First successful build_stream wins
@givizager-boop
Copy link
Copy Markdown
Author

Hi! Could you trigger the \ workflow for this PR? The fix addresses a real issue with Synaptics audio devices on Windows where \ fails silently on F32 format. I can't build locally because the project has a dependency issue between \ and \ — \ is forward-declared as opaque in the bundled whisper.cpp header, causing compile errors. A test build from CI would let me verify the fix works. Thanks!

@cjpais
Copy link
Copy Markdown
Owner

cjpais commented Mar 18, 2026

Closing in favor of #1084, we can discuss further there if you would like!

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