{"record":{"id":"17ccd2ea6cf9c35d","repo":"Zackriya-Solutions/meetily","slug":"no-default-input-device-found","errorCode":null,"errorMessage":"No default input device found","messagePattern":"No default input device found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/audio/devices/microphone.rs","lineNumber":12,"sourceCode":"use anyhow::{anyhow, Result};\nuse cpal::traits::{HostTrait, DeviceTrait};\nuse log::{info, warn};\n\nuse super::configuration::{AudioDevice, DeviceType};\n\n/// Get the default input (microphone) device for the system\npub fn default_input_device() -> Result<AudioDevice> {\n    let host = cpal::default_host();\n    let device = host\n        .default_input_device()\n        .ok_or_else(|| anyhow!(\"No default input device found\"))?;\n    Ok(AudioDevice::new(device.name()?, DeviceType::Input))\n}\n\n/// Find the built-in microphone device (wired, stable, consistent sample rate)\n///\n/// Searches for MacBook/built-in microphone patterns to find the hardware\n/// microphone instead of Bluetooth devices. This is useful for:\n/// - Avoiding Bluetooth variable sample rate issues\n/// - Getting stable wired audio for recording\n/// - Fallback when Bluetooth device is default but unreliable\n///\n/// Returns None if no built-in microphone found\npub fn find_builtin_input_device() -> Result<Option<AudioDevice>> {\n    let host = cpal::default_host();\n\n    // Built-in microphone name patterns (platform-specific)\n    let builtin_patterns = [\n        // macOS patterns","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/audio/devices/microphone.rs#L1-L30","documentation":"default_input_device (microphone.rs:12) asks cpal's default host for host.default_input_device() and gets None - the OS reports no default capture device at all. Unlike Device-not-found, this fails before any name matching: there is no input device selected/available system-wide. (On success the function also propagates device.name()? errors, but the ok_or_else is specifically the None case.)","triggerScenarios":"No microphone attached (desktop without webcam/mic); mic disabled in BIOS/Device Manager or blocked by policy; macOS microphone privacy denial can surface as no default input; headless/CI environments with no audio hardware; the default device was a virtual driver (BlackHole/Soundflower) that has been uninstalled, leaving the OS without a default; Linux sandbox with an empty PulseAudio source list.","commonSituations":"First run on a fresh machine before any input device is configured; after uninstalling a virtual audio driver that held the default-input slot; running over X-forwarding/remote desktop where no audio devices are exported; OS update resetting the default device while none is connected.","solutions":["Attach/enable a physical input device and confirm the OS shows one (macOS System Settings > Sound > Input; Windows Sound settings; Linux pactl list short sources).","On macOS grant microphone permission and relaunch; on Linux check PulseAudio/PipeWire is running (pulseaudio --check / systemctl --user status pipewire-pulse).","In the app, pick a specific mic from the device list instead of relying on the default; find_built_in_microphone() is this module's own fallback for exactly this situation.","If a virtual driver was removed, set any remaining device as system default so the OS default is valid again.","For headless test environments, load a null source (pactl load-module module-null-source) so a default exists."],"exampleFix":"// before: hard failure when the OS has no default input\nlet device = host.default_input_device()\n    .ok_or_else(|| anyhow!(\"No default input device found\"))?;\n\n// after: fall back to the built-in mic finder already present in this module\nlet device = host.default_input_device()\n    .or_else(find_built_in_microphone) // Option-returning helper\n    .ok_or_else(|| anyhow!(\"No input device found (default missing and no built-in mic)\"))?;","handlingStrategy":"fallback","validationCode":"// Check whether any input device exists before entering the record flow\nfn any_input_available() -> bool {\n    cpal::default_host().input_devices().map(|mut it| it.next().is_some()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"// No default input -> try the built-in mic finder, else instruct the user\nlet mic = match default_input_device() {\n    Ok(m) => m,\n    Err(e) if e.to_string().contains(\"No default input device\") => {\n        find_built_in_microphone().ok_or_else(|| anyhow!(\"Connect or enable a microphone\"))?\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Ship a device-availability check on the record screen: disable Record when no input enumerates.","Request OS mic permission during onboarding so CoreAudio exposes inputs.","After uninstalling virtual audio drivers, set a real default device in OS settings.","In headless CI, load a null source (PulseAudio) so a default exists for tests."],"tags":["audio","cpal","no-microphone","hardware","permissions","default-device"],"backgroundTag":"no-default-audio-device","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}