You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(audio): fix device selection and eliminate duplication in sounddevice backend
The original get_input_device_id() and get_output_device_id() had two issues:
1. Both incorrectly returned sd.default.device[1] (default OUTPUT device) as fallback
2. Nearly identical code duplicated between the two methods
This caused failures when:
- get_input_device_id() returned an output-only device for recording
- get_output_device_id() always returned the same device regardless of type
Changes:
- Extract shared logic into _find_device_id(name_contains, device_type) helper
- Use dynamic channel_key: "max_input_channels" or "max_output_channels"
- Proper fallback: search for first device with appropriate channel type
- Raise clear RuntimeError if no suitable device exists
- Fix typo: logger.warningt → logger.warning
This ensures both methods always return valid devices of the correct type.
0 commit comments