fix: always use default_input_config to avoid shared-mode stream rejection#1163
fix: always use default_input_config to avoid shared-mode stream rejection#1163dan-vernon wants to merge 2 commits intocjpais:mainfrom
Conversation
…ction CoreAudio (macOS) and WASAPI (Windows) only accept streams in the OS mixer's native shared-mode format. The previous get_preferred_config() tried to find a higher-quality format (preferring F32 over I16) by iterating supported_input_configs(), but those enumerate exclusive-mode formats that both backends reject with "stream configuration not supported" when opening in shared mode. Fixes the consistent recording failure on macOS and Windows where build_input_stream fails immediately. Resolves the same class of issue as cjpais#990. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Some devices (notably Bluetooth HFP on macOS, e.g. Sony MDR-1000X) report F32 in default_input_config() but CoreAudio rejects that format when the stream is actually opened — only I16 works for the HFP shared-mode stream. Pre-clone the sender and stop-flag (both cheap ref-count bumps) so we can retry with I16 before giving up. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
what was the reasoning behind closing this PR - did the fix not work? |
Hey @VirenMohindra - same error reoccurred after subsequently testing the fix with a Bluetooth input device, so I need to isolate this from a possible MacOS bluetooth / CoreAudio issue before re-opening. Thx |
|
Reopening with additional retry with Looking through git blame, the old implementation came from two separate changes. First, an explicit format preference ( The root issue is that the old Using The new For Windows, to be precise: this is still the safer, more API-aligned behaviour for shared-mode capture, but the exact failure mode reproduced here was on macOS, not tested on WASAPI. Validation so far:
Overall assessment: strong confidence for the observed macOS bug, lower risk because this mostly removes custom config-selection logic, but still limited by the lack of automated hardware-level coverage. |
| @@ -282,56 +303,16 @@ impl AudioRecorder { | |||
| fn get_preferred_config( | |||
There was a problem hiding this comment.
this is effectively a dead function now
|
@VirenMohindra I will need more time with this one, or we need to get a test build out to everyone with this I am generally in favor of using default configs always if possible. I do suspect it will help avoid some issues, but not sure if it will cause others. We just need to make sure Handy can handle the cases for the new configs it might be thrown |
🧪 Test Build ReadyBuild artifacts for PR #1163 are available for testing. Download artifacts from workflow run Artifacts expire after 30 days. |
Summary
get_preferred_config()'s format-selection logic with a direct call todefault_input_config()Failed to build input stream: The requested stream configuration is not supported by the deviceerror on macOS and WindowsProblem
get_preferred_config()iteratedsupported_input_configs()and picked the highest-scored sample format (preferring F32 over I16). However,supported_input_configs()enumerates exclusive-mode formats on both CoreAudio (macOS) and WASAPI (Windows). Since cpal opens streams in shared mode, the OS requires the stream to use the mixer's native format — which is whatdefault_input_config()returns. Passing a different format causedbuild_input_streamto fail immediately on every attempt.This root cause was identified by @VirenMohindra in #990. The existing
FrameResamplerinrun_consumer()already handles downsampling to the 16 kHz rate required by Whisper/Parakeet, so no other changes are needed.Testing
rustfmt --checkpassesRelated issues
Closes #990
AI assistance
This PR was written with the help of Claude Code. It was used extensively — log analysis, root cause diagnosis, code change, and PR writeup.