{"record":{"id":"199fc49503ef9f8b","repo":"Zackriya-Solutions/meetily","slug":"failed-to-get-default-input-config","errorCode":null,"errorMessage":"Failed to get default input config: {}","messagePattern":"Failed to get default input config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/audio/devices/configuration.rs","lineNumber":132,"sourceCode":"    #[cfg(target_os = \"windows\")]\n    {\n        return super::platform::get_windows_device(audio_device);\n    }\n\n    #[cfg(not(target_os = \"windows\"))]\n    {\n        use cpal::traits::{DeviceTrait, HostTrait};\n\n        let host = cpal::default_host();\n\n        match audio_device.device_type {\n            DeviceType::Input => {\n                for device in host.input_devices()? {\n                    if let Ok(name) = device.name() {\n                        if name == audio_device.name {\n                            let default_config = device\n                                .default_input_config()\n                                .map_err(|e| anyhow!(\"Failed to get default input config: {}\", e))?;\n                            return Ok((device, default_config));\n                        }\n                    }\n                }\n            }\n            DeviceType::Output => {\n                #[cfg(target_os = \"macos\")]\n                {\n                    // Use default host for all macOS output devices\n                    // Core Audio backend uses direct cidre API for system capture, not cpal\n                    for device in host.output_devices()? {\n                        if let Ok(name) = device.name() {\n                            if name == audio_device.name {\n                                let default_config = device\n                                    .default_output_config()\n                                    .map_err(|e| anyhow!(\"Failed to get output config: {}\", e))?;\n                                return Ok((device, default_config));\n                            }","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/audio/devices/configuration.rs#L114-L150","documentation":"Wrapped cpal error from Device::default_input_config() while get_cpal_device (configuration.rs:132) iterated the default host input devices looking for an exact name match. The device object was found by name, but querying its default stream config failed - cpal reports the underlying host error (DeviceNotAvailable on macOS CoreAudio, ALSA errors on Linux). The anyhow! with ? aborts the whole device search, so later candidates and the not-found error are never reached.","triggerScenarios":"A matching input device exists in enumeration but is unplugged/disabled between enumeration and the config query; macOS microphone permission not granted (CoreAudio errors on input config queries); an exclusive-mode app (ASIO/DVO) holds the device; a Bluetooth headset that disappeared mid-pairing; a Linux PulseAudio/ALSA device whose source became unavailable.","commonSituations":"Selecting a USB headset then unplugging it before start_recording; first launch on macOS with mic permission denied in System Settings; Bluetooth headset sleeping between device list refresh and record start; enumeration ghosts from devices whose names differ only by invisible Unicode.","solutions":["Check the inner cpal error string - it distinguishes permission vs device-gone vs host errors.","Re-run list_audio_devices (refresh the device list in the UI) and confirm the device still appears before retrying start_recording.","On macOS, grant Microphone access (System Settings > Privacy & Security > Microphone) and restart the app.","Reconnect/reselect the device (re-pair Bluetooth, replug USB) or fall back to the default input via default_input_device().","Longer term: in get_cpal_device, treat a per-device config failure as skip-and-continue instead of aborting with ?, so other candidates or the final Device-not-found path apply."],"exampleFix":"// before: first matching device's config failure aborts the search\nlet default_config = device.default_input_config()\n    .map_err(|e| anyhow!(\"Failed to get default input config: {}\", e))?;\n\n// after: skip devices whose config query fails, keep searching\nmatch device.default_input_config() {\n    Ok(cfg) => return Ok((device, cfg)),\n    Err(e) => { warn!(\"Skipping device '{}' config error: {}\", name, e); continue; }\n}","handlingStrategy":"fallback","validationCode":"// Rust: confirm the device still enumerates before asking for its config\nfn device_still_listed(target: &str) -> bool {\n    cpal::default_host().input_devices()\n        .map(|it| it.any(|d| d.name().map(|n| n == target).unwrap_or(false)))\n        .unwrap_or(false)\n}\nif !device_still_listed(&name) { /* refresh picker / use default instead */ }","typeGuard":null,"tryCatchPattern":"// Catch the wrapped cpal error and degrade to the default input device\nlet (dev, cfg) = match get_cpal_device(&audio_device) {\n    Ok(found) => found,\n    Err(e) if e.to_string().starts_with(\"Failed to get default input config\") => {\n        warn!(\"Selected mic unavailable ({}); using default\", e);\n        default_input_device_config()? // explicit fallback path\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Refresh list_audio_devices immediately before start_recording; do not trust a cached picker.","Request microphone permission at app startup on macOS, not at record time.","Unplug/re-pair hardware before selecting it, not after; surface an enumeration refresh in the UI.","Patch get_cpal_device to skip a device whose config query fails instead of aborting the search."],"tags":["audio","cpal","device-config","permissions","macos","linux"],"backgroundTag":"audio-device-unavailable","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}