{"record":{"id":"5e7c59d15c8d9782","repo":"Zackriya-Solutions/meetily","slug":"cannot-access-microphone","errorCode":null,"errorMessage":"Cannot access microphone: {}","messagePattern":"Cannot access microphone: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/audio/devices/discovery.rs","lineNumber":141,"sourceCode":"        };\n\n        let config = device\n            .default_input_config()\n            .map_err(|e| anyhow::anyhow!(\"Failed to get microphone config: {}\", e))?;\n\n        let callback_fired = Arc::new(AtomicBool::new(false));\n        let callback_fired_clone = callback_fired.clone();\n\n        let stream = device\n            .build_input_stream(\n                &config.into(),\n                move |_data: &[f32], _: &cpal::InputCallbackInfo| {\n                    callback_fired_clone.store(true, Ordering::SeqCst);\n                },\n                |err| warn!(\"[verify_microphone_access] test stream error: {}\", err),\n                None,\n            )\n            .map_err(|e| anyhow::anyhow!(\"Cannot access microphone: {}\", e))?;\n\n        stream\n            .play()\n            .map_err(|e| anyhow::anyhow!(\"Cannot start microphone: {}\", e))?;\n\n        // Wait up to 5s for the first callback.\n        for _ in 0..50 {\n            if callback_fired.load(Ordering::SeqCst) {\n                drop(stream);\n                info!(\"[verify_microphone_access] microphone access verified\");\n                return Ok(());\n            }\n            std::thread::sleep(std::time::Duration::from_millis(100));\n        }\n\n        drop(stream);\n        Err(anyhow::anyhow!(\n            \"Microphone permission not granted. Please allow microphone access in \\","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/a2cb62e827da7ef59f65064c97233efb2313878e/frontend/src-tauri/src/audio/devices/discovery.rs#L123-L159","documentation":"After obtaining a config, verify_microphone_access builds a test input stream with device.build_input_stream(). If cpal cannot create the stream (device busy, backend error, stream config rejected), the error is wrapped as 'Cannot access microphone: {}'. This means a stream could not even be constructed for the device.","triggerScenarios":"device.build_input_stream(config, callback, err_callback, None) returning Err - device exclusively locked by another app, invalid StreamConfig, or backend-level failure while opening the device.","commonSituations":"Another app holds the mic in exclusive mode (Windows WASAPI exclusive); Zoom/Teams/Discord occupying the device with broken drivers; sample rate from default_input_config rejected by driver; macOS core audio device reset.","solutions":["Close other apps using the microphone, then retry the verification.","Pick a different microphone device via device selection UI and retry.","Restart the audio subsystem (or reboot) to clear stuck exclusive locks.","Use a stream config explicitly supported by the device instead of blindly using default_input_config values."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match verify_microphone_access().await {\n    Ok(()) => start_recording(),\n    Err(e) if e.to_string().contains(\"Cannot access microphone\") => {\n        toast.error('Microphone is busy or inaccessible. Close other apps using it and retry.');\n    }\n    Err(e) => show_error(e),\n}","preventionTips":["Ask users to close other capture apps (Zoom/Teams/Discord) before first recording.","Offer explicit device selection rather than relying on the default input.","Avoid WASAPI exclusive-mode devices; prefer shared mode.","Add a short retry with backoff around verification."],"tags":["audio","cpal","microphone","device-busy"],"backgroundTag":"permission-denied","analyzedSha":"a2cb62e827da7ef59f65064c97233efb2313878e","analyzedAt":"2026-09-12T11:12:14.152Z","contentChangedAt":"2026-09-12T11:12:14.152Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}