fix: cap audio device enumeration and give a clear error on hang (#40)#44
Merged
Conversation
The dshow -list_devices probe can block on some setups (a misbehaving audio driver), so list_audio_devices and system-audio recording could hang the full 30s and return the raw "ffmpeg timed out" text. Enumeration now uses a 12s cap, closes the child's stdin (a known hang cause), and surfaces a clear, actionable error. A successful result is cached for the process so a recording does not re-pay the probe; list_audio_devices forces a fresh probe. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
92c1c66 to
119c101
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #40.
list_audio_devices(andstart_recordingwithaudio.source: "system", which resolves the loopback device first) could hang for the full 30s timeout and then fail with the rawffmpeg timed out after 30s, instead of listing devices or giving an actionable message. The dshow-list_devicesprobe blocks on some setups (a misbehaving audio driver, or no audio hardware).Changes
ENUM_TIMEOUT_MScap.runCapturegained acloseStdinoption) - a known cause of the dshow probe hanging.Could not enumerate audio devices (...)error with a fix hint, instead of the rawffmpeg timed outtext.list_audio_devicesforces a fresh probe (forceRefresh), so a device enabled mid-session still shows up.clearAudioDeviceCache()drops the cache.Notes
The pure parse/pick helpers are unchanged and still covered. The new timeout/cache behavior is integration-level (it spawns ffmpeg); the suite deliberately keeps unit tests pure and mocks nothing, so no spawn-mocked test was added.
Verification
npm run build,npm run typecheck,npm testall pass (136 passed, 6 skipped).🤖 Generated with Claude Code